Pyomo Ipopt 不返回解决方案 [英] Pyomo Ipopt does not return solution

查看:96
本文介绍了Pyomo Ipopt 不返回解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脚本是:

    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()

虽然这是一个非常简单的问题,虽然程序指出它找到了最优解,解数为0,没有显示任何解.

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.

有什么想法吗??

非常感谢.

推荐答案

在最新版本的 Pyomo 中,解决方案默认加载到模型中.结果对象应该用于检查状态信息.如果您想询问解决方案,您可以直接访问模型组件并检查它们的值,或者您可以执行以下操作:

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()

这篇关于Pyomo Ipopt 不返回解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