简体   繁体   English

在Pyomo中定义虚拟目标

[英]Defining a dummy Objective in Pyomo

So I'm trying to structure an MCP for Pyomo (with Python 3) where there's only one solution which fits all the complementary conditions, making the objective function redundant. 因此,我正在尝试为Pyomo(使用Python 3)构建MCP,其中只有一种解决方案可以满足所有互补条件,从而使目标函数变得多余。 Do I need to define an objective at all, or is there any way to define a dummy objective? 我是否需要定义一个目标,或者有什么方法可以定义一个虚拟目标?

It depends on the solver that you are using. 这取决于您使用的求解器。 Some solvers will complain without the presence of an objective. 一些求解器会在没有目标的情况下抱怨。 My favorite ways to add a dummy include: 我最喜欢的添加虚拟对象的方法包括:

  • model.dummy = Objective(expr=1)
  • model.dummy_var = Var(bounds=(0, 1)) with model.dummy = Objective(expr=model.dummy_var) model.dummy_var = Var(bounds=(0, 1)) with model.dummy = Objective(expr=model.dummy_var)

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

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