untilperfect.model module

model.py

This module contains the definition of the buffer preparation vessel assignment problem along with classes for Parameters, Buffers and Vessels. It also contains a function for solving the problem.

class untilperfect.model.BufferPrepProblem(parameters, buffers, vessels, solver=None)[source]

Bases: object

Determines the optium selection and assignment of prep vessels.

Parameters:
  • parameters (untilperfect.Parameters) –
  • buffers (untilperfect.Buffers) –
  • vessels (untilperfect.Vessels) –
  • solver (None or pulp.LpSolver, optional) –
basic(do_solve=True)[source]

Solve basic problem (no scheduling) to minimize cost.

Parameters:do_solve (bool, optional) – If set to True (default), solves the problem upon construcion. Set this parameter to false to defer solution (useful if other constraints are to be applied before solving).
Returns:If do_solve is set to True, returns problem status (see pulp.LpStatus).
Return type:int
complete(do_solve=True)[source]

Solve complete problem (includes scheduling) to minimize cost.

Parameters:do_solve (bool, optional) – If set to True (default), solves the problem upon construcion. Set this parameter to false to defer solution (useful if other constraints are to be applied before solving).
Returns:If do_solve is set to True, returns problem status (see pulp.LpStatus).
Return type:int
evaluate(problem_type)[source]

Generate some useful data from a solved problem.

minimized_hold_time()[source]

Solve complete problem to first minimize vessel cost, then minimize hold times subject to the minimum cost.

Returns:If do_solve is set to True, returns problem status (see pulp.LpStatus).
Return type:int
minimized_used_volume()[source]

Solve complete problem to first minimize vessel cost, then minimize used preparation volume, subject to minimum cost, finally, minimize hold times, subject to minimal cost and minimal used preparation volume.

Returns:If do_solve is set to True, returns problem status (see pulp.LpStatus).
Return type:int
plot(filename='single_cycle_plot.svg')[source]

Create a single-cycle steady-state equipment occupancy plot.

Parameters:filename (str, optional) – Plot file name.
write(filename='untilperfect.lp')[source]

Write problem to file in .LP format.

Parameters:filename (str, optional) – Output file name.
class untilperfect.model.Buffers(data)[source]

Bases: untilperfect.model.Data

Selection of buffers to be prepared.

Parameters:data (str or dict) – Pass either a filename string or a dict of parameters to initialize a Data class instance. The filename should be that of a valid data file (csv format).
set_relative_use_start_times(cycle_time)[source]

Calculates use start times relative to cycle.

Parameters:cycle_time (float) – Process cycle time.
class untilperfect.model.Data(data)[source]

Bases: object

Parent class of ‘Buffers’ and ‘Vessels’. If initialized with a ‘dict’, reads data from the ‘dict’. If initialized with a ‘str’, treats it as a filename and reads data from the file.

Parameters:data (str or dict) – Pass either a filename string or a dict of parameters to initialize a Data class instance. The filename should be that of a valid data file (csv format).
class untilperfect.model.Parameters(data)[source]

Bases: object

Problem parameters.

Parameters:data (str or dict) – Pass either a filename string or a dict of parameters to initialize a Parameters instance. The filename should be that of a valid parameters file; in ini format and with a [parameters] section.
class untilperfect.model.Vessels(data)[source]

Bases: untilperfect.model.Data

Selection of preparation vessels available for use.

Parameters:data (str or dict) – Pass either a filename string or a dict of parameters to initialize a Vessels class instance. The filename should be that of a valid data file (csv format).
untilperfect.model.solve(parameters_file='parameters.ini', buffers_file='buffers.csv', vessels_file='vessels.csv', problem_type=<function BufferPrepProblem.complete>, solver=None, plot=True, write=True, cli=False)[source]

Solve BufferPrepProblem.

Parameters:
  • parameters_file (str, optional) – Parameters filename.
  • buffers_file (str, optional) – Buffers filename.
  • vessels_file (str, optional) – Vessels filename.
  • problem_type (optional) – Type of problem to solve.
  • solver (optional) – Solver to use; see pulp.LpSolver
  • plot (bool, optional) – Generate steady-state single-cylce equipent occupancy plot and save to file.
  • write (bool, optional) – Write the problem to file in .lp format.
  • cli (bool, optional) – Set to True to return problem status, returns problem object otherwise.
Returns:

If cli=True, returns status (int, see pulp.LpStatus), if cli=False, returns pulp.LpProblem instance.

Return type:

int or pulp.LpProblem