Second constraint as the absolute value of a previous constraint

I am struggling a lot with the following constraint and can only think of quadratic expressions.

Let: Ax == 2b+1. b is a boolean vector, x is a vector of signs (either 1 or -1).

Now I want to express a new constraint: |Ay| == 2b+1 so if 2b+1==3 then I can have either 3 or -3 and 1 or -1 respectively for the case of 2b+1==1. (y again is a vector of signs).

The difficulty arises because the value also changes on the right hand side. i.e |A*y| == 3 wouldn’t pose any problem. Could I maybe use find to break it into 2 cases like the aforementioned?

This can be easily done with a sign variable but then the constraint will lose its linearity.

Any tip/solution to this?

You haven’t told us the how this constraint comes into play in your optimization problem, how else the variables appear, etc. So I don;t know whether you need to add additional binary varaibles to handle your constraints as conditional constraints.

Read and and see whether that helps.

As for handling conditional (logic) constraints, I recommend .

it is true I was not precise enough, I didn’t realize it earlier. The links seems helpful.

If my current approach is correct, once I have it working, I will post it with more details for future reference