Skip to main content

Weighted Completion Time with WSPT

WSPT algorithm

For single-machine jobs with objective wjCj\sum w_j C_j, the classic dispatching rule is to process jobs in descending order of:

wjpj\frac{w_j}{p_j}

where:

  • wjw_j is job weight (priority),
  • pjp_j is processing time.

When all weights are equal, WSPT reduces to SPT.

API used in tilearn

Input format

Each row follows:

[name, p, r, d, w]

Example:

jobs = [
["J1", 2.0, 0, 8, 4.0],
["J2", 1.0, 0, 5, 1.0],
["J3", 3.0, 0, 6, 6.0],
]

Minimal runnable example

import tilearn as tl

jobs = [
["J1", 2.0, 0, 8, 4.0],
["J2", 1.0, 0, 5, 1.0],
["J3", 3.0, 0, 6, 6.0],
]

ranked = tl.wspt(jobs)
for row in ranked:
print(row)

Output shape:

[name, p, r, d, w, factor]

The appended factor column is w/p, and rows are sorted in descending factor order.

Practical notes

  • wspt mutates the input table in-place.
  • Calling it repeatedly on the same data may append additional factor columns.
  • Use a copy when you need to preserve original rows:
safe_jobs = [row[:] for row in jobs]
ranked = tl.wspt(safe_jobs)