Is this model possible in CVX (putting soft constraint as an energy term?)?

I face something related to this .Still it is not the same and a bit complex so I will try to explain it the best way possible.

Pl2pathAdjX*paths >= (1-lowX)*4;
Pl2pathAdjY*paths >= (1-lowY)*4;
Pl2pathAdjZ*paths >= (1-lowZ)*4;
Pl2pathAdjX*paths <= (1-lowX).*allCrX;
Pl2pathAdjY*paths <= (1-lowY).*allCrY;
Pl2pathAdjZ*paths <= (1-lowZ).*allCrZ;

This part of my program ( made of linear constraints and a linear objective) is what my question is about.

In the left hand sides Pl2pathAdj[X,y,z] is an constrant matrix and paths is a binary variable (vector). In the right hand sides low[X,y,z] is a binary variable (vector) and allCr[X,Y,Z] is a constant vector (with mainly 3-digit numbers).

Now the thing is that, it is great if this set of constraints is satisfied, but sometimes it damages feasibility. This indicates that it could probably be added as a term to the energy, even though the scaling between the two objectives is a question (but that has to worry me the modeler and not you).

What I want to achieve by this set of constraints, is that the left hand side, has to be greater than 4 and smaller than some big number or equal to zero (from previous constraints it is also guaranteed to be a multiple of 2). But it must not be equal to 2. This discontinuity prevents me from simply putting it as a term in the energy. Neither does it sound linear nor can I think of 2 terms to express it appropriately.

Is the problem clear? Does anybody have a suggestion?

I’m not sure exactly what you want the constraints to be, but you might be able to handle the discontinuity using binary variables. See, for instance,

If you are trying to handle “can not be exactly equal to 2”, and the 2 is a continuous varialbe as opposed to integer, that might be a bit tricky, and you will need some small tolerance around 2 as to what constitutes being equal to 2.

No it is an integer one. I want it to be exactly as I described it ( between 0 and some number, a multiple of 2 and not 2). However, sometimes due to noisy data (that is was not expecting to get as input) not all 3 can be accomplished at the same time.

The least damage is done, if the multiple of two is dropped. But till now I have never differentiated between important and non important lets say constraints, nor have I written something that complex as a linear energy (high energy when not a multiple of 2? Sounds quite bizarre).

If you have something else to add now that I gave a further explanation, you are more than welcome. Otherwise I will pass to the study of the link you sent.

Thanks a lot

For instance, look at section 2.9 Disjunctions of the above link to get an idea of how to model similar situations, then modify accordingly for your situation.You can adapt my answer at Can I restrict variable to only a few values? for your situation.

1 Like

That was exactly what I needed. Thanks a lot