Problem with case distinction in a programming problem

120 Views Asked by At

Good evening, I have the following problem. I want to create a duty roster and model performance losses. For this I have introduced the binary variable $l_{it}$, which takes the value 1 when the shift of a worker changes, e.g. from late to early shift. Now I have introduced the performance variable $p_{it}$, which starts from 1 and should deteriorate with changes of view. The performance should deteriorate by 0.1 from the second shift change, i.e. from the second time $l_{it}=1$. For each further time $l_{it}=1$ again by 0.1. How do I model the whole thing, so that it comes only from the second time to a loss. That would be my suggestion so far:

$$p_{it}=\begin{cases} p_{it_{-1}}-0.1\times l_{it}, & \text{if}~\sum_{t=2}^{t}l_{it}\ge 2~~~~\forall i\in I,\\ p_{it_{-1}}, & \text{else.} \end{cases} $$

In each period, for each worker, the sum of all $l_{it}$, starting from $t=2$ up to the current period, should be calculated. If this sum is $\ge2$, then the 1st case should occur, if not then the second. How do I model this? Or is my formulation correct?

2

There are 2 best solutions below

7
On

If I understand what you want, and if higher performance values are always more desirable, you can add the following constraints for all $i$ and $t:$ $$p_{i,t} \le 1$$ and $$p_{i,t} \le 1.1 - 0.1\cdot \sum_{\tau=2}^t \ell_{i,t}.$$

If, for some reason, lower performance values would improve the objective function (giving the solver an incentive to underestimate $p$), things get more complicated.

Addendum: This only works if we can be sure that at most 11 shift changes can occur over the planning horizon. Assuming $p_{i,t}$ is defined to be nonnegative, the second constraint will indirectly force $\sum_{\tau=2}^t \ell_{i,t} \le 11$ for all $t.$

0
On

This is an answer to a modified version of the original problem (based on comments by the author). In the version I will address, a physician's efficient ($p$) starts at 1 and degrades by 0.1 for each shift change (captured by $\ell$) after the first, with two qualifications. The efficiency cannot go below 0, and three consecutive shifts without a change "resets" the efficiency to 1 and cancels the effect of any earlier shift changes (so that it takes two shift changes after the reset to degrade efficiency again). I assume that, from the objective perspective, higher efficiency is better.

I'm going to skip the physician subscript $i$ in what follows, and I'm going to introduce the following variables:

  • $\pi_t\in \lbrace 0,\dots,11\rbrace$ is the number of shift changes used to compute the efficiency penalty at time $t;$
  • $\rho_t$ is a binary variable taking value 1 if a reset occurs at time $t;$
  • $\mu_t$ is a binary variable taking value 1 if $\pi_t = 11,$ i.e., if the physician's efficiency at time $t$ has degraded to 0; and
  • $\sigma_t$ is a binary variable representing the product $\mu_{t-1} \times \ell_t$ (indicating that a shift change just occurred to a physician already at efficiency 0).

We add the following constraints:

  • $p_t \le 1$ (a physician's maximum efficiency is 1);
  • $p_t \le 1.1 - 0.1 \pi_t$ (the physician loses 0.1 efficiency per shift change that counts, with the first one harmless);
  • $\rho_t \le \ell_{t-k}$ for $\forall k \in \lbrace 0, 1, 2 \rbrace$ (a reset can occur only after three periods without a shift change);
  • $11 \mu_t \le \pi_t \le 10 + \mu_t,$ which enforces $\mu_t = 1 \iff \pi_t = 11$;
  • $\sigma_t \le \ell_t;\ \sigma_t \le \mu_{t-1};\ \sigma_t \ge \ell_t + \mu_{t-1} -1$ (which collectively enforce $\sigma_t = \mu_{t-1} \times \ell_t$);
  • $\pi_t \le 11(1 - \rho_t)$ (the shift change count is at most 11 and drops to 0 when a reset occurs);
  • $\pi_t \ge \pi_{t-1} + \ell_t - \sigma_t - 11 \rho_t$ (explained below).

The way to parse the last constraint is as follows. Assume, for the moment, no reset ($\rho_t = 0$). If $\pi_{t-1} < 11$ (implying $\mu_{t-1}=0$ and thus $\sigma_t = 0$), then the cumulative shift count $\pi_t$ will be $\pi_{t-1}$ plus 1 if the shift changed again ($\ell_t = 1$). If $\pi_{t-1} = 11$ ($\mu_{t-1}=1$), then $\sigma_t = \ell_t$ and $\pi_t = \pi_{t-1} = 11$ (the physician stays at full burnout). Note that under no circumstance is $\pi_{t-1} + \ell_t - \sigma_t > 11.$ Finally, if a reset occurs ($\rho_t = 1$), the right side of the last constraint is $\le 0,$ allowing $\pi_t$ to be 0 (which will be optimal) and thus $p_t = 1$ (the reset).