本文介绍了在pyomo中设置参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 CPLEX pyomo 一起使用。我想设置参数 mip.limits.solutions = 1 。如何使用 .options( .set_options(或其他方式)执行此操作?

I am using CPLEX with pyomo. I would like to set the parameter mip.limits.solutions = 1. How to do this with either .options( or .set_options( or any other way?

我尝试了以下操作,但无济于事:

I have tried the following but nothing works:

   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?


推荐答案

Pyomo(基于LP文件)的CPLEX接口使用CPLEX的交互式 API传递选项。该选项的交互式版本是 mip limit solutions

Pyomo's (LP file-based) CPLEX interface passes options using CPLEX's "Interactive" API. In this case, the interactive version of that option is "mip limits solutions":

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

这篇关于在pyomo中设置参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-22 11:00