简体   繁体   English

在python中为cplex求解器pyomo设置optimitytarget参数

[英]Setting optimalitytarget parameter in python for cplex solver pyomo

i am trying to optimize a quadratic objective function in pyomo with cplex solver and i get this CPLEX Error 5002: objective is not convex.我正在尝试使用 cplex 求解器优化 pyomo 中的二次目标函数,但我得到了这个 CPLEX 错误 5002:目标不是凸的。 QP with an indefinite objective can be solved to local optimality with optimality target 2, or to global optimality with optimality target 3. From IBM manual i got to know that we should Set optimalitytarget parameter in pythonI have this globalqpex1.py and now how can i set the parameter can someone explain how to set up this parameter具有不确定目标的 QP 可以求解为具有最优目标 2 的局部最优,或具有最优目标 3 的全局最优。从 IBM 手册我知道我们应该在 python 中设置最优目标参数我有这个 globalqpex1.py 现在我怎么能设置参数有人可以解释如何设置这个参数

it is given that i can run python globalqpex1.py g global optimum but i dont have any .sav or .lp files and i dont know what they are...furthur more I found in the manual that I can solve this problem by seting parameters.optimalitytarget in python how and where should i add c.parameters.optimalitytarget.set(1)假设我可以运行 python globalqpex1.py g 全局优化,但我没有任何 .sav 或 .lp 文件,我不知道它们是什么......更多我在手册中发现我可以通过设置来解决这个问题python中的parameters.optimalitytarget我应该如何以及在哪里添加c.parameters.optimalitytarget.set(1)

this is the error i get CPLEX Error 5002: objective is not convex.这是我得到的错误 CPLEX 错误 5002:目标不是凸的。 QP with an indefinite objective can be solved to local optimality with optimality target 2, or to global optimality with optimality target 3. Presolve time = 0.00 sec.具有不确定目标的 QP 可以求解为具有最优性目标 2 的局部最优性,或具有最优性目标 3 的全局最优性。预求解时间 = 0.00 秒。 (0.00 ticks) Barrier time = 0.00 sec. (0.00 滴答声)屏障时间 = 0.00 秒。 (0.00 ticks) (0.00 滴答声)

Error termination, CPLEX Error 5002. Solution time = 0.00 sec.错误终止,CPLEX 错误 5002。求解时间 = 0.00 秒。 Deterministic time = 0.00 ticks (0.49 ticks/sec)确定性时间 = 0.00 滴答声(0.49 滴答声/秒)

CPLEX> CPLEX Error 1217: No solution exists. CPLEX> CPLEX 错误 1217:不存在解决方案。 No file written.没有写入文件。 CPLEX> [ 0.05] Pyomo Finished ERROR: Unexpected exception while loading model: Cannot load a SolverResults object with bad status: error CPLEX> [0.05] Pyomo 完成错误:加载模型时出现意外异常:无法加载状态错误的 SolverResults 对象:错误

There are two different CPLEX interfaces in pyomo. pyomo 中有两种不同的 CPLEX 接口。 There is one that shells out to the CPLEX interactive ( cplex ) and there is one that makes use of the CPLEX Python API ( cplex_direct ).有一种用于 CPLEX 交互式 ( cplex ),另一种使用 CPLEX Python API ( cplex_direct )。 Setting parameters looks to be slightly different between the two interfaces in some cases (eg, when the parameter is more than one level deep in the hierarchy).在某些情况下(例如,当参数在层次结构中的深度不止一层时),两个界面之间的参数设置看起来略有不同。 In general, you set a parameter using the technique described here .通常,您可以使用此处描述的技术设置参数。

In either case, for the optimality target parameter , you should be able to use the following:在任一情况下,对于最优性目标参数,您应该能够使用以下内容:

solver = SolverFactory('cplex')
solver.options['optimalitytarget'] = 3

Here's an example where we set the absolute MIP gap tolerance parameter and the syntax is slightly different between the two CPLEX interfaces:这是我们设置绝对 MIP 间隙容差参数的示例,并且两个 CPLEX 接口之间的语法略有不同:

# Using the CPLEX interactive interface
solver = SolverFactory('cplex')
solver.options['mip tolerances absmipgap'] = 3

# Using the CPLEX Python API interface (i.e., use underscores)
solver = SolverFactory('cplex_direct')
solver.options['mip_tolerances_absmipgap'] = 3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM