parameter_sweep.reader

Module Contents

Classes

ParameterSweepReader

Functions

get_sweep_params_from_yaml(m, yaml_filename)

Creates a dictionary of swept model parameters specified via yaml file

set_defaults_from_yaml(m, yaml_filename[, verbose])

Sets default model values using values stored in a yaml file

class parameter_sweep.reader.ParameterSweepReader
get_sweep_params_from_yaml(m, yaml_filename)

Creates a dictionary of swept model parameters specified via yaml file

This function creates a dictionary of the items to vary during a parameter sweep where the variable name, model attribute, and sweeping domain are specified in a YAML file. The YAML file should have the following format:

A_comp:
    type: NormalSample
    param: fs.RO.A_comp
    mean: 4.0e-12
    std: 0.5e-12

where the top-level keyword can be any short, easily understood identifier for the parameter. type must be one of LinearSample, UniformSample, NormalSample, or LatinHypercubeSample. param must be a valid dot-sperated string path to the object attribute (in this case, an RO attribute on the flowsheet m) that you wish to vary. The remaining arguments are dependent on the sample type selected. For NormalSample information about the mean and standard deviation is required. Consult the parameter_sweep help for more information on the different sample classes.

Parameters:
  • m (pyomo model) – The flowsheet containing the model to deploy with the parameter sweep tool.

  • yaml_filename (str) – The path to the yaml file.

Returns:

A dictionary containing different instances of parameter sweep samples

Return type:

sweep_params (dict)

set_defaults_from_yaml(m, yaml_filename, verbose=False)

Sets default model values using values stored in a yaml file

This function reads a yaml file with the structure:

fs.path.to.attribute_1: 0.123
fs.path.to.attribute_2: 1.234
...

and uses the (key, default_value) pairs to set default values for the attributes in model m.

Parameters:
  • m (pyomo model) – The flowsheet containing the model to set default values for

  • yaml_filename (str) – The path to the yaml file.

Returns:

N/A

parameter_sweep.reader.get_sweep_params_from_yaml(m, yaml_filename)

Creates a dictionary of swept model parameters specified via yaml file

This function creates a dictionary of the items to vary during a parameter sweep where the variable name, model attribute, and sweeping domain are specified in a YAML file. The YAML file should have the following format:

A_comp:
    type: NormalSample
    param: fs.RO.A_comp
    mean: 4.0e-12
    std: 0.5e-12

where the top-level keyword can be any short, easily understood identifier for the parameter. type must be one of LinearSample, UniformSample, NormalSample, or LatinHypercubeSample. param must be a valid dot-sperated string path to the object attribute (in this case, an RO attribute on the flowsheet m) that you wish to vary. The remaining arguments are dependent on the sample type selected. For NormalSample information about the mean and standard deviation is required. Consult the parameter_sweep help for more information on the different sample classes.

Parameters:
  • m (pyomo model) – The flowsheet containing the model to deploy with the parameter sweep tool.

  • yaml_filename (str) – The path to the yaml file.

Returns:

A dictionary containing different instances of parameter sweep samples

Return type:

sweep_params (dict)

parameter_sweep.reader.set_defaults_from_yaml(m, yaml_filename, verbose=False)

Sets default model values using values stored in a yaml file

This function reads a yaml file with the structure:

fs.path.to.attribute_1: 0.123
fs.path.to.attribute_2: 1.234
...

and uses the (key, default_value) pairs to set default values for the attributes in model m.

Parameters:
  • m (pyomo model) – The flowsheet containing the model to set default values for

  • yaml_filename (str) – The path to the yaml file.

Returns:

N/A