1

I don't have much experience with defining the limits of my binary variables. In basic terms, I want my binary variable to switch from 1 to 0, when my other value (called base) hits its upper limit at 379900. What I wish is this:

    base >= 379900  means that Y=0
    base <  379900  means that Y=1

To give some further context, here's a full picture of where I am currently at.

    base  = salary - 89700;
    base <= M * Y;

    supp <= 89700 * Y;
    supp <= 89700 - suppBase*0.309 + (1-Y)*M;
    supp >= 0;

Salary is an input (that I am currently choosing myself), and can technically take any positive value. I have 3 test cases

    salary < 89700 meaning supp = 89700,
    salary = 220000 meaning supp = 49437,
    salary > 399700 meaning supp SHOULD be = 0, but I get infeasible problem.

Here, supp is the value I am calculating. It works for all values less than 379900, since this is the value that makes the second supp condition go into negative territory, making the model infeasible. If Y becomes 0 at 379900, then the 1st and 3rd supp conditions will determine that supp = 0, while the 2nd supp condition becomes irrelevantly large.

I am assuming that my error is in the second base condition, but my lack of experience with how to define binary variables makes me unable to find the solution.

I have tried a couple of different things. Mostly changing how I define my base. Changing M to be exactly 399700 seemed like a solution for a second, but when I tried it, it changed nothing (obviously in hindsight). I also tried to change my base calculation to salary - 399700, but that just made the supp calculation wrong, since base no longer was the actual number it needed to be. I also just raised the limit for when the problem became infeasible.

godfin
  • 11
  • 2
  • I’m voting to close this question because it belongs on [OR.se](https://or.stackexchange.com/). – joni Nov 11 '22 at 21:10

1 Answers1

0

I did not get the full context, but if you want to write the below conditions:

base >= 379900  means that Y=0
base <  379900  means that Y=1

you can do that as below:

constraint 1 :

base - m*y1 >= 379900 

# y1 is a boolean variable
# base <  379900  means that y1 = 1 
# m is a lower bound for the expression : (base - 379900). 
# so if base value can be zero then lower bound = -379900
# assuming base is a decision variable

constraint 2 :

base - (M + epsilon)*y2 <= 379900 - epsilon

# y2 is a boolean variable
# base >= 379900  means that y2 = 1
# M is a upper bound for the expression : (base - 379900). 
# so if base value can be 400000 at max then upper bound = 20100
# epsilon is a some small tolerance. can safely be taken as 1, if base is 
# an integer variable

constraint 3 :

y1 + y2 == 1