Documentation for pdopt.data

Module that contains all the data structures used within PDOPT.

Design Set objects

pdopt.data.DesignSpace

A class to represent a Design Space.

Attributes:
  • parameters (list[Parameter]) –

    List of parameters.

  • objectives (list[Objective]) –

    List of objectives.

  • constraints (list[Constraint]) –

    List of constraints.

  • n_par (int) –

    Number of paramters.

  • par_names (list[str]) –

    List of the parameter names.

  • obj_names (list[str]) –

    List of objective names.

  • con_names (list[str]) –

    List of constraint names.

  • sets (list[DesignSet]) –

    List of sets within the design space.

pdopt.data.DesignSpace.__init__(parameters, objectives, constraints)

Initialise the DesignSpace object.

Parameters:
  • parameters (list[Parameter]) –

    List of parameters.

  • objectives (list[Objective]) –

    List of objectives.

  • constraints (list[Constraint]) –

    List of constraints.

Returns:
  • None.

pdopt.data.DesignSpace.from_csv(csv_parameters, csv_responses) classmethod

Helper function to initialise the DesignSpace object from .csv files. This is useful for running multiple cases without modifying the python scripts.

Parameters:
  • csv_parameters (str) –

    Path to the input parameters csv file.

  • csv_responses (str) –

    Path to the responses csv file.

Returns:
  • DesignSpace

    Initialised design space object.

pdopt.data.DesignSpace.from_pickle(filepath) classmethod

Load a DesignSpace object from a pickle file.

Parameters:
  • filepath (str) –

    Path to DesignSpace binary file.

Returns:
  • DesignSpace

    Loaded design space object.

pdopt.data.DesignSpace.save_to_pickle(filepath)

Save a DesignSpace object as pickle file.

Parameters:
  • filepath (str) –

    Path to save the DesignSpace object.

Returns:
  • None.

pdopt.data.DesignSpace.get_exploration_results()

Construct a pandas DataFrame with the exploration results.

Returns:
  • pandas.DataFrame: Dataframe with Exploration phase results.

pdopt.data.DesignSpace.get_optimum_results()

Construct a pandas DataFrame with the optimisation results.

Returns:
  • pandas.DataFrame: Dataframe with Search phase results.

pdopt.data.DesignSpace.set_discard_status(set_id, status)

Set the discard status of a set.

Parameters:
  • set_id (int) –

    ID of the set.

  • status (bool) –

    Discarded status. Set to true if the set is to be marked as discarded.

Returns:
  • None.

pdopt.data.DesignSpace.save_exploration_results(filepath)

Save exploration results as a .csv file

Parameters:
  • filepath (str) –

    Path to save the results.

Returns:
  • None.

pdopt.data.DesignSpace.save_optimisation_results(filepath)

Save optimisation results as a .csv file

Parameters:
  • filepath (str) –

    Path to save the results.

Returns:
  • None.

pdopt.data.DesignSpace.sample_from_set(set_id, n_samples, debug=False)

Sample design parameters contained within a set using LatinHypercube.

Parameters:
  • set_id (int) –

    ID of the set.

  • n_samples (int) –

    Number of samples to be generated.

  • debug (bool, default: False ) –

    Fix the random generator for debug purposes. Defaults to False.

Returns:
  • sampled_designs( Array ) –

    Array of size (n_samples, n_par) with the sampled input designs from the set_id set..

pdopt.data.DesignSet

A class to represent a Design Set.

Attributes:
  • id (int) –

    Unique id of the set.

  • parameter_levels_dict (dict{str ) –

    int}): Dictionary containing the level of each input parameter, indexed by parameter name.

  • parameter_levels_list (list[int]) –

    List with the parameter levels, in the same order as the input parameters.

  • response_parameters (list[str]) –

    List containing the names of the responses attached to the set.

  • is_discarded (bool) –

    Flag if the set has been discarded.

  • P (float) –

    Overall satisfaction probability of the set.

  • P_responses (dict{str ) –

    float}): Dictionary containing the satisfaction probability for each requirement, indexed by response name.

  • optimisation_problem (Problem) –

    pymoo Object containing the optimisation problem, extended with surrogate models if necessary (see pdopt.optimisation).

  • optimisation_results (DataFrame) –

    DataFrame containing the search phase results for this set.

pdopt.data.DesignSet.__init__(input_parameter_levels, response_parameters)

Initialise the Design Set object.

