Reputation: 129
Online I can read that it is posible to solve Mixed-Integer Nonlinear problems with pyomo. But I don´t understand how. I solved problems with “glpk” and “ipopt” solvers but both don´t work for my current problem (ipopt doesn´t respect a boolean variable). (I also rebuild the problem to avoid the Boolean variable, but in case that the global optimum is at 0 (in one dimension) ipopt only shows me a local optimum far from 0).
I found this paper http://egon.cheme.cmu.edu/Papers/Bernal_Chen_MindtPy_PSE2018Paper.pdf presenting MindtPy but I didn´t figure out how to install it. I read about many possible solvers, such as BARON, ANTIGONE, SCIP, LINDOGLOBAL and COUENNE. But how can I use them in pyomo and if possible without a license or is there another solver that you can recommend that comes with pyomo or anaconda (or easy to install). Thank a lot in advance
Upvotes: 4
Views: 5116
Reputation: 14376
I'm working on a freely available MINLP solver for Pyomo (or AMPL) called APOPT. You can download a version that currently solves NLP problems in Pyomo (MINLP not yet supported). It sends the .nl problem to a server and then returns a .sol solution to Pyomo.
I have the interface working with Python Gekko for MINLP problems. This is a preview of the solver performance for Pyomo as well. You can install Gekko with:
pip install gekko
Or if you are in a Jupyter notebook, you can install Gekko by running this command in a cell (only needed once):
!pip install gekko
Here is an example of an MINLP problem:
from gekko import GEKKO
m = GEKKO() # Initialize gekko
m.options.SOLVER=1 # APOPT is an MINLP solver
# optional solver settings with APOPT
m.solver_options = ['minlp_maximum_iterations 500', \
# minlp iterations with integer solution
'minlp_max_iter_with_int_sol 10', \
# nlp sub-problem max iterations
'nlp_maximum_iterations 50', \
# maximum deviation from whole number
'minlp_integer_tol 0.05', \
# covergence tolerance
'minlp_gap_tol 0.01']
# Initialize variables
x1 = m.Var(value=1,lb=1,ub=5)
x2 = m.Var(value=5,lb=1,ub=5)
# Integer constraints for x3 and x4
x3 = m.Var(value=5,lb=1,ub=5,integer=True)
x4 = m.Var(value=1,lb=1,ub=5,integer=True)
# Equations
m.Equation(x1*x2*x3*x4>=25)
m.Equation(x1**2+x2**2+x3**2+x4**2==40)
m.Obj(x1*x4*(x1+x2+x3)+x3) # Objective
m.solve(disp=False) # Solve
print('Results')
print('x1: ' + str(x1.value))
print('x2: ' + str(x2.value))
print('x3: ' + str(x3.value))
print('x4: ' + str(x4.value))
print('Objective: ' + str(m.options.objfcnval))
It produces the following output:
Results
x1: [1.3589086474]
x2: [4.5992789966]
x3: [4.0]
x4: [1.0]
Objective: 17.532267301
Upvotes: 3
Reputation: 2828
MindtPy is distributed with Pyomo in the most recent release (v. 5.6.2). Take a look at the examples here to see how problems can be formulated and solved with MindtPy. The other solvers you mentioned must be installed manually and added to your search path, some of them do require a license. COUENNE is a free, open-source option and you can find the installation instructions here. Search for the homepages of the other solvers to learn about their licensing and how to access them.
Upvotes: 1