MIPLib dataset (cpmpy.tools.datasets.miplib)
MIPLib is the Mixed Integer Programming Library of benchmark instances. Origin: https://miplib.zib.de/
- class cpmpy.tools.datasets.miplib.MIPLibDataset(root: str = '.', year: int = 2024, transform: Callable | None = None, target_transform: Callable | None = None, download: bool = False, **kwargs: Any)[source]
MIPLib Dataset in a PyTorch compatible format.
Origin: https://miplib.zib.de/
Reference: Gleixner, A., et al. MIPLIB 2017: Data-Driven Compilation of the 6th Mixed-Integer Programming Library. Mathematical Programming Computation, 2021.
To load an instance into a CPMpy model, use
load_scip_format(). For examples of using a loader as a datasettransform, see the modeling guide.- Parameters:
root (str) – Root directory where datasets are stored or will be downloaded to (default=”.”).
year (int) – Year of the dataset to use (default=2024).
track (str) – Track name specifying which subset of the dataset instances to load (default=”exact-unweighted”).
transform (callable, optional) – Optional transform applied to the instance file path.
target_transform (callable, optional) – Optional transform applied to the metadata dictionary.
download (bool) – If True, downloads the dataset if it does not exist locally (default=False).
- 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.
yearortrack.
- citation: ClassVar[List[str]] = ['Gleixner, A., Hendel, G., Gamrath, G., Achterberg, T., Bastubbe, M., Berthold, T., Christophel, P. M., Jarck, K., Koch, T., Linderoth, J., Lubbecke, M., Mittelmann, H. D., Ozyurt, D., Ralphs, T. K., Salvagnin, D., and Shinano, Y. MIPLIB 2017: Data-Driven Compilation of the 6th Mixed-Integer Programming Library. Mathematical Programming Computation, 2021. https://doi.org/10.1007/s12532-020-00194-3.']
- collect_instance_metadata(file: Path) dict[str, Any][source]
Extract row/column counts from MPS file sections.
- classmethod dataset_metadata() dict[str, Any]
Return dataset-level metadata as a dictionary.
- Returns:
The dataset-level metadata.
- Return type:
dict
- description: ClassVar[str] = 'Mixed Integer Programming Library benchmark instances.'
- homepage: ClassVar[str] = 'https://miplib.zib.de/'
- 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] = 'miplib'
- classmethod open(instance: PathLike) TextIOBase[source]
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
- parse(instance: PathLike) Any
Parse an instance file into intermediate data structures.
Override this for datasets whose files contain problem data but not an explicit model. Typical outputs are structures like tables, arrays, and dictionaries that can then be passed to a separate model-construction function.
Default behavior is
read(instance), i.e. return raw text content.- Parameters:
instance (os.PathLike) – File path to the instance file.
- Returns:
The parsed intermediate data structure(s).
- 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