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 (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:

  • ax (Axes | None, default: None ) –

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

Returns:

  • 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:

  • 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 | None, default: None ) –

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

  • big_m_upper_bound (int | None, default: None ) –

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

Returns:

  • 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:

  • n_jobs (int, default: 2 ) –

    Number of jobs, by default 2.

  • n_machines (int, default: 2 ) –

    Number of machines, by default 2.

  • max_duration (int, default: 5 ) –

    Maximum duration of an operation, by default 5.

  • seed (int | None, default: None ) –

    Random seed for reproducibility, by default None.

Returns:

  • 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:

Returns:

  • Model

    A Luna Model ready to be solved.

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

Extract solution from solver result.

Parameters:

  • solution (Solution) –

    The solver solution.

  • data (JsspData) –

    The problem data.

Returns:

  • 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 (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:

  • data (JsspData | None, default: None ) –

    Problem data (unused but kept for API consistency).

  • ax (Axes | None, default: None ) –

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

Returns:

  • 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:

  • min_jobs (int) –

    Minimum number of jobs.

  • max_jobs (int) –

    Maximum number of jobs.

  • n_machines (int, default: 2 ) –

    Number of machines, by default 2.

  • max_duration (int, default: 5 ) –

    Maximum operation duration, by default 5.

  • num_instances (int, default: 1 ) –

    Number of instances per job count, by default 1.

  • seed (int | None, default: None ) –

    Random seed for reproducibility, by default None.

Returns: