Pyomo Ipopt does not return solution

2019-05-25 06:32发布

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.

标签: ipopt pyomo
1条回答
该账号已被封号
2楼-- · 2019-05-25 06:55

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()
查看更多
登录 后发表回答