问题
my script is:
from __future__ import division
import numpy
import scipy
from pyomo.environ import *
from pyomo.dae import *
from pyomo.opt import SolverFactory
m=ConcreteModel()
m.x3=Var(within=NonNegativeReals)
m.u=Var(within=NonNegativeReals)
def _con(m):
return m.x3 >=3
m.con=Constraint(rule=_con)
def _con2(m):
return 4 >= m.u >=1
m.con2=Constraint(rule=_con2)
m.obj=Objective(expr=m.x3*m.u)
opt = SolverFactory("Ipopt", executable = "/Ipopt-3.12.6/bin/ipopt")
results = opt.solve(m)
results.write()
Although this is a very simple problem and although the program states that it has found the optimal solution, the number of solutions is 0 and there is not any solution displayed.
Any ideas??
Thanks a lot.
回答1:
In the most recent versions of Pyomo, the solution is loaded into the model by default. The results object should be used to check status information. If you want to interrogate the solution you can do so by accessing the model components directly and checking their value, or you can do the following:
m.solutions.store_to(results)
results.write()
来源:https://stackoverflow.com/questions/39941520/pyomo-ipopt-does-not-return-solution