1

I am trying to formulate a linear program for a time scheduling problem.

My variable is simple, $x_{ij}$, which is equal to 1 when job $i$ is done at hour $j$.

Now as a part of this schedule (10 job = 10 rows and 24 hours = 24 columns), I need to define a constraint for job 5, or row 5. I've been using constraints like summation of row 3 should be equal to 5, meaning job 3 requires 5 hours to be devoted to it through the day.

Now, lets say I have job 7, that MUST be done sequentially (it can be done from 3-6 pm, 6-9 pm, anything, it must be sequential is all). But how do I show a constraint in a linear program like that?

Kuifje
  • 9,802
  • Is how many hours in total should be devoted to task 7 predefined? – Vim Dec 19 '18 at 04:53
  • Have you considered reformulating your problem in other terms ? Find your feasible columns first, and then use binary variables $y_i$ that take value $1$ if schedule/column $i$ is used.

    For your job $7$, you would define all the columns with three consecutive $1$s for instance.

    – Kuifje Dec 19 '18 at 09:07
  • @Kuifje so based on my formulation, each row or job, has a weight associated with it, so it has to maximise the sum of each Ci with the x variable for 24 columns, across 10 rows.

    the total sum of each column is always 1, so there can never be multiple assignments at the same time. my main issue is how to show a constraint that I can explain in english "3 hour task must be finished in a single chunk", as a mathematical equation/inequality. It must be formulated like this because some other jobs have flexibility in this regard, they can be done in parts.

    – Arjun Mohan Dec 19 '18 at 11:21
  • @Vim yes, the time required to do a task is always fixed. Some jobs can be done in parts, so their constraint is just, sum(row elements) = time required to perform.

    I can show that as sigma (j=1, upto 24) xij = tij [apologies I dont know how to format mathematical symbols in my comment]

    How can I show a constraint that says "row elements must add up to 3, but also as a single chunk of 3"

    I have the means to show the results of my calculation, but I am not able to show that as a constraint in the canonical form of a linear program, so to say.

    – Arjun Mohan Dec 19 '18 at 11:24
  • As the other comment suggested, maybe you can consider formulating task 7 in a special way that's different than other tasks. For example, instead of using $x_{7j}$, you may use another set of indicator variables $w_1, w_2,\cdots$ etc in which $w_1=1$ means task 7 is assigned to the first chunk and $w_2=1$ the second chunk and so on, with the constraint that $\sum_{k}w_k=1$. – Vim Dec 19 '18 at 11:58

1 Answers1

1

Although I do not think this is the best approach, if you really want to stick with your $x_{ij}$ variables, you could do something like this : Introduce binary variables $s_{ij}$ that take value $1$ if job $i$ starts at hour $j$, and add the following constraints :

  • Job $7$ can only have $1$ starting time : $$\sum_j s_{7j} =1$$
  • If job $7$ starts at hour $j$, then hour $j$ is "active" and accounted for in the objective function : $$ s_{7j} \le x_{7j} \quad\forall j $$
  • If job $7$ starts at hour $j$, then hours $j+1$ and $j+2$ must also be active : \begin{align*} s_{7j} + x_{7j} &\le 1 + x_{7j+1}\quad\forall j \\ s_{7j} + x_{7j} &\le 1 + x_{7j+2}\quad\forall j \\ \end{align*} Since variables $x_{ij}$ are minimised in the cost function (I suppose), they will take value $0$ when they can, so this last constraint should be sufficient to guarantee $3$ consecutive active time slots : $x_{7j+k}$ will take value $1$ if and only if $s_{7j}=x_{7j}=1$.
Kuifje
  • 9,802