prioritizing a constraint

24 views
Skip to first unread message

Jack1

unread,
Apr 8, 2020, 2:11:47 PM4/8/20
to YALMIP
I have two constraints on `x`
L<=x<=U
A<=x<=B
and I would like the optimizer to satisfy the first over the other; however, I would still like to keep the second one since I can adjust the bounds. 
I am currently getting an infeasible soln with both of them. But, if i added a slack term to the first then the soln is feasible, but, that constraint becomes easily violated which I don't want. So, I added a slack to the second constraint, but, then run into infeasibilities.
Can you pls advise of alternatives? Maybe I can appropriately bound the slack term that's in the second constraint? Thank you.


Johan Löfberg

unread,
Apr 8, 2020, 2:31:05 PM4/8/20
to YALMIP
the only way to do that if slacks don't work as you want is to model some logic using binary variables (or simply solving a sequence of problems)

Jack1

unread,
Apr 9, 2020, 9:25:51 AM4/9/20
to YALMIP
Thank you. And one more Q: since there are two constraints in the above on `x` --> does this imply that the optimizer would always respect both? Or, can it choose to go with either the lower or upper bound on a run? 

For instance, if U is tighter than B (i.e., U <= B), then, could it not be the case that the optimizer can choose to go with the relaxed one B or would it have to satisfy U as well? I don't think so because there is no rule in the optimizer saying to prioritize the first constraint over the second? But, am not sure. 

Johan Löfberg

unread,
Apr 9, 2020, 9:37:30 AM4/9/20
to YALMIP
if you have x<=1 and x<=2, the second constraint is redundant and will be eliminated before the solver even starts

A solver satisfies all constraints in a model, if you want otherwise you will have to model a more complex model involving OR constraints modelled using binary variables etc

Johan Löfberg

unread,
Apr 9, 2020, 9:38:30 AM4/9/20
to YALMIP
i.e., the model you write in your first post is simply max(L,A) <= x <= min(U,B)
Reply all
Reply to author
Forward
0 new messages