RCPSP (cpmpy.tools.io.rcpsp)
Helper functions for the PSPLIB RCPSP format.
The PSPLIB RCPSP format is a textual format to represent Resource-Constrained Project Scheduling problems. More can be read about it here:
List of functions
Loader for PSPLIB RCPSP format. |
|
Parse a PSPLIB RCPSP instance file. |
|
Convert parsed RCPSP job data to a pandas DataFrame. |
- cpmpy.tools.io.rcpsp.load_rcpsp(rcpsp: str | PathLike | TextIO, open: Callable = <built-in function open>) Model[source]
Loader for PSPLIB RCPSP format. Loads an instance and returns its matching CPMpy model.
- Parameters:
rcpsp (str or os.PathLike or TextIO) –
A file path to a PSPLIB RCPSP file
OR a string containing the RCPSP content directly
OR a TextIO object already open for reading
open (Callable) – If rcpsp is the path to a file, a callable to “open” that file (default=python standard library’s ‘open’).
- Returns:
The CPMpy model of the PSPLIB RCPSP instance.
- Return type:
cp.Model
- cpmpy.tools.io.rcpsp.parse_rcpsp(instance: str | PathLike | TextIO, open: Callable = <built-in function open>) dict[str, Any][source]
Parse a PSPLIB RCPSP instance file.
- Parameters:
instance (str or os.PathLike or TextIO) –
A file path to a PSPLIB RCPSP file, or
A string containing the RCPSP content directly, or
A TextIO object already open for reading
open (Callable) – If instance is the path to a file, a callable to “open” that file (default=python standard library’s ‘open’).
- Returns:
- Native Python structures with keys
jobs,resource_names, and
capacities.
- Native Python structures with keys
- Return type:
dict[str, Any]
Note
Use
to_dataframe()to convert job data to a pandas DataFrame if needed.
- cpmpy.tools.io.rcpsp.to_dataframe(data: dict[str, Any])[source]
Convert parsed RCPSP job data to a pandas DataFrame.
- Parameters:
data (dict[str, Any]) – Dictionary returned by
parse_rcpsp().- Returns:
Job data indexed by job number.
- Return type:
pd.DataFrame
- Raises:
ImportError – If pandas is not installed.