【问题标题】:Pyomo not returning optimumPyomo没有返回最佳状态
【发布时间】:2021-12-08 23:44:57
【问题描述】:

我正在尝试在 pyomo 中解决以下问题:

为此,我定义了以下模型,并使用MindtPy 解决:

import pyomo.environ as pyo

model = pyo.ConcreteModel()
model.x = pyo.Var(domain=pyo.NonNegativeIntegers)
model.y = pyo.Var(domain=pyo.Binary)
model.constraint = pyo.Constraint(expr = model.x * model.y <= 10)
model.objective = pyo.Objective(expr = model.x * model.y - model.y, sense = pyo.maximize)
res = pyo.SolverFactory('mindtpy').solve(model)

返回的解是x=0, y=0,这显然是次优的(x=10, y=1 是最优解)。我不知道为什么求解器无法为这样一个(显然)简单的问题给出正确的结果,所以我怀疑我的模型中的某个地方有错误。知道这里发生了什么吗?

res 回溯如下:

{
   "Problem":[
      {
         "Name":"unknown",
         "Lower bound":7.494096406374967e-09,
         "Upper bound":-5.2559467146445e-09,
         "Number of objectives":1,
         "Number of constraints":1,
         "Number of variables":2,
         "Number of binary variables":1,
         "Number of integer variables":1,
         "Number of continuous variables":0,
         "Number of nonzeros":"None",
         "Sense":"maximize",
         "Number of disjunctions":0
      }
   ],
   "Solver":[
      {
         "Name":"MindtPyOA",
         "Status":"ok",
         "Message":"None",
         "User time":0.07270376699943881,
         "System time":"None",
         "Wallclock time":0.07270376699943881,
         "Termination condition":"optimal",
         "Termination message":"None",
         "Timing":Bunch(Call after main solve = 6.144000508356839e-06,
         Call after subproblem solve = 2.660000063769985e-06,
         OA cut generation = 0.0005902640004933346,
         fixed subproblem = 0.01827019400025165,
         initialization = 0.037425839999741584,
         main = 0.005608348999885493,
         main loop = 0.02800907599976199,
         main_timer_start_time = 5267.784403186,
         total = 0.07270376699943881),
         "Iterations":1,
         "Num infeasible nlp subproblem":0,
         "Best solution found time":0.07225401699997747
      }
   ]
}

【问题讨论】:

  • 我用Gurobi解决了这个问题,解决方法还可以(x=10, y=1, obj=9)。我不知道这是 mindtpy 错误还是 mindtpy 求解器不支持此类问题。你可以尝试在 Pyomo Github 中打开一个关于这个问题的问题吗?我对此很感兴趣。我会关注这个问题。谢谢
  • 没试过 Gurobi,谢谢你的提示!打开了一个问题here
  • 我不认为 MindtPy 是一个全局求解器。所以这可能发生。另一方面,Gurobi 是一个全局二次求解器。
  • published paper 关于Mindtpy 他们声称,事实上,MIndtpy 能够找到应用所引用的分解算法的全局最优值。 ...The methods implemented in this toolbox are designed to find the global optimal solution of convex MINLP problems.... — (Bernal et all, 2018)
  • " MINLP问题"。非凸问题需要全局求解器。海报提出了一个非凸问题。

标签: python pyomo nonlinear-optimization


【解决方案1】:

如果问题是非凸的,求解器无法保证您获得全局最优值。优化问题是凸的,如果: 目标函数是凸的, 不等式约束是凸的, 等式约束是线性的。

大多数求解器使用“梯度良好”的方法,因此如果它们生成切割并且会下降到第一个最优值,那么它们就会停止,即使它是局部最优值。

在您的情况下,目标函数和约束具有双线性项x*y,这是非凸的。 (您可以通过找到 Hessian 矩阵来检查凸性,该矩阵必须是半正定的(或在凹的情况下为负))。因此,求解器无法在数学上保证全局最优。

【讨论】:

  • 全局求解器旨在解决非凸问题。它们存在,因此“如果问题是非凸的,求解器无法保证您获得全局最优值。”是不正确的。全局求解器包括 Baron、Couenne、Antigone 和 Gurobi(仅限二次)。
猜你喜欢
  • 2022-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-10
  • 2020-11-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多