简体   繁体   English

如何将二次约束转换为线性

[英]How to Convert Quadratic Contraint to Linear

I have this constraint in my model:我的 model 中有这个约束:

(X - Y) @ B >= 0

where B is a boolean vector variable, X and Y are variables vector that represent quantities其中 B 是 boolean 向量变量,X 和 Y 是表示数量的变量向量

I'm working with CVXPY, so I have to keep linear expressions我正在使用 CVXPY,所以我必须保持线性表达式

How could I translate this constraint in a way that is linear?我怎样才能以线性的方式翻译这个约束?

Could someone help me please?有人可以帮我吗?

I am assuming that X>=0 and Y>=0 .我假设X>=0Y>=0 In that case, we can somewhat easily linearize XB=X*B and YB=Y*B .在这种情况下,我们可以稍微轻松地线性化XB=X*BYB=Y*B

   XB <= X
   XB <= B*999
   XB >= X-999*(1-B)
   0 <= XB <= 999

Here 999 is an upper bound on X .这里 999 是X的上限。 Similar for YB . YB类似。 Now just add:现在只需添加:

   XB >= YB

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

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