Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: property 'domain' of 'variable' object has no getter with experimental kernel interface using appsi_highs solver #3480

Closed
kdheepak opened this issue Feb 19, 2025 · 4 comments

Comments

@kdheepak
Copy link
Contributor

Summary

I'm unable to use pmo.SolverFactory("appsi_highs") with my optimization problem built using the experimental kernel interface:

Cell In[13], line 13
     10 def solve(self):
     11     solver = pmo.SolverFactory("appsi_highs")
---> 13     solver.solve(self.model)

File .../python3.12/site-packages/pyomo/contrib/appsi/base.py:1552, in LegacySolverInterface.solve(self, model, tee, load_solutions, logfile, solnfile, timelimit, report_timing, solver_io, suffixes, options, keepfiles, symbolic_solver_labels)
   1549 if options is not None:
   1550     self.options = options
-> 1552 results: Results = super(LegacySolverInterface, self).solve(model)
   1554 legacy_results = LegacySolverResults()
   1555 legacy_soln = LegacySolution()

File .../python3.12/site-packages/pyomo/contrib/appsi/solvers/highs.py:263, in Highs.solve(self, model, timer)
...
    984         v.value,
    985     )
    986 self._add_variables(variables)

AttributeError: property 'domain' of 'variable' object has no getter

This optimization problem works fine with ipopt. I'm assuming this is to do with the legacy solver vs new solvers?

>>> import pyomo.kernel as pmo
>>> pmo.SolverFactory("appsi_highs")

<pyomo.contrib.appsi.base.SolverFactoryClass.register.<locals>.decorator.<locals>.LegacySolver at 0x12b58af00>
>>> import pyomo.kernel as pmo

>>> pmo.SolverFactory("ipopt")
<pyomo.solvers.plugins.solvers.IPOPT.IPOPT at 0x12b589f70>

Steps to reproduce the issue

# example.py
import random
import pyomo.kernel as pmo

model = pmo.block()

model.max_n_samples = 3
model.samples = ["A", "B", "C", "D", "E"]

random.seed(42)
model.weights = [random.randint(1, 5) for _ in model.samples]

model.choices = pmo.variable_dict()
for p in model.samples:
    model.choices[p] = pmo.variable()

model.objective = pyo.objective(
    expr=sum(model.choices[p] * model.weights[i] for i, p in enumerate(model.samples)),
    sense=pyo.maximize,
)

model.max_samples = pyo.constraint(
    sum(model.choices[p] for p in model.samples) <= model.max_n_samples
)

pmo.SolverFactory("appsi_highs").solve(model)

Information on your system

Pyomo version: 6.8.2
Python version: 3.12.7
Operating system: MacOSX
How Pyomo was installed (PyPI, conda, source): PyPI
Solver (if applicable): appsi_highs

@kdheepak kdheepak added the bug label Feb 19, 2025
@mrmundt
Copy link
Contributor

mrmundt commented Feb 19, 2025

Thanks, @kdheepak - can you maybe do me a favor and try to use highs from #3476 to see if it's still an issue there? That's the interface we are going to be trying to make better / officially support.

@blnicho
Copy link
Member

blnicho commented Feb 19, 2025

@kdheepak as you noted, pyomo.kernel is experimental and not being maintained. We have no plans to add support for pyomo.kernel in our new solver interfaces.

@blnicho blnicho closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2025
@kdheepak
Copy link
Contributor Author

Thanks @blnicho for the clarification. Just to confirm, even though ipopt works right now, it is possible that it won't work in the future? Should we not use pyomo.kernel in our code at all? I do like the API of pyomo.kernel and wanted to organize our model using "block"s more.

@mrmundt
Copy link
Contributor

mrmundt commented Feb 19, 2025

@kdheepak - ipopt will continue to work, but pyomo.kernel is not planned for any further updates. We recommend using ipopt in the standard format (e.g., opt = pyo.SolverFactory('ipopt'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants