Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multi-resource-fjsp-cp-sat

CP-SAT model for a multi-mode flexible job shop scheduling problem with renewable technician resources, precedence constraints, release/due dates, and shift-calendar constraints.

Overview

This repository contains OR-Tools CP-SAT scheduling models for production environments that need to coordinate:

  • alternative machine assignments
  • technician qualification and staffing constraints
  • operation precedence
  • release and due dates
  • working-shift calendars
  • makespan and tardiness minimization

It also includes an interactive web dashboard for configuring the solver, running solves, analyzing results (Gantt charts, utilization, bottlenecks), and comparing solutions.

Setup

python -m venv .venv
source .venv/bin/activate
pip install ortools openpyxl pandas numpy

Required Data

Place input CSV/XLSX files in data/schedulingmodel/:

File Description
jobs.csv Job IDs, names, release and due dates
operations.csv Operation IDs, names, departments
machines.csv Machine IDs, names, capabilities
technicians.csv Technician IDs, names, departments
capabilities.csv Capability ID-to-name mapping
departments.csv Department ID-to-code mapping
method.csv Machine-operation processing times and required capabilities
precedence.csv Operation predecessor/successor pairs
technician_capability_matrix.xlsx Technician skill levels (0/1/2) per capability

Files

File Description
data_loader.py Reads input data into a SchedulingDataset dataclass
model_builder.py Shared helpers: shift calendar, holidays, skill-based speedup
direct_ortools.py Lean CP-SAT model builder
direct_ortools_bells_whistles.py Extended solver with warm-starting, greedy heuristic, solution snapshots
dashboard_server.py HTTP server for the interactive dashboard and solver API
outputs/scheduling_dashboard.html Interactive dashboard UI

Dashboard

Running

source .venv/bin/activate
python dashboard_server.py [--port 8050]

Open http://localhost:8050 in a browser.

Features

Analyze Solution -- Interactive Gantt chart with swimlane options (by job, machine, technician, or department), zoom and filtering. Machine and technician utilization tables. Resource load heatmap over time. Bottleneck analysis with resource investment impact ranking. Tardiness breakdown and department stats.

Configure & Run Solver -- Full parameter form for SolverConfig (time limit, num workers, search branching, LNS, gap limits) and BuilderConfig (shift hours, speedup %, planning extension). Run the solver directly from the browser or copy the equivalent Python command.

Compare Solutions -- Side-by-side diff of two solutions: objective, makespan, tardiness, solve time, and per-job completion deltas.

Solution Files

Solution JSON files are read from and written to outputs/. The dashboard lists all *.json files in that directory. Solutions are created by running the solver from the dashboard or from Python.

Running the Solver from Python

from data_loader import load_dataset
from direct_ortools_bells_whistles import (
    build_direct_ortools_model_for_jobs, SolverConfig
)
from model_builder import BuilderConfig

ds = load_dataset("data/schedulingmodel")
build = build_direct_ortools_model_for_jobs(ds)

status, snapshot = build.solve(
    solver_config=SolverConfig(max_time_in_seconds=300, log_search_progress=True),
    run_greedy_heuristic=True,
    dataset=ds,
    save_solution="outputs/my_solution.json",
)
print(f"Status: {snapshot.status}, Objective: {snapshot.objective_value}")

Solver Configuration

SolverConfig parameters:

  • max_time_in_seconds -- Wall-clock time limit (default: 300)
  • num_workers -- Parallel search workers (0 = auto)
  • search_branching -- 0=AUTO, 1=FIXED, 2=PORTFOLIO, 3=LP, 4=PSEUDO_COST, 5=PORTFOLIO_QUICK_RESTART
  • linearization_level -- 0=none, 1=fixed, 2=full
  • use_lns -- Enable Large Neighborhood Search
  • random_seed -- For reproducibility
  • relative_gap_limit / absolute_gap_limit -- Early termination

BuilderConfig parameters:

  • advanced_speedup_pct -- Duration reduction for skilled technicians (default: 20%)
  • shift_start_hour / shift_end_hour -- Working hours (default: 7-16)
  • planning_extension_days -- Buffer past last due date (default: 14)
  • unattended_startup_units -- Startup phase length (default: 1 = 15 min)

Key Concepts

  • Modes: Each operation can run on different (machine, technician-combo) pairs with different durations. The solver picks exactly one mode per operation.
  • Unattended operations (operators_required == 0): A technician does a short startup, then the machine runs alone (e.g., cures/bakes). The machine is blocked for the full duration.
  • Attended operations (operators_required > 0): Technicians are tied to the machine for the full duration.
  • Shift constraints: Starts are restricted to working windows (weekdays minus US holidays, 7am-4pm default).
  • Time units: All times are 15-minute wall-clock slots from the planning start date.
  • Objective: Minimize makespan + total tardiness.

About

CP-SAT model for a multi-mode flexible job shop scheduling problem with renewable technician resources, precedence constraints, release/due dates, and shift-calendar constraints.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages