You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm on Windows 11. I have HiGHS version 1.7.2 Githash 5ce7a2753. Copyright (c) 2024 HiGHS under MIT licence terms in a given directory (EDIT: same problem with AMPL/HiGHS Optimizer [1.7.1] (Windows AMD64), driver(20240724), MP(20240724)).
This program (standard solver factory doesn't accept 'highs' argument which is another bug):
import os
from pyomo.environ import ConcreteModel, Var, Objective, NonNegativeReals, Constraint
from pyomo.contrib.appsi.solvers import Highs
# Set the environment variable PATH to include the directory of HiGHS executable
os.environ['PATH'] += os.pathsep + r"C:\bin\Highs\bin"
# Define the model
model = ConcreteModel("MyModel")
# Variables (Renamed to x1 and x2)
model.x1 = Var(name='x1', domain=NonNegativeReals)
model.x2 = Var(name='x2', domain=NonNegativeReals)
# Quadratic Objective function
model.obj = Objective(expr=model.x1 + model.x2 , sense=1) # Minimize
# Constraints
model.con1 = Constraint(expr=model.x1 + 2 * model.x2 >= 1)
model.con2 = Constraint(expr=3 * model.x1 + 4 * model.x2 <= 2)
# Instantiate the HiGHS solver directly via APPSI
solver = Highs()
# Solve the model
results = solver.solve(model)
# Display the results
print("Termination Condition:", results.termination_condition)
# Print the values of the variables
print(f"x1 = {model.x1.value}")
print(f"x2 = {model.x2.value}")
# Display full model details
print()
model.display()
Traceback (most recent call last):
File "C:\Micha\Programming\Python\Optimierung\highs_pyomo.py", line 26, in <module>
results = solver.solve(model)
^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\site-packages\pyomo\contrib\appsi\solvers\highs.py", line 263, in solve
self.set_instance(model)
File "C:\Python312\Lib\site-packages\pyomo\contrib\appsi\solvers\highs.py", line 383, in set_instance
self.add_block(model)
File "C:\Python312\Lib\site-packages\pyomo\contrib\appsi\base.py", line 1128, in add_block
self.set_objective(obj)
File "C:\Python312\Lib\site-packages\pyomo\contrib\appsi\base.py", line 1083, in set_objective
self._set_objective(obj)
File "C:\Python312\Lib\site-packages\pyomo\contrib\appsi\solvers\highs.py", line 595, in _set_objective
raise DegreeError(
pyomo.contrib.appsi.solvers.highs.DegreeError: Highs interface does not support expressions of degree None
Solving the corresponding lp file model.write('model_output.lp', format='lp') on commandline using highs.exe works (after some syntactic corrections).
I'm on Windows 11. I have
HiGHS version 1.7.2 Githash 5ce7a2753. Copyright (c) 2024 HiGHS under MIT licence terms
in a given directory (EDIT: same problem withAMPL/HiGHS Optimizer [1.7.1] (Windows AMD64), driver(20240724), MP(20240724)
).This program (standard solver factory doesn't accept
'highs'
argument which is another bug):works well but changing objective to
model.obj = Objective(expr=model.x1*model.x1 + model.x2*model.x2, sense=1)
results in
Solving the corresponding lp file
model.write('model_output.lp', format='lp')
on commandline using highs.exe works (after some syntactic corrections).EDIT: Changing the line 591ff in
highs.py
from
quadratic=False
toquadratic=True
removes the error and solution is produced.The text was updated successfully, but these errors were encountered: