在pyom中设置参数

2024-05-14 16:22:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在将CPLEXpyomo一起使用。我想设置参数mip.limits.solutions = 1。如何使用.options(.set_options(或任何其他方式来实现这一点?在

我试过以下方法,但都不管用:

   from pyomo.environ import *

   opt = SolverFactory("cplex")

   opt.set_options('miplimitssolutions=1')  # does not work
   opt.set_options('mip.limits.solutions=1')  # does not work

   opt.options['mip'] = 'limits'  # this works up to here but how to continue?

Tags: to方法参数方式notpyomoworkoptions
1条回答
网友
1楼 · 发布于 2024-05-14 16:22:20

Pyomo的(基于LP文件的)CPLEX接口使用CPLEX的“交互式”API传递选项。在本例中,该选项的交互版本是“mip limits solutions”:

from pyomo.environ import *
opt = SolverFactory("cplex")
opt.options['mip limits solutions'] = 1

相关问题 更多 >

    热门问题