cost_eco_model_linker.cost_calculations¶
Attributes¶
Functions¶
|
Calculate key cost codes: |
|
Initialize dataframe for storing sampled cost data. |
|
Sample cost model parameters for production, deployment, and LM models. |
|
Return the OPEX multiplier for LM interventions based on deployment distance. |
|
Update sampled LM factor dataframe with the year-specific larval release |
|
Update sampled cost model parameter dataframes with intervention specific parameters |
|
Calculate the number of devices required in the previous intervention year |
|
Sample costs for a set of interventions specified in ID_key, sampling nsims. |
Module Contents¶
- cost_eco_model_linker.cost_calculations.THIS_DIR¶
- cost_eco_model_linker.cost_calculations.cost_types(cost, contingency, nsims)¶
Calculate key cost codes: - 1 : CAPEX, sum of production and deployment cost - 2 : Contingency CAPEX, % of CAPEX - 3 : OPEX, sum of production and deployment cost - 4 : Sustaining capital OPEX, set to zero for now (assumed to be included in OPEX through contract) - 5 : Contingency OPEX, % of OPEX - 6 : Vessel fuel, only relevant if volunteer vessels are used - set to zero for now - 7 : CAPEX-monitoring, set to zero (assumed no monitoring cost) - 8 : Contingency CAPEX-monitoring, % of CAPEX-monitoring - 9 : OPEX-monitoring, set to zero (assumed no monitoring cost) - 10 : Sustaining capital OPEX-monitoring, set to zero (assumed no monitoring cost) - 11 : Contingency OPEX-monitoring, % of OPEX-monitoring
- Parameters:
cost (dataframe) – Dataframe containing ‘capex’ and ‘opex’
contingency (float) – Contingency proportion.
nsims (int) – Total number of simulations (from metrics sampling)
- cost_eco_model_linker.cost_calculations.initialize_cost_df(years, nsims)¶
Initialize dataframe for storing sampled cost data.
Components: - 1 : CAPEX, sum of production and deployment cost - 2 : Contingency CAPEX, % of CAPEX - 3 : OPEX, sum of production and deployment cost - 4 : Sustaining capital OPEX, set to zero for now (assumed to be included in OPEX through contract) - 5 : Contingency OPEX, % of OPEX - 6 : Vessel fuel, only relevant if volunteer vessels are used - set to zero for now - 7 : CAPEX-monitoring, set to zero (assumed no monitoring cost) - 8 : Contingency CAPEX-monitoring, % of CAPEX-monitoring - 9 : OPEX-monitoring, set to zero (assumed no monitoring cost) - 10 : Sustaining capital OPEX-monitoring, set to zero (assumed no monitoring cost) - 11 : Contingency OPEX-monitoring, % of OPEX-monitoring
- Parameters:
years (np.array) – All simulation years (non-intervention years will have zero costs)
nsims (int) – Total number of simulations (from metrics sampling)
- Returns:
cost_df
- Return type:
dataframe
- cost_eco_model_linker.cost_calculations.sample_cost_model(nsims)¶
Sample cost model parameters for production, deployment, and LM models.
- Parameters:
nsims (int or None) – Total number of simulations (from metrics sampling). When
Noneor1Sobol’ sampling is skipped and a single row ofbest_point_valueentries is returned instead.- Returns:
factor_specs_prod (DataFrame)
factors_df_prod (DataFrame)
factor_specs_dep (DataFrame)
factors_df_dep (DataFrame)
factor_specs_lm (DataFrame)
factors_df_lm (DataFrame)
- cost_eco_model_linker.cost_calculations.lm_opex_distance_multiplier(distance_nm: float) float¶
Return the OPEX multiplier for LM interventions based on deployment distance.
Derived from the regression 0.2495 * x^0.517, where x is distance in nautical miles. The relationship is calibrated so that 15 NM → ×1.0 (100%), 30 NM → ×1.5, 60 NM → ×2.0, 120 NM → ×3.0.
- Parameters:
distance_nm (float) – Distance from port in nautical miles.
- Returns:
Multiplier to apply to the raw LM OPEX value.
- Return type:
float
- cost_eco_model_linker.cost_calculations.update_lm_factors(lm_factors, iv_spec, pool_min, pool_max, sample_scale=False)¶
Update sampled LM factor dataframe with the year-specific larval release pool count derived from coral counts in the intervention specification.
- Parameters:
lm_factors (DataFrame) – Factors dataframe for the LM cost model.
iv_spec (DataFrame) – Intervention specification for the current rep and year (one row per reefset); must contain
number_of_1YO_corals.pool_min (int) – Minimum valid pool count (
range_lowerfrom LM config).pool_max (int) – Maximum valid pool count (
range_upperfrom LM config).sample_scale (bool, optional) – When
True(cost exploration mode), the larval pool count is already sampled from the Sobol sequence and must not be overwritten. The RME template coral counts are ignored. Defaults toFalse.
- Returns:
lm_factors
- Return type:
DataFrame
- cost_eco_model_linker.cost_calculations.update_factors(prod_factors, deploy_factors, iv_spec, sample_scale=False)¶
Update sampled cost model parameter dataframes with intervention specific parameters for a single ecological repeat.
- Parameters:
prod_factors (dataframe) – Factors dataframe for the production cost model.
deploy_factors (dataframe) – Factors dataframe for the deployment cost model.
iv_spec (dataframe) – Intervention specification dataframe for the current rep and year, containing one row per reefset.
sample_scale (bool, optional) – When
True(cost exploration mode),num_1yoecis already sampled from the Sobol sequence and must not be overwritten with the fixed coral count from the RME template.coral_yield_1YOECis still synced between models anddistance_from_portis still set fromiv_spec. Defaults toFalse.
- cost_eco_model_linker.cost_calculations.calc_production_requirement(deploy_factors, prev_iv_spec)¶
Calculate the number of devices required in the previous intervention year for a single ecological repeat. Used to determine whether additional production capacity is needed in the current year.
- Parameters:
deploy_factors (dataframe) – Factors dataframe for the deployment cost model (used for yield values).
prev_iv_spec (dataframe) – Intervention specification dataframe for the previous intervention year and rep, containing one row per reefset.
- Returns:
prev_devices – Number of devices required in the previous intervention year, per simulation.
- Return type:
np.ndarray
- cost_eco_model_linker.cost_calculations.calculate_costs(stores: cost_eco_model_linker.setup_results.OutputStores, ID_key_fn: str, nsims: int, deploy_model_filepath: str, prod_model_filepath: str, lm_model_filepath: str, cont_p: float = 0.25, p_iter_id: int = 0, active_models: set = None, sample_scale: bool = False, session_reset_interval: int = _RESET_INTERVAL)¶
Sample costs for a set of interventions specified in ID_key, sampling nsims.
- Parameters:
stores (OutputStores) – Data class holding output directory locations
ID_key_fn (str) – Target filename for output.
nsims (int) – Total number of draws to sample cost models, should match ecological metrics sampling.
deploy_model_filepath (string) – Path to deployment cost model.
prod_model_filepath (string) – Path to production cost model.
lm_model_filepath (string) – Path to LM cost model.
cont_p (float) – Contingency cost proportion.
p_iter_id (int) – ID used for parallel sampling to keep track of batches for ordered recombination.
active_models (set, optional) – Set of intervention types to compute costs for. Valid values are
"outplant"and"lm". Defaults to both whenNone. Pass{"outplant"}for CA-only or{"lm"}for LM-only scenarios.sample_scale (bool, optional) – When
True(cost exploration mode), intervention scale (num_1yoecfor outplant, larval pool count for LM) is drawn from the Sobol samples rather than derived from the RME template coral counts. Defaults toFalse.session_reset_interval (int, optional) – Recycle the process-local Excel session every N calls to bound memory growth. Defaults to
_RESET_INTERVAL(50).