Linear Programming: Purely linear formulation (LP) for the expression "if x<0, set x = 0"

36 Views Asked by At

Basically, I need something that becomes 1 or zero depending on some conditions. Variables are if its a normal shift or extended These conditions are: If it goes from a normal shift to normal shift, = 0 If it goes from a normal shift to extended shift, = 1 If it goes from an extended to normal, = 0 If it goes from extended to extended, = 0

1

There are 1 best solutions below

3
On

Guessing a bit here, but it sounds like you have time dependent binary variables $x_t$ and $y_t$, where $x_t$ indicates whether shift $t$ is normal, and you want to enforce the following logical proposition: $$((x_{t-1} \land x_t) \implies \neg y_t)\land ((x_{t-1} \land \neg x_t) \implies y_t) \land ((\neg x_{t-1} \land x_t) \implies \neg y_t) \land ((\neg x_{t-1} \land \neg x_t) \implies \neg y_t)$$ You can obtain linear constraints by rewriting in conjunctive normal form as follows: $$ (\neg(x_{t-1} \land x_t) \lor \neg y_t)\land (\neg(x_{t-1} \land \neg x_t) \lor y_t) \land (\neg(\neg x_{t-1} \land x_t) \lor \neg y_t) \land (\neg(\neg x_{t-1} \land \neg x_t) \lor \neg y_t)\\ \equiv ((\neg x_{t-1} \lor \neg x_t) \lor \neg y_t)\land ((\neg x_{t-1} \lor x_t) \lor y_t) \land ((x_{t-1} \lor \neg x_t) \lor \neg y_t) \land ((x_{t-1} \lor x_t) \lor \neg y_t)\\ \equiv (1- x_{t-1} +1- x_t+1- y_t)\land (1- x_{t-1} + x_t+ y_t\ge 1) \land (x_{t-1} + 1- x_t+1- y_t\ge 1) \land (x_{t-1} + x_t+ 1 - y_t \ge 1)\\ \equiv (1- x_{t-1} +1- x_t+1- y_t\ge 1)\land (1- x_{t-1} + x_t+ y_t\ge 1) \land (x_{t-1} + 1- x_t+1- y_t\ge 1) \land (x_{t-1} + x_t+ 1 - y_t \ge 1)\\ \equiv (x_{t-1} + x_t+ y_t\le 2)\land (x_{t-1}-x_t\le y_t) \land (x_t - x_{t-1} \le 1- y_t) \land (x_{t-1} + x_t \ge y_t)\\ $$