Pyomo Ipopt does not return solution

喜欢而已 提交于 2020-02-02 11:21:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!