Scheduling Tasks on One Machine

You have nn tasks, and must find an order in which to execute them with minimum cost. Task ii takes time tit_i, and making task ii wait for tt time units incurs cost fi(t)f_i(t).

Formally, given nn functions fif_i and nn numbers tit_i, find a permutation pp minimizing

F(p)=∑i=1nfpi(∑j=1i−1tpj)F(p)=\sum_{i=1}^nf_{p_i}\left(\sum_{j=1}^{i-1}t_{p_j}\right)

Special Cost Functions

Linear Cost Functions

First, consider the case where all functions are linear, namely fi(x)=cix+dif_i(x)=c_ix+d_i, where cic_i is a nonnegative integer. Clearly, we can add all constant terms in advance, so the functions reduce to the form fi(x)=cixf_i(x)=c_ix.

Consider two permutations pp and p′p', where p′p' is obtained by swapping the numbers at positions ii and i+1i+1 in pp. Then

F(p′)−F(p)=cpi′∑j=1i−1tpj′+cpi+1′∑j=1itpj′−(cpi∑j=1i−1tpj+cpi+1∑j=1itpj)=cpitpi+1−cpi+1tpi\begin{aligned} F(p')-F(p)&=c_{p'_i}\sum_{j=1}^{i-1}t_{p'_j}+c_{p'_{i+1}}\sum_{j=1}^{i}t_{p'_j} -\left(c_{p_i}\sum_{j=1}^{i-1}t_{p_j}+c_{p_{i+1}}\sum_{j=1}^{i}t_{p_j}\right)\\ &=c_{p_i}t_{p_{i+1}}-c_{p_{i+1}}t_{p_i} \end{aligned}

Therefore, we can sort by repeatedly swapping whenever cpitpi+1−cpi+1tpi>0c_{p_i}t_{p_{i+1}}-c_{p_{i+1}}t_{p_i}>0. Written as cpitpi>cpi+1tpi+1\dfrac{c_{p_i}}{t_{p_i}}>\dfrac{c_{p_{i+1}}}{t_{p_{i+1}}}, this means sorting the permutation in ascending order of citi\dfrac{c_i}{t_i}.

Our approach is to consider the effect of a local perturbation and greedily choose the optimal solution.

Exponential Cost Functions

Consider cost functions of the form fi(x)=cieaxf_i(x)=c_i\mathrm{e}^{ax}, where ci≥0,a>0c_i\ge 0,a>0.

Following the previous approach, consider the change in cost caused by swapping the numbers at positions ii and i+1i+1. The resulting algorithm is to sort the permutation in ascending order of 1−eatici\dfrac{1-\mathrm{e}^{at_i}}{c_i}.

The Same Increasing Function

Suppose all fi(x)f_i(x) are the same increasing function. Then it is clear that we should sort the permutation in ascending order of tit_i.

Livshits–Kladov Theorem

The Livshits–Kladov theorem holds if and only if the cost functions fall into one of the following three cases:

  • Linear functions: fi(t)=cit+dif_i(t) = c_it + d_i, where ci≥0c_i\ge 0;
  • Exponential functions: fi(t)=cieat+dif_i(t) = c_i \mathrm{e}^{a t} + d_i, where ci,a>0c_i,a>0;
  • The same increasing function: fi(t)=ϕ(t)f_i(t) = \phi(t), where ϕ(t)\phi(t) is an increasing function.

The theorem is proved under the assumption that the cost functions are sufficiently smooth (their third derivatives exist). In all three cases, the optimal solution can be found by simple sorting in O(nlog⁡n)O(n\log n) time.

This page is mainly translated from the blog post Задача Джонсона с одним станком and its English version Scheduling jobs on one machine. The Russian version is licensed under Public Domain + Leave a Link; the English version is licensed under CC-BY-SA 4.0.

This content comes from OI Wiki: Scheduling Tasks on One Machine. See the original for authors and revision history. AIOJ has adapted the formatting, in-site links, and resource paths.

Content is shared under CC BY-SA 4.0 and SATA license; additional terms are governed by the original notice. Thanks to the OI Wiki authors and contributors; per the SATA terms, please visit the OI Wiki repository and star it to show your support.