Skip to content

Commit a91ee1a

Browse files
committed
Parse open shop problems
1 parent 9098c23 commit a91ee1a

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

read/Problem.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class ProblemVariant(str, Enum):
99
NW_PFSP = "NW-PFSP"
1010
HFSP = "HFSP"
1111
PMP = "PMP"
12+
OSP = "OSP"
1213
# Permutation machine scheduling problems
1314
PFSP = "PFSP"
1415
SDST_PFSP = "SDST-PFSP"

read/machine.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class MachineInstance:
2525
jobs: list[list[TaskData]] # also defines precedence constraints
2626
permutation: list[tuple[int, int]] | None = None # tuples of machine idcs
2727
no_wait: bool = False
28+
open_shop: bool = False # if True, job tasks have no precedence
2829
setup_times: list[list[list[int]]] | None = None
2930
objective: str = "makespan"
3031
due_dates: list[int] | None = None
@@ -64,6 +65,10 @@ def data(self) -> ProblemData:
6465
for mach_idx, duration in task_data:
6566
model.add_mode(task, machines[mach_idx], duration)
6667

68+
if self.open_shop:
69+
# Open shop: a job's tasks have no precedence among them.
70+
continue
71+
6772
for pred, succ in pairwise(job2tasks[job_idx]):
6873
# Assume linear routing of tasks as presented in the job data.
6974
if self.no_wait:
@@ -197,6 +202,14 @@ def parse_npfsp(cls, loc: Path):
197202

198203
return MachineInstance(num_machines, jobs)
199204

205+
@classmethod
206+
def parse_osp(cls, loc: Path):
207+
# Open shop has the same matrix format as NPFSP, but a job's tasks
208+
# may be processed in any order, so there is no precedence between them.
209+
instance = cls.parse_npfsp(loc)
210+
instance.open_shop = True
211+
return instance
212+
200213
@classmethod
201214
def parse_nw_pfsp(cls, loc: Path):
202215
instance = cls.parse_npfsp(loc)

read/read.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def read(loc: Path, problem: ProblemVariant) -> ProblemData:
1717
ProblemVariant.NPFSP: MachineInstance.parse_npfsp,
1818
ProblemVariant.NW_PFSP: MachineInstance.parse_nw_pfsp,
1919
ProblemVariant.PMP: MachineInstance.parse_pmp,
20+
ProblemVariant.OSP: MachineInstance.parse_osp,
2021
# Permutation machine scheduling
2122
ProblemVariant.PFSP: MachineInstance.parse_pfsp,
2223
ProblemVariant.SDST_PFSP: MachineInstance.parse_sdst_pfsp,

0 commit comments

Comments
 (0)