excel - Solver Constraint to assign a penalty for binary changing from 0 to 1 -


i creating production scheduling solver in machine "x" can run in between 300 , 450 units, or machine can turned off.

my current constraint says.

300*d<=x<=450*d  

"d" binary constraint, , "x" decision variable. constraint works fine need to. solver deciding how run machine each day.

however, need apply fixed cost penalty when d changes 0 1. saying costs $26,000 shut down machine. cannot figure out how without getting error saying solver not linear.

so if d=1 on day 1 , d=0 on day 2, need apply fixed cost penalty of $26000 in order tell machines run long possible without shutting down.

any appreciated.

you can introduce new variable defined on pairs of consecutive days, apply following logic:

if d_t + d_t-1 = 1 z_t = 1, otherwise z_t = 0 

where t day index, d_t binary variable shows if machine open or not in day t, , z_t newly introduced variable, shows if there switch between days t-1 , t.

to enforce logic, need following constraints:

z_t <= d_t + d_t-1 z_t >= d_t - d_t-1 z_t >= d_t-1 - d_t 

why works

here set of possible values of d_t, d_t-1 , z_t, result constraint above:

 d_t   |   d_t-1   |   z_t --------------------------   0    |     0     |    0   0    |     1     |    1   1    |     0     |    1   1    |     1     |    {0, 1} 

note in last case, when d_t , d_t-1 both 1, constraints not enforce z_t particular value. however, since have $26,000*z_t in objective function, optimal solution pick z_t = 0 when has flexibility so, because cheaper z_t=1.

i hope helps!


Comments