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