简体   繁体   中英

Implement “OR” constraints in CVXPY

So I have a quick question which I was not able to find the answer to...

I want to implement an "OR" constraint on CVXPY:

Either x = 0 OR x_min < x < x_max

where x is a real positive value. How can we implement such a constraint in code? I was trying to formulate the constraint with a mixed-integer form, but I was unsuccessful... Any help would be much appreciated!

There are no strict inequalities in convex-optimization.

Assuming, we want to express:

Either x = 0 OR x_min <= x <= x_max
(x_min, x_max: scalar constants)

this is usually done by (mixed-integer programming:):

Add binary variable y
Add constraint: x <= x_max * y
Add constraint: x >= x_min * y

Strict inequalities would need a-priori defined epsilons .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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