PSPLib dataset (cpmpy.tools.datasets.psplib)

PSPLib is a library of Project Scheduling Problem (RCPSP) benchmark instances. Origin: https://www.om-db.wi.tum.de/psplib/main.html

class cpmpy.tools.datasets.psplib.PSPLibDataset(root: str = '.', variant: str = 'rcpsp', family: str = 'j30', transform: Callable | None = None, target_transform: Callable | None = None, download: bool = False, **kwargs: Any)[source]

PSPlib Dataset in a PyTorch compatible format.

To load an instance into a CPMpy model, use load_rcpsp(). For examples of using a loader as a dataset transform, see the modeling guide.

Parameters:
  • root (str) – Root directory containing the psplib instances (if ‘download’, instances will be downloaded to this location)

  • variant (str) – scheduling variant (only ‘rcpsp’ is supported for now)

  • family (str) – family name (e.g. j30, j60, etc…)

  • transform (callable, optional) – Optional transform to be applied on the instance data (the file path of each problem instance)

  • target_transform (callable, optional) – Optional transform to be applied on the metadata (the metadata dictionary of each problem instance)

  • download (bool) – If True, downloads the dataset from the internet and puts it in root directory

METADATA_EXTENSION: ClassVar[str] = '.meta.json'
categories() dict[str, Any][source]

Labels to distinguish instances into categories matching to those of the dataset, e.g. year or track.

citation: ClassVar[List[str]] = ['Kolisch, R., Sprecher, A. PSPLIB - A project scheduling problem library. European Journal of Operational Research, 96(1), 205-216, 1997.']
collect_instance_metadata(file: Path) dict[str, Any][source]

Extract project metadata from SM file header.

classmethod dataset_metadata() dict[str, Any]

Return dataset-level metadata as a dictionary.

Returns:

The dataset-level metadata.

Return type:

dict

description: ClassVar[str] = 'Project Scheduling Problem Library (RCPSP) benchmark instances.'
download()[source]

Download the dataset.

homepage: ClassVar[str] = 'https://www.om-db.wi.tum.de/psplib/main.html'
instance_metadata(instance: PathLike) dict[str, Any]

Return the metadata for a given instance file.

Parameters:

file (os.PathLike) – Path to the instance file.

Returns:

The metadata for the instance.

Return type:

dict

name: ClassVar[str] = 'psplib'
classmethod open(instance: PathLike) TextIOBase

How an instance file from the dataset should be opened. Especially usefull when files come compressed and won’t work with Python standard library’s ‘open’, e.g. ‘.xz’, ‘.lzma’.

Parameters:

instance (os.PathLike) – File path to the instance file.

Returns:

The opened file handle.

Return type:

io.TextIOBase

classmethod parse(instance: PathLike) dict[str, Any][source]

Parse a PSPLIB RCPSP instance into job data and capacities.

read(instance: PathLike) str

Read raw file contents from an instance file. Handles optional decompression automatically via dataset.open().

Parameters:

instance (os.PathLike) – File path to the instance file.

Returns:

The raw file contents.

Return type:

str