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

load_rcpsp

Loader for PSPLIB RCPSP format.

parse_rcpsp

Parse a PSPLIB RCPSP instance file.

to_dataframe

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(f: TextIO) dict[str, Any][source]

Parse a PSPLIB RCPSP instance file.

Parameters:

f (TextIO) – The file to parse.

Returns:

Native Python structures with keys jobs, resource_names,

and capacities.

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.