Skip to content

Job Shop Scheduling API Reference

Data

Data model for Job Shop Scheduling use case.

JsspData

Bases: UcData

Data for the Job Shop Scheduling (JSS) use case.

The Job Shop Scheduling problem assigns operations of jobs to time slots on machines so that the overall makespan is minimised. Each job consists of an ordered sequence of operations, where every operation must be processed on a specific machine for a given duration.

Attributes:

Name Type Description
name Literal['job_shop_scheduling']

Identifier for this data type.

jobs list[list[tuple[int, int]]]

jobs[j] is a list of (machine, duration) pairs describing the ordered operations of job j.

n_machines int

Number of machines available.

deadline int

Time horizon T. All operations must complete by this time.

big_m_upper_bound int | None

Optional user-supplied upper bound for the Big-M constant used in disjunctive constraints. When None (default), the formulation computes a tight bound automatically from machine loads and job chain lengths.

plot(*, ax: Axes | None = None) -> Axes

Plot a Gantt-style overview of the job structure.

Parameters:

Name Type Description Default
ax Axes | None

Matplotlib axes to draw on. Creates a new figure if None.

None

Returns:

Type Description
Axes

The axes with the plot.

to_string() -> str

Return a string describing the data.

from_jobs(jobs: list[list[tuple[int, int]]], n_machines: int, deadline: int | None = None, big_m_upper_bound: int | None = None) -> JsspData staticmethod

Create a Job Shop Scheduling instance from explicit job definitions.

Parameters:

Name Type Description Default
jobs list[list[tuple[int, int]]]

jobs[j] is a list of (machine, duration) pairs describing the ordered operations of job j.

required
n_machines int

Number of machines available.

required
deadline int | None

Time horizon T. If None, defaults to the sum of all operation durations (conservative upper bound).

None
big_m_upper_bound int | None

User-supplied upper bound for the Big-M constant. If None (default), the formulation computes a tight bound automatically.

None

Returns:

Type Description
JsspData

A new instance built from the given jobs.

generate_random(n_jobs: int = 2, n_machines: int = 2, max_duration: int = 5, seed: int | None = None) -> JsspData staticmethod

Generate a random Job Shop Scheduling instance.

Each job visits every machine exactly once in a random order with a random duration between 1 and max_duration.

Parameters:

Name Type Description Default
n_jobs int

Number of jobs, by default 2.

2
n_machines int

Number of machines, by default 2.

2
max_duration int

Maximum duration of an operation, by default 5.

5
seed int | None

Random seed for reproducibility, by default None.

None

Returns:

Type Description
JsspData

A randomly generated instance.

Formulation

Formulation for Job Shop Scheduling use case.

JsspFormulation

Bases: UcFormulation[JsspData, JsspSolution]

Constraint-based formulation for Job Shop Scheduling.

Uses a disjunctive formulation with per-pair Big-M values derived from operation time windows, integer start-time variables, and binary ordering variables.

Mathematical Formulation

Preprocessing: ES[o] = earliest start of operation o (from job precedence) LS[o] = latest start of operation o (from horizon - tail chain) horizon = user-supplied big_m_upper_bound, or max(longest job chain, heaviest machine load)

Decision Variables: s[o] integer -- start time of operation o y[o1,o2] binary -- ordering of operations on the same machine C_max integer -- makespan

Objective: minimize C_max

Constraints: 1. s[o] + dur[o] <= C_max for all o 2. Precedence: s[o_next] >= s[o_prev] + dur[o_prev] 3. Variable bounds: ES[o] <= s[o] <= LS[o] 4. Disjunctive (per-pair Big-M): no overlap on same machine M_a(o1,o2) = LS[o1] + dur[o1] - ES[o2] M_b(o1,o2) = LS[o2] + dur[o2] - ES[o1]

to_string(data: JsspData) -> str staticmethod

Return a string describing the formulation.

formulate(data: JsspData) -> Model staticmethod

Formulate using a Big-M disjunctive approach.

Parameters:

Name Type Description Default
data JsspData

The problem data.

required

Returns:

Type Description
Model

A Luna Model ready to be solved.

interpret(solution: Solution, data: JsspData) -> JsspSolution staticmethod

Extract solution from solver result.

Parameters:

Name Type Description Default
solution Solution

The solver solution.

required
data JsspData

The problem data.

required

Returns:

Type Description
JsspSolution

Structured solution with schedule and metrics.

Solution

Solution model for Job Shop Scheduling use case.

JsspSolution

Bases: UcSolution

Solution for the Job Shop Scheduling (JSS) use case.

Attributes:

Name Type Description
name Literal['job_shop_scheduling']

Identifier for this solution type.

schedule dict[str, list[tuple[int, int, int]]]

Mapping from machine name (e.g. "machine_0") to a list of (job, start_time, duration) tuples.

makespan int

The completion time of the last operation (objective value).

is_valid bool

Whether the solution satisfies all constraints.

plot(data: JsspData | None = None, *, ax: Axes | None = None) -> Axes

Plot a Gantt chart of the schedule.

Parameters:

Name Type Description Default
data JsspData | None

Problem data (unused but kept for API consistency).

None
ax Axes | None

Matplotlib axes to draw on. Creates a new figure if None.

None

Returns:

Type Description
Axes

The axes with the plot.

to_string() -> str

Return a string describing the solution.

Instance

Instance model for JobShopScheduling use case.

JsspInstance

Bases: UcInstance[JsspData, JsspFormulation, JsspSolution]

Instance combining data and formulation for JobShopScheduling.

Collection

Collection of Job Shop Scheduling instances.

JsspCollection

Bases: UcInstanceCollection[JsspInstance]

Collection of Job Shop Scheduling instances.

from_random(min_jobs: int, max_jobs: int, n_machines: int = 2, max_duration: int = 5, num_instances: int = 1, *, seed: int | None = None) -> JsspCollection classmethod

Generate random Job Shop Scheduling instances.

Parameters:

Name Type Description Default
min_jobs int

Minimum number of jobs.

required
max_jobs int

Maximum number of jobs.

required
n_machines int

Number of machines, by default 2.

2
max_duration int

Maximum operation duration, by default 5.

5
num_instances int

Number of instances per job count, by default 1.

1
seed int | None

Random seed for reproducibility, by default None.

None

Returns:

Type Description
JsspCollection

Collection containing generated instances.