cost_eco_model_linker.runner¶
Attributes¶
Functions¶
|
Evaluate costs of intervention scenarios. |
|
|
|
Wrapper that converts factor kwargs into the format expected by |
|
Wrapper that converts factor kwargs into the format expected by |
|
Evaluate a cost model over a set of parameter combinations. |
|
Run a parameter sweep over a range of values for any single parameter. |
Module Contents¶
- cost_eco_model_linker.runner.SEMVER_RE¶
- cost_eco_model_linker.runner.evaluate(rme_files_path: str, nsims: int, deploy_model_fn: str, prod_model_fn: str, results_dir: str, metrics: list = None, uncertainty_dict: dict = None) list[str]¶
Evaluate costs of intervention scenarios.
- Parameters:
rme_files_path (str) – Path to ReefMod Engine results.
nsims (int) – Number of simulations to evaluate.
deploy_model_fn (str) – Path to deployment spreadsheet model, including filename but excluding file extension.
prod_model_fn (str) – Path to production spreadsheet model, including filename but excluding file extension.
results_dir (str) – Path to directory for storing results.
metrics (list, optional) – List of metrics to calculate. Default is None.
uncertainty_dict (dict, optional) – Dictionary specifying uncertainty parameters. Default is None.
- Returns:
Paths to result files.
- Return type:
list[str]
- cost_eco_model_linker.runner.parallel_evaluate(rme_files_path: str, nsims: int, ncores: int, deploy_model_fn: str, prod_model_fn: str, results_dir: str, metrics: list = None, uncertainty_dict: dict = None)¶
- cost_eco_model_linker.runner.evaluate_production_cost(workbook_path: str, **factors) tuple[float, float]¶
Wrapper that converts factor kwargs into the format expected by calculate_production_cost and returns operational and setup costs. Only the factors to be overridden need to be provided; all others default to their current values in the workbook.
- Parameters:
workbook_path (str) – Absolute path to the Excel workbook including extension (.xlsx).
**factors – Factor name-value pairs keyed by factor_name from the config CSV. Only factors to be overridden need to be supplied.
- Returns:
op_cost (float) – Operational cost.
setup_cost (float) – Setup cost.
- cost_eco_model_linker.runner.evaluate_deployment_cost(workbook_path: str, **factors) tuple[float, float]¶
Wrapper that converts factor kwargs into the format expected by calculate_deployment_cost and returns operational and setup costs. Only the factors to be overridden need to be provided; all others default to their current values in the workbook.
- Parameters:
workbook_path (str) – Absolute path to the Excel workbook.
**factors – Factor name-value pairs keyed by factor_name from the config CSV. Only factors to be overridden need to be supplied. due to the leading digit making it an invalid Python identifier.
- Returns:
op_cost (float) – Operational cost.
setup_cost (float) – Setup cost.
- cost_eco_model_linker.runner.run_cost_model(workbook_path: str, params_df: pandas.DataFrame, *, model_type: str | None = None, nprocs: int | None = None) pandas.DataFrame¶
Evaluate a cost model over a set of parameter combinations.
The model type (production or deployment) and config version are inferred from the workbook filename — e.g.
'3.9.1 CA Production Model.xlsx'. Passmodel_typeexplicitly only when the filename does not follow the standard naming convention.When
nprocsis greater than 1,params_dfis split into chunks and evaluated in parallel — each worker opens its own temporary workbook copy. Otherwise the whole DataFrame is evaluated serially in a single workbook session.Columns not present in
params_dfdefault to the values currently in the workbook.- Parameters:
workbook_path (str) – Absolute path to the Excel workbook including extension (.xlsx).
params_df (pd.DataFrame) – Each row is one model evaluation. Column names must be factor names from the relevant config CSV. Only factors to be overridden from workbook defaults need to be included.
model_type (str, optional) –
"production"or"deployment". Inferred from the filename if not provided.nprocs (int, optional) – Number of parallel worker processes. Values <= 1 run serially. Defaults to serial (
None).
- Returns:
Input DataFrame with three appended columns:
capex,opex, andtotal_cost.- Return type:
pd.DataFrame
- cost_eco_model_linker.runner.run_parameter_sweep(prod_model, deploy_model, sweep_param, search_range, prod_params=None, dep_params=None)¶
Run a parameter sweep over a range of values for any single parameter.
- Parameters:
prod_model (model) – Production cost model
deploy_model (model) – Deployment cost model
sweep_param (str) – Name of the parameter to sweep over
search_range (iterable) – Range of values to sweep over for sweep_param
prod_params (dict, optional) – Fixed keyword arguments passed to evaluate_production_cost
dep_params (dict, optional) – Fixed keyword arguments passed to evaluate_deployment_cost
- Returns:
search_range (iterable) – The input search range
prod_capex (np.ndarray)
prod_opex (np.ndarray)
dep_capex (np.ndarray)
dep_opex (np.ndarray)
totals (np.ndarray)