sampling_functions

Functions

calculate_deployment_cost(wb, factor_spec, factors)

Calculates set up and operational costs in the deployment cost model (wb), given a set of parameters to sample.

calculate_production_cost(wb, factor_spec, factors)

Calculates set up and operational costs in the production cost model (wb), given a set of parameters to sample.

load_config([config_filepath])

Load configuration file for model sampling

problem_spec(cost_type[, config_filepath])

Create a problem specification for sampling using SALib.

convert_factor_types(factors_df, is_cat)

SALib samples floats, so convert categorical variables to integers by taking the ceiling.

_sample_cost(wb_file_path, factors_df, factor_spec, ...)

Sample a cost model.

sample_deployment_cost(wb_file_path, factors_df, ...)

Sample the deployment cost model.

sample_production_cost(wb_file_path, factors_df, ...)

Sample the production cost model.

cost_sensitivity_analysis(samples_fn, cost_type[, ...])

Perform a sensitvity analysis with costs as output from a set of samples.

Module Contents

sampling_functions.calculate_deployment_cost(wb, factor_spec, factors)

Calculates set up and operational costs in the deployment cost model (wb), given a set of parameters to sample.

Parameters

wbWorkbook

The cost model as an excel workbook

factor_specdataframe

The factor specification, as loaded from the config.csv

factorsdataframerow

Row of a pandas dataframe with factors to sample

Returns

Cost: float

Operational cost

setupCost: float

Setup cost

sampling_functions.calculate_production_cost(wb, factor_spec, factors)

Calculates set up and operational costs in the production cost model (wb), given a set of parameters to sample.

Parameters

wbWorkbook

The cost model as an excel workbook

factor_specdataframe

factor specification, as loaded from the config.csv

factorsdataframerow

Row of a pandas dataframe with factors to sample

Returns

Cost: float

Operational cost

setupCost: float

Setup cost

sampling_functions.load_config(config_filepath='config.csv')

Load configuration file for model sampling

Parameters

config_filepathstr

String specifying filepath of config file, default is the default package config file

sampling_functions.problem_spec(cost_type, config_filepath='config.csv')

Create a problem specification for sampling using SALib.

Parameters

cost_typestr

String specifying cost model type, “production_params” or “deployment_params”

config_filepathstr

String specifying filepath of config file, default is the default package config file

Returns

sp: dict

ProblemSpec for sampling with SALib

factor_specdataframe

factor specification, as loaded from the config.csv

sampling_functions.convert_factor_types(factors_df, is_cat)

SALib samples floats, so convert categorical variables to integers by taking the ceiling.

Parameters

factors_dfdataframe

A dataframe of sampled factors

is_catlist{bool}

Boolian vector specifian whether each factor is categorical

Returns:

factors_df: Updated sampled factor dataframe with categorical factors as integers

sampling_functions._sample_cost(wb_file_path, factors_df, factor_spec, calculate_cost)

Sample a cost model.

Parameters

wb_file_pathstr

Filepath to a cost model as an excel workbook

factors_dfdataframe

Dataframe of factors to input in the cost model

factor_specdataframe

factor specification, as loaded from the config.csv

calculate_cost: function

Function to use to sample cost

Returns

factors_dfdataframe

Updated sampled factor dataframe with costs added

sampling_functions.sample_deployment_cost(wb_file_path, factors_df, factor_spec)

Sample the deployment cost model.

Parameters

wb_file_pathstr

Filepath to a cost model as an excel workbook

factors_dfdataframe

Dataframe of factors to input in the cost model

factor_specdataframe

factor specification, as loaded from the config.csv

Returns

factors_dfdataframe

Updated sampled factor dataframe with costs added

sampling_functions.sample_production_cost(wb_file_path, factors_df, factor_spec)

Sample the production cost model.

Parameters

wb_file_pathWorkbook file path

A cost model as an excel workbook

factors_dfdataframe

Dataframe of factors to input in the cost model

factor_specdataframe

Factor specification, as loaded from the config.csv

Returns

factors_dfdataframe

Updated sampled factor dataframe with costs added

sampling_functions.cost_sensitivity_analysis(samples_fn, cost_type, figures_path='.\\src\\figures\\')

Perform a sensitvity analysis with costs as output from a set of samples.

Parameters

samples_fnstr

Filename/path of the samples.

cost_typestr

“production” or “deployment”.

figures_pathstr

Path to save figures from the sensitvity analysis.