简体   繁体   English

Pyomo:如何施加决策变量必须是特定 integer 的倍数的约束?

[英]Pyomo: How to impose the constraint that the decision variables must be a multiple of a specific integer?

I am making an AbstractModel in Pyomo and I want to impose as a constraint the following:我正在 Pyomo 中制作一个 AbstractModel ,我想强加以下约束:

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

  • The constraint is that Xij must be zero or a multiple of 50.约束条件是 Xij 必须为零或 50 的倍数。

I am trying to do so by using the remainder but when making the constraint with % or something similar I obtain that % does not support using int.我试图通过使用余数来做到这一点,但是当使用 % 或类似的东西进行约束时,我发现 % 不支持使用 int。

How would you propose this constraint?你会如何提出这个约束?

Example:例子:

Example of constraint that I have tried我尝试过的约束示例

"Xij must be zero or a multiple of 50" “Xij 必须为零或 50 的倍数”

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

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

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