简体   繁体   English

CVXPY 中的条件约束

[英]Constraints with condition in CVXPY

I want to add constraints like this:我想添加这样的约束:

constraint = cp.sum(cp.multiply(x, a)) > 10 if x*a != 0

where x is decision variable and a is constant.其中x是决策变量,a 是常数。 I know if condition and chain constraints are not allowed.我知道if不允许条件和链约束。 But how can I implement this condition?但是我怎样才能实现这个条件呢?

I also report a issue for csxpy in github .我还在 github 中报告了csxpy的问题。

That can be implemented linearly by considering y=a*x to be semi-continuous .这可以通过将y=a*x视为半连续来线性实现。

 y = a*x
 10*δ ≤ y ≤ 9999*δ
 δ ∈ {0,1} 
 

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

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