Skip to content

Job shop

All formats · Reader spec · Cases and output

jobshop.iris reads job and machine counts, then one (machine, duration) pair per operation in each job. Machine numbers start at 0. Free text, # comments, and +++ separators are skipped. Each job must use every machine once. Data contains the counts and two-dimensional machine and duration arrays, plus name when present.

The format sources are the OR-Library job shop documentation and the format description at the start of jobshop1.txt, also used by JSPLIB. The reader spec is copied verbatim from Gecode’s job-shop.cpp.

  • or-library has three jobs and three machines, a description, separators, and instance handmade-or. Its params.json selects that instance by name.
  • jsplib has a different 3×3 instance with comment headers and no instance name.
  • duplicate-machine uses machine 0 twice in the first job. The reference reports E-CHECK-FAILED with record path [0].

The instances statement also supports files with several instances; these samples each contain one. These are hand-made samples under the repository’s MIT license. See the library README for case layout, validation, and Gecode notices.

Reader spec

From Gecode commit 5e7bbd5c26b0702c6fd652356b2289da0710ac3c. Source notices.

format jobshop
comment "#" "+++"
instances {
sections skip other {
"instance {name:word}" optional
"{n_jobs:1..} {n_machines:1..}" last {
check n_jobs <= (gecode.int_max - 2) / 2 / n_machines "there are too many jobs and machines"
repeat n_jobs as jobs {
each job
repeat n_machines as steps {
each step
machine: 0..<n_machines
duration: 0..
}
}
}
}
check distinct(job.machine) "a job uses a machine twice; each job must use every machine once"
check sum(j in jobs: sum(j.duration)) <= gecode.int_max "the total duration is too large"
}

Cases and output

Run the commands from the repository root. Successful reads show dzn, JSON, and a summary. Rejected inputs show the CLI's diagnostic and caret, with the stable error code beside it.

duplicate-machine

A job uses machine zero twice

Parameters: instance=handmade-invalid

instance handmade-invalid
3 3
0 2 0 3 2 1
1 1 2 4 0 2
2 3 0 1 1 2

E-CHECK-FAILED

check failed for record 1 of 'jobs': a job uses a machine twice; each job must use every machine once

Read rejectedRun from the repository root.
iris read formats/jobshop/jobshop.iris formats/jobshop/cases/duplicate-machine/input.txt --dzn --param instance=handmade-invalid
formats/jobshop/cases/duplicate-machine/input.txt:3:1: check failed for record 1 of 'jobs': a job uses a machine twice; each job must use every machine once
     3 | 0 2 0 3 2 1
       | ^
while reading: instance [1]
spec: formats/jobshop/jobshop.iris:21

Input rejected

Download full case · Open in playground

jsplib

Three-job instance with JSPLIB comments

# Hand-made JSPLIB style file
# Jobs and machines, then machine-duration pairs
3 3
0 3 2 2 1 4
1 2 0 1 2 3
2 4 1 3 0 2
dzn
iris read formats/jobshop/jobshop.iris formats/jobshop/cases/jsplib/input.txt --dzn
n_jobs = 3;
n_machines = 3;
machine = [| 0, 2, 1
  | 1, 0, 2
  | 2, 1, 0 |];
duration = [| 3, 2, 4
  | 2, 1, 3
  | 4, 3, 2 |];
JSON
iris read formats/jobshop/jobshop.iris formats/jobshop/cases/jsplib/input.txt --json
{"iris":"0.1","entries":[{"name":"n_jobs","type":"int","depth":0,"value":3},{"name":"n_machines","type":"int","depth":0,"value":3},{"name":"machine","type":"int","depth":2,"value":[[0,2,1],[1,0,2],[2,1,0]]},{"name":"duration","type":"int","depth":2,"value":[[3,2,4],[2,1,3],[4,3,2]]}]}
Summary
iris read formats/jobshop/jobshop.iris formats/jobshop/cases/jsplib/input.txt --summary
formats/jobshop/cases/jsplib/input.txt [jobshop]
  n_jobs: int 3
  n_machines: int 3
  machine: int array 3 x 3
  duration: int array 3 x 3

Download full case · Open in playground

or-library

Named three-job instance with OR-Library wrappers

Parameters: instance=handmade-or

Hand-made OR-Library style file
+++++++++++++++++++++++++++++
instance handmade-or
+++++++++++++++++++++++++++++
Three jobs on three machines
3 3
0 2 1 3 2 1
1 1 2 4 0 2
2 3 0 1 1 2
dzn
iris read formats/jobshop/jobshop.iris formats/jobshop/cases/or-library/input.txt --dzn --param instance=handmade-or
name = "handmade-or";
n_jobs = 3;
n_machines = 3;
machine = [| 0, 1, 2
  | 1, 2, 0
  | 2, 0, 1 |];
duration = [| 2, 3, 1
  | 1, 4, 2
  | 3, 1, 2 |];
JSON
iris read formats/jobshop/jobshop.iris formats/jobshop/cases/or-library/input.txt --json --param instance=handmade-or
{"iris":"0.1","entries":[{"name":"name","type":"string","depth":0,"value":"handmade-or"},{"name":"n_jobs","type":"int","depth":0,"value":3},{"name":"n_machines","type":"int","depth":0,"value":3},{"name":"machine","type":"int","depth":2,"value":[[0,1,2],[1,2,0],[2,0,1]]},{"name":"duration","type":"int","depth":2,"value":[[2,3,1],[1,4,2],[3,1,2]]}]}
Summary
iris read formats/jobshop/jobshop.iris formats/jobshop/cases/or-library/input.txt --summary --param instance=handmade-or
formats/jobshop/cases/or-library/input.txt [jobshop]
  name: string "handmade-or"
  n_jobs: int 3
  n_machines: int 3
  machine: int array 3 x 3
  duration: int array 3 x 3

Download full case · Open in playground