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.

Thanks in advance

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.

First, thank you so much for the reply and your service to the community of optimization with AMPL Professor.

I am not familiar with the format of logical constraints, but it is now clear. I have used your suggestion: C[u] = 0 ==> SINR[u] <= 36.3 else SINR[u] >= 36.3001

I could not regenerate the logical constraint error message for now as I made multiple modifications, but will post about it if I have a regenerateable error. However, the “greater than” causes it as you explained AMPL does not recognize it.

SINR will now be equal to 0 in the model when QoS constraint is not met as I want it because I removed a constraint that enforces setting of another binary variable to equal 1 for each user (my wording was not accurate, may be I should’ve said not included or I want it to be zero)

Sorry my question was not be clear because I have adapted it to reflect only my needs ( SINR variable is not calculated directly, it is a ratio of signal to noise-plus-interference which is a nonlinear term. There is a binary variable in the numberator multiplied by a parameter. This binary variable is also in the denominator and I did cross multiplication and then further linearization to the quadratic term where a binary variable is multiplied by the continuous variable, some of the model equations are attached as I could not attach a PDF file).

Again many thanks <3.
equations