【问题标题】:Pyomo: How to impose the constraint that the decision variables must be a multiple of a specific integer?Pyomo:如何施加决策变量必须是特定整数的倍数的约束?
【发布时间】:2020-12-09 16:28:39
【问题描述】:

我正在 Pyomo 中制作一个 AbstractModel,我想将以下内容作为约束:

  • 我的决策变量是Xij,定义为:model.x = Var(model.I, model.J, domain=NonNegativeIntegers)

  • 约束条件是 Xij 必须为零或 50 的倍数。

我试图通过使用余数来做到这一点,但是当使用 % 或类似的东西进行约束时,我发现 % 不支持使用 int。

你会如何提出这个约束?

例子:

Example of constraint that I have tried

【问题讨论】:

  • 请将您的代码直接插入问题中,而不是链接到外部图像,因为首先,尝试您的示例的人无法复制它,其次,外部链接可能有一天会消失,使这个问题变得无用为他人。

标签: python optimization integer pyomo


【解决方案1】:

"Xij 必须为零或 50 的倍数"

 variables
    y(i,j) ∈ {0,1,2,3...}
    x(i,j) ≥ 0
 constraint
    x(i,j) = 50*y(i,j)    

【讨论】:

    猜你喜欢
    • 2022-08-15
    • 2014-02-25
    • 2022-11-27
    • 2020-08-04
    • 2017-12-31
    • 1970-01-01
    • 2018-07-09
    • 2020-10-26
    • 2021-09-12
    相关资源
    最近更新 更多