Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.4K Views
|
1 Reply
|
1 Total Like
View groups...
Share
Share this post:

Problem with case distinction in a programming problem

Posted 2 years ago

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 $\ge 2$ then the 1st case should occur, if not then the second. How do I model this? Or is my formulation correct?

POSTED BY: C Baier
Posted 2 years ago

Not entirely sure if this is what you want (some sample inputs and expected outputs would help), but you can provide clarification/correction as needed.

Let's say we have a series of shift changes (presumably at some cadence of time intervals):

ShiftChanges = {0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0};

Your performance function just depends on the sum of 1s in this list. The exact sequence doesn't matter. So, at any moment in time, if we had the sum of shift changes up to that point, we could easily calculate the performance:

Performance[changeCount_] := 1 /; changeCount < 2;
Performance[changeCount_] := 1 - .1 (changeCount - 1)

If we had a cumulative sum of shift changes over time, we could just map our Performance function of that list. The Accumulate function will give us such a cumulative sum:

Accumulate[ShiftChanges]
(* {0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4} *)

Let's apply our performance function:

Performance /@ Accumulate[ShiftChanges]
(* {1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 0.9, 0.9, 0.9, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7} *)
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard