# Assigning a binary variable 1 when another variable exceeds threshold

Hi

I am trying to assign 1 to a binary variable if another variable exceeds a certain threshold value to satisify a QoS constraint. The objective function is a weighing of maximizing the number of elements satisfying the QoS constraint. Here is a snippet of the relevant lines of the model

param beta=1e3;
var SINR{u in U}>=0;
var C{u in U} >=0 binary;

# Objectives

maximize ParetosSINRandServedUsers: sum{u in U} SINR[u] + beta * sum{u in U} C[u];

# QoS constraints

s.t. ConsQoS{u in U}:
C[u] = 1 ==> SINR[u] >= 36.3 else C[u]= 0;

I receive the following error message
CPLEX 22.1.1.0:
logical constraint _slogcon[2] is not an indicator constraint.
which when I used “print _slogconname[2];” indicate constraint ConsQoS[2] which I know is the case when SINR does not exceed the threshold according to the model input data. I do not receive an error in other cases where model input data allow QoS to be satisfied.

I used the constraint SINR[u]>=36.3C[u]; which results in C equals to zero when SINR is less than 36.3.
While it seems working like this, I am still not conviced since I want the SINR not to be caluclated in the case of C equals zero. I am thinkin of multiplying it by the numerator which contains another binary varialbe and then linearize the multiplication of two binary variables. This is done by adding adding a new binary variable z (to replace x
y) and then addition the three constraints z<=x; z<=y; z>=x+y-1;

P.S the way of expressing the logical constraint (had I used this approach) is not correct after else I should have typed SINR[u]<36.3 instead of C[u]=0;.

Are you trying to say that “if SINR[u] exceeds 36.3, then C[u] = 1”? This could be written

``````SINR[u] > 36.3 ==> C[u] = 1
``````

and that is equivalent to the following indicator constraint:

``````C[u] = 0 ==> SINR[u] <= 36.3
``````

If you also want to say that “if SINR[u] does not exceed 36.3, then C[u] = 0” then you could write

``````C[u] = 0 ==> SINR[u] <= 36.3 else SINR[u] >= 36.3001
``````

(You can’t write “SINR[u] > 36.3” because CPLEX recognizes only >= and <=, so instead I have written >= 36.3 + a small number.)

(If you still have trouble, please upload files that can be used to reproduce the error that you are seeing.)

I did not see your most recent message before I replied. You can use

``````SINR[u] >= 36.3 * C[u]
``````

which will force SINR[u] to be >= 36.3 when C[u] = 1. However when C[u] = 0 this constraint will become SINR[u] >= 0 and it will not have any effect (since SINR[u] is already defined as a nonnegative variable).

I am not able to understand some of your other statements:

• I want the SINR not to be calculated in the case of C equals zero. SINR[u] is a variable, so the solver will always assign it some value for each u.

• I am thinking of multiplying it by the numerator . . . It is not clear which numerator you mean. There should be some fraction of the form a/b, where a is the numerator.