How to return a binary value by comparing two variables?

122 views Asked by At

I currently study operation research. I required to formulate the model as LP model.

The objective function is

y = ( ai * C1i + bi * C2i)
        ,where ai = max(0, xi - Ti) ; bi = max(0, Ti - xi)

This is a scheduling problem. xi is the decision variables of scheduled time for job i, and Ti is the best fit time for job i. Each unit of time of earlier or late will subject to a penalty cost. C1i and C2i are the penalty cost per unit.

if job i is start before the best time Ti for job i, the penalty cost will be

 bi * C2i.

if job i is start after the best time Ti for job i, the penalty will be

ai * C1i.

During my formulation, i found that it is difficult to use max(,) function in Lingo or Cplex. Acutally, there is no max(,) function in the program. If the task start before Ti, ai = xi - Ti will be negative. bi = Ti - xi will be positive. I cannot think about a way to convert "if negative, then the value change into 0".

Is it possible to formula the objective with the below function?

 y = ( ai * C1i*yi + bi * C2i*(1-yi))

if Ti - xi >= 0 ( Start before the best time for job i), then yi = 1 Otherwise, yi =0.

But, how can I formulate the above if-then-statement in LP model?

thanks!

1

There are 1 answers

0
Erwin Kalvelagen On

The question is a little bit difficult to parse, but I think what you are after is something like:

enter image description here

Actually this was suggested in the duplicate question here. (Sorry: that question has been deleted).