Open
Description
Summary
Pyomo 6.7.2 added support for the MAiNGO solver. When running a simple model, Pyomo hangs, with no output or result.
Steps to reproduce the issue
I'm running the following model. If the solver is set to 'bonmin', then Pyomo returns the correct optimal solution of x = 2, z = -1. When the solver if set to 'maingo', Pyomo produces no output. In Task Manager, I can see that the MAiNGO.exe process is running and using the CPU, but it does not end.
import pyomo.environ as pyo
Model = pyo.ConcreteModel()
Model.x = pyo.Var(domain = pyo.Reals, bounds = (0, 8), initialize = 1)
z = -1 * pyo.exp(-((Model.x - 2)**2))
Model.Obj = pyo.Objective(expr = z, sense = pyo.minimize)
Solver = pyo.SolverFactory('maingo')
Results = Solver.solve(Model, load_solutions = True, tee = True)
print(f'\nx = {Model.x():7.4f} z = {Model.Obj():7.4f} {Results.solver.termination_condition}\n')
MAiNGO correctly solves the same model when written using its interface, as follows:
from maingopy import *
from math import pi
class Model(MAiNGOmodel):
def __init__(self):
MAiNGOmodel.__init__(self) # Should be there for technical reasons
def get_variables(self):
variables = [OptimizationVariable(Bounds(0,8), VT_CONTINUOUS, "x") ]
return variables
def get_initial_point(self):
initialPoint = [1]
return initialPoint
def evaluate(self, vars):
x = vars[0]
result = EvaluationContainer()
result.objective = -1 * exp(-((x - 2)**2))
result.ineq = [x - 8] # x <= 8
result.ineq = [-x] # x >= 0
result.output = [OutputVariable("Result of x: ", x)]
return result
myModel = Model()
myMAiNGO = MAiNGO(myModel)
fileName = ""
myMAiNGO.read_settings(fileName) # If fileName is empty, MAiNGO will attempt to open MAiNGOSettings.txt
maingoStatus = myMAiNGO.solve()
Information on your system
Pyomo version: 6.7.2
Python version: 3.11.8
Operating system: Windows 11
How Pyomo was installed (PyPI, conda, source): PyPl
Solver (if applicable): MAiNGO