Documentation for pdopt.exploration

Module that contains the functions and object required by the Exploration phase.

pdopt.exploration.ProbabilisticExploration

Class that represents the object performing the probabilistic exploration.

Attributes:
  • design_space (DesignSpace) –

    The design space object of the problem.

  • parameters (list[Parameter]) –

    List containing the input parameter objects.

  • objectives (list[Objective]) –

    List containing the objective objects.

  • constraints (list[Constraint]) –

    List containing the constraint objects.

  • model (Model) –

    Model object containing the evaluation function.

  • run_time (float) –

    Total running time (seconds).

  • surrogate_train_data (DataFrame) –

    Training data for the surrogates.

  • surrogate_test_data (DataFrame) –

    Testing data for the surrogates.

  • surrogates (dict[str, SurrogateResponse]) –

    The trained surrogate objects, keywords are the response names.

pdopt.exploration.ProbabilisticExploration.__init__(design_space, model, surrogate_training_data_file=None, surrogate_testing_data_file=None, n_train_points=128, debug=False)

Initialise the Probabilistic Exploration object.

Parameters:
  • design_space (DesignSpace) –

    The design space object of the problem.

  • model (Model) –

    Model object containing the evaluation function.

  • surrogate_training_data_file (str, default: None ) –

    Path to the training data .csv file. If None, generates data from scratch.

  • surrogate_testing_data_file (str, default: None ) –

    Path to the testing data .csv file. If None, generates data from scratch.

  • n_train_points (float, default: 128 ) –

    Number of points for training (must be a power of 2). Defaults to 128.

  • debug (bool, default: False ) –

    Fix random generator for testing purposes. Defaults to False.

Returns:
  • None.

pdopt.exploration.ProbabilisticExploration.from_pickle(filepath) classmethod

Helper function to load the ProbabilisticExploration object from a pickle file.

Parameters:
  • filepath (str) –

    Path to the .pk file.

Returns:
  • pdopt.exploration.ProbabilisticExploration: The loaded exploration object.

pdopt.exploration.ProbabilisticExploration.save_to_pickle(filepath)

Save the ProbabilisticExploration object to a pickle file.

Parameters:
  • filepath (str) –

    Path where to save the .pk file.

Returns:
  • None.

pdopt.exploration.ProbabilisticExploration.run(n_samples=100, p_discard=0.5, debug=False)

Perform the probabilistic exploration procedure

Parameters:
  • n_samples (int, default: 100 ) –

    The number of samples used to evaluate the satisfaction probability of a set. Defaults to 100.

  • p_discard (float, default: 0.5 ) –

    Probability threshold under which a design set is discarded. Defaults to 0.5.

  • debug (bool, default: False ) –

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

Returns:
  • None.

pdopt.exploration.ProbabilisticExploration.run_surrogate(X)

Run all the surrogate models for a given input.

Parameters:
  • X (ndarray) –

    Array of input parameters to be evaluated with the surrogate.

Returns:
  • means( dict[str, ndarray] ) –

    Dictionary containing the expected value for each surrogate response.

  • deviations( dict[str, ndarray] ) –

    Dictionary containing the standard deviation for each surrogate response.

pdopt.exploration.SurrogateResponse

Class that encapsulates the Gaussian Process Regressor to be used as probabilistic surrogate model.

Attributes:
  • id (int) –

    Unique id of the surrogate response.

  • name (str) –

    Name of the surrogate response.

  • n_levels (int) –

    Number of levels of the continous parameter.

  • par_names (list[str]) –

    List containing the parameter names

  • score (float) –

    r^2 score of the trained Gaussian Process

  • train_time (float) –

    Total training time (seconds).

  • x_scaler (MixMaxScaler) –

    Object used for normalising input data between [0,1].

  • f (GaussianProcessRegressor) –

    Trained Gaussian Process function.

pdopt.exploration.SurrogateResponse.__init__(response_name, parameters_list, model, train_data=None, test_data=None)

Initialise and train the SurrogateResponse object.

Parameters:
  • response_name (str) –

    Name of the response.

  • parameters_list (list[Parameter]) –

    List containing the input parameter objects.

  • model (Model) –

    Model object containing the evaluation function.

  • train_data (str, default: None ) –

    Path to training data .csv to be loaded. If set to None, it will generate a new set of training data.

  • test_data (str, default: None ) –

    Path to testing data .csv to be loaded. If set to None, it will generate a new set of testing data.

Returns:
  • None.

pdopt.exploration.SurrogateResponse.predict(x)

Parameters:
  • x (narray) –

    Array of input points where to evaluate the surrogate.

Returns:
  • mu( narray ) –

    Expected response of the input points.

  • sigma( narray ) –

    Standard deviation of the expected response.

pdopt.exploration.generate_input_samples(n_points, parameters_list, rule='lhs', debug=False)

Auxiliary function for sampling the full design space. The default rule is Latin Hypercube sampling (lhs), but Sobol and factorial grid sampling are available.

Parameters:
  • n_points (int) –

    Number of samples to generate.

  • parameters_list (list[Parameter]) –

    List containing the input parameter objects.

  • rule (str, default: 'lhs' ) –

    Method used for sampling. Available methods are LatinHypercube (’lhs’), Sobol sequence (’sobol’) and full factorial sampling (’grid’). Defaults to "lhs".

  • debug (TYPE, default: False ) –

    Fix random generator for testing purposes. Defaults to False.

Returns:
  • samples( ndarray ) –

    Numpy array containing the input samples, columns ordered as the parameters in parameters list..

pdopt.exploration.generate_surrogate_training_data(parameters_list, model, n_train_points, save_dir=None, debug=False)

Generates the training data from the evaluation function for the probabilistic surrogate model, by sampling in the entire design space using a Sobol sequence.

Parameters:
  • parameters_list (list[Parameter]) –

    List containing the input parameter objects.

  • model (Model) –

    Model object containing the evaluation function.

  • n_train_points (int) –

    Number of training datapoints to generate.

  • save_dir (str, default: None ) –

    Filename where to save the generated data into a .csv file. If set to None, no file is generated.

  • debug (bool, default: False ) –

    Fix random generator for testing purposes. Defaults to False.

Returns:
  • training_data( DataFrame ) –

    Dataframe with the generated datapoints,

  • with input and output columns as defined in the PDOPT case.

pdopt.exploration.generate_surrogate_test_data(n_points, parameters_list, model, save_dir=None, debug=False)

Generates the testing data from the evaluation function for the probabilistic surrogate model, by sampling in the entire design space using latin hybercube sampling.

Parameters:
  • n_points (int) –

    Number of training datapoints to generate.

  • parameters_list (list[Parameter]) –

    List containing the input parameter objects.

  • model (Model) –

    Model object containing the evaluation function.

  • save_dir (str, default: None ) –

    Filename where to save the generated data into a .csv file. If set to None, no file is generated.

  • debug (bool, default: False ) –

    Fix random generator for testing purposes. Defaults to False.

Returns:
  • test_data( DataFrame ) –

    Dataframe with the generated datapoints,

  • with input and output columns as defined in the PDOPT case.