cost_eco_model_linker.sampling¶
Attributes¶
Functions¶
|
Calculates set up and operational costs in the deployment cost model (wb), given a set of parameters to sample. |
|
Calculates set up and operational costs in the production cost model (wb), given a set of parameters to sample. |
Load configuration file for model sampling |
|
Load internal config for model sampling |
|
|
Create a problem specification for sampling cost models using SALib. |
|
SALib samples floats, so convert categorical variables to integers by taking the ceiling. |
|
Run the production cost model. |
|
Run the deployment cost model. |
|
Generate Sobol' samples for the deployment model and run |
|
Generate Sobol' samples for the production model and run |
|
Module Contents¶
- cost_eco_model_linker.sampling.THIS_DIR¶
- cost_eco_model_linker.sampling.DEFAULT_VER = '3.8.0'¶
- cost_eco_model_linker.sampling.calculate_deployment_cost(wb, model_spec, factors)¶
Calculates set up and operational costs in the deployment cost model (wb), given a set of parameters to sample.
- Parameters:
wb (Workbook) – The cost model as an excel workbook
model_spec (DataFrame) – The cost model specification, detailing where cells are in the spreadsheet
factors (DataFrameRow) – Factor values to run cost model with
- Returns:
op_cost (float) – Operational cost
setup_cost (float) – Setup cost
- cost_eco_model_linker.sampling.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:
wb (Workbook) – The cost model as an excel workbook
factor_spec (dataframe) – factor specification, as loaded from the config.csv
factors (dataframerow) – Row of a pandas dataframe with factors to sample
- Returns:
op_cost (float) – Operational cost
setup_cost (float) – Setup cost
- cost_eco_model_linker.sampling.load_config()¶
Load configuration file for model sampling
- Parameters:
config_filepath (str) – String specifying filepath of config file, default is the default package config file
- cost_eco_model_linker.sampling.load_internal_config(fp)¶
Load internal config for model sampling
- Parameters:
fp (str) – Filename of config file within the package structure
- cost_eco_model_linker.sampling.problem_spec(cost_type)¶
Create a problem specification for sampling cost models using SALib.
- Parameters:
cost_type (str) – String specifying cost model type, “production_params” or “deployment_params”
config_filepath (str) – String specifying filepath of config file, default is the default package config file
- Returns:
sp (dict) – ProblemSpec for sampling with SALib
model_spec (dataframe) – factor specification, as loaded from the config.csv
- cost_eco_model_linker.sampling.convert_factor_types(factors_df, is_cat)¶
SALib samples floats, so convert categorical variables to integers by taking the ceiling.
- Parameters:
factors_df (dataframe) – A dataframe of sampled factors
is_cat (list{bool}) – Boolian vector specifian whether each factor is categorical
- Returns:
factors_df
- Return type:
Updated sampled factor dataframe with categorical factors as integers
- cost_eco_model_linker.sampling.collect_production_costs(wb, cost_factors, factor_spec)¶
Run the production cost model.
- Parameters:
wb_file_path (Workbook file path) – A cost model as an excel workbook
cost_factors (dataframe) – Dataframe of factors to input in the cost model
factor_spec (dataframe) – Factor specification, as loaded from the config.csv
- Returns:
cost_factors – Updated sampled factor dataframe with costs added
- Return type:
dataframe
- cost_eco_model_linker.sampling.collect_deployment_costs(wb, cost_factors, factor_spec)¶
Run the deployment cost model.
- Parameters:
wb_file_path (str) – Filepath to a cost model as an excel workbook
cost_factors (dataframe) – Dataframe of factors to input in the cost model
factor_spec (dataframe) – Factor specification, as loaded from the config.csv
- Returns:
cost_factors – Updated sampled factor dataframe with costs added
- Return type:
dataframe
- cost_eco_model_linker.sampling.run_deployment_model(cost_model: str, N: int)¶
Generate Sobol’ samples for the deployment model and run
- Parameters:
cost_model (str) – Path to cost (spreadsheet) model
N (int) – Number of desired Sobol’ sample points (resolves to N * (2D + 2) samples) where D is the number of model factors
- Return type:
SALib ProblemSpec with cost_model_results added as a field.
- cost_eco_model_linker.sampling.run_production_model(cost_model: str, N: int)¶
Generate Sobol’ samples for the production model and run
- Parameters:
cost_model (str) – Path to cost (spreadsheet) model
N (int) – Number of desired Sobol’ sample points (resolves to N * (2D + 2) samples) where D is the number of model factors
- Return type:
SALib ProblemSpec with cost_model_results added as a field.
- cost_eco_model_linker.sampling.extract_sa_results(sp: SALib.ProblemSpec, fig_path: str = './figs/')¶