Parameters:
  • input_parameter_levels (dict{str) –

    int}): Dictionary containing the level of each input parameter, indexed by parameter name.

  • response_parameters (list[str]) –

    List containing the names of the responses attached to the set.

Returns:
  • None.

pdopt.data.DesignSet.get_discarded_status()

Get the discarded status of the set.

Returns:
  • bool

    Discarded status.

pdopt.data.DesignSet.get_P()

Get the overall probability of the set.

Returns:
  • float

    Probability value.

pdopt.data.DesignSet.get_response_P(response_id=None)

Returns the probability of a response or all of them.

Parameters:
  • response_id (int, default: None ) –

    Get the probability of a response. If set to None, get all the responses.

Returns:
  • float

    Probability value.

pdopt.data.DesignSet.set_responses_P(response_name, P_response)

Updates adds the probability of the response and updated the global probability.

Parameters:
  • response_name (str) –

    Name of the response (Must be a constraint or objective).

  • P_response (float) –

    Probability value of the response.

Returns:
  • None.

pdopt.data.DesignSet.set_as_discarded()

Set the set as discarded.

Returns:
  • None.

pdopt.data.DesignSet.set_optimisation_problem(opt_problem)

Set the optimisation problem from the Optimisation library

Parameters:
  • opt_problem (Problem) –

    Optimisation problem.

Returns:
  • None.

pdopt.data.DesignSet.sample(n_samples, parameters_list, debug=False)

Sample designs within the set using Latin Hypercube

Parameters:
  • set_id (int) –

    ID of the set.

  • n_samples (int) –

    Number of samples to be generated.

  • debug (bool, default: False ) –

    Fix the random generator for debug purposes. Defaults to False.

Returns:
  • sampled_designs( Array ) –

    Array of size (n_samples, n_par) with the sampled input designs from the set_id set..

pdopt.data.DesignSet.get_optimum()

Get a pandas DataFrame with the Search phase results of this set.

Returns:
  • pandas.DataFrame: Dataframe with Search phase results.

Input Parameter objects

pdopt.data.ContinousParameter

Bases: Parameter

A class to represent a Continous Parameter.

Attributes:
  • id (int) –

    Unique id of the parameter.

  • name (str) –

    Name of the parameter. n_levels (int): Number of levels of the continous parameter.

  • lb (float) –

    Lower bound value of the continous parameter.

  • ub (float) –

    Upper bound value of the continous parameter.

  • ranges (list[float, float]) –

    List of the bounds of each level.

  • uq_dist (str) –

    Type of uncertainty distribution to be applied to this parameter. Options are "norm", "uniform" and "triang".

  • uq_var_l (float) –

    Lower percentile variation from the UQ distribution mean

  • uq_var_u (float) –

    Upper percentile variation from the UQ distribution mean

pdopt.data.ContinousParameter.get_bounds()

Returns a tuple with the continous parameter bounds

Returns:
  • float Lower bound of the continous parameter.

  • float Upper bound of the continous parameter.

pdopt.data.ContinousParameter.get_level_bounds(level)

Returns a tuple containing the bounds of the selected level.

Parameters:
  • level

    int N-th selected level.

Returns:
  • float Lower bound of the selected level.

  • float Upper bound of the selected level.

pdopt.data.ContinousParameter.__init__(name, lb, ub, n_levels, uq_dist, uq_var_l, uq_var_u)

Initialise the Continous Parameter object.

Parameters:
  • name (str) –

    Name of the parameter.

  • lb (float) –

    Lower bound value of the continous parameter.

  • ub (float) –

    Upper bound value of the continous parameter.

  • n_levels (int) –

    Number of levels of the continous parameter.

  • uq_dist (str) –

    Type of uncertainty distribution to be applied to this parameter. Options are "norm", "uniform" and "triang".

  • uq_var_l (float) –

    Lower percentile variation from the UQ distribution mean

  • uq_var_u (float) –

    Upper percentile variation from the UQ distribution mean

Returns:
  • None.

pdopt.data.ContinousParameter.sample(n_samples, level=None)

Sample within the entire continuous parameter or in a level.

Parameters:
  • n_samples

    int Number of samples.

  • level

    int, optional N-th level to sample in. If None, sample in the entire range. The default is None.

Returns:
  • numpy.ndarray Array of random samples of length n_samples.

pdopt.data.ContinousParameter.ppf(quantile, x0)

Inverse cumulative function for obtaining random values around a reference point, given a quantile.

Parameters:
  • quantile

    float or numpy.ndarray Probability quantile(s).

  • x0

    float Mean value of the uncertainty distribution.

Returns:
  • numpy.ndarray Array of samples from the distribution matching the quantiles.

pdopt.data.DiscreteParameter

Bases: Parameter

A class to represent a discrete parameter.

Attributes:
  • id (int) –

    Unique id of the parameter.

  • name (str) –

    Name of the discrete parameter.

  • n_levels (int) –

    Number of levels of the discrete parameter.

pdopt.data.DiscreteParameter.get_n_levels()

Returns the number of levels of this parameter.

Returns:
  • int The total number of levels in this parameter.

Response objects

pdopt.data.Objective

Bases: Response

A class to represent an Objective.

Attributes:
  • id (int) –

    Unique id of the objective.

  • name (str) –

    Name of the objective.

  • operand (str) –

    The type of objective. It can be either ”min” for minimise or ”max” for maximise.

  • min_requirement (float) –

    Optional soft constraint. If present, it will affect the exploration phase by setting a maximum value constraint (if objective set to minimise), viceversa minimum value constraint (if objective set to maximise).

  • p_sat (float) –

    The satisfaction probability of the objective, if the soft constraint is set.

pdopt.data.Objective.__init__(name, operand, min_requirement=None, p_sat=0.5)

Initialise the Objective object.

Parameters:
  • name

    str Name of the objective.

  • operand

    str The type of objective. It can be either ”min” for minimise or ”max” for maximise.

  • min_requirement

    float, optional Soft constraint value. If present, it will affect the exploration phase by setting a maximum value constraint (if objective set to minimise), viceversa minimum value constraint (if objective set to maximise). The default is None.

  • p_sat

    float, optional The satisfaction probability of the objective, if the soft constraint is set. The default is 0.5.

Returns:
  • None.

pdopt.data.Objective.get_requirement()

Get the inequality that defines the soft constraint, if present. Returns a tuple containing the operand and right-hand side value. Returns none if no soft constraint is present.

Returns:
  • str Operand of the soft constraint ("lt" for <, "gt" for >).

  • float Right-hand side of the constraint.

pdopt.data.Objective.get_operand()

Get the multiplier required by the pymoo optimiser to perform maximisation.

Returns:
  • int Returns -1 if the objective is set to maximise, 1 otherwise.

pdopt.data.Constraint

Bases: Response

A class to represent a Constraint.

Attributes:
  • id (int) –

    Unique id of the constraint.

  • name (str) –

    Name of the constraint.

  • operand (str) –

    The type of constraint. It can be either "lt" for < or "gt" for >.

  • value (float) –

    Right hand side of the constraint i.e. g(x) < value

  • p_sat (float) –

    The satisfaction probability of the constraint.

pdopt.data.Constraint.__init__(name, operand, value, p_sat=0.5)

Initialise the Constraint object.

Parameters:
  • name

    str Name of the constraint. Must be a response name.

  • operand

    str The type of constraint. It can be either "lt" for < or "gt" for >.

  • value

    float Right hand side of the constraint i.e. g(x) < value.

  • p_sat

    float, optional The satisfaction probability of the constraint. The default is 0.5.

Returns:
  • None.

pdopt.data.Constraint.get_constraint()

Get the inequality that defines the constraint. Returns a tuple containing the operand and the right-hand side value.

Returns:
  • str The type of constraint. It can be either "lt" for < or "gt" for >.

  • float Right hand side of the constraint i.e. g(x) < value..

Simulation model objects

pdopt.data.Model

A class to encapsulate the design model.

Attributes:
  • run (function) –

    Model function

pdopt.data.Model.__init__(model_fun)

Initialise the design model. Model function has to be designed such that what it returns is the same as the response list example: model_fun(*args : list[float]) -> dict[str, float]

Parameters:
  • model_fun (function) –

    The reference to the function of the design model.

Returns:
  • None.

pdopt.data.ExtendableModel

Model Object that can be extended and used by the library

pdopt.data.ExtendableModel.run(*args)

The run() method has to be overloaded with the evaluation function required to run the analysis. Input parameters must be a list in the order of the paramters passed to the DesignSpace object. Output must be a dictionary containing for keyword the names of the constraints and objectives as defined in the DesignSpace object.

Parameters:
  • *args

    list[float] A list containing the input quantities, in the same order as in the DesignSpace object.

Returns:
  • dict[str, float]

    dict[str, float] A dicitonary containing the outputs (constraints and objectives) with keywords matching those of the object.