DroughtMitigationInstruments Module

API Reference

The base components define foundational functionality of the DroughtMitigationInstruments class for maintaining continuity.

Base Components

DroughtMitigationInstruments.h

class DroughtMitigationPolicy
#include <DroughtMitigationPolicy.h>

The DroughtMitigationPolicy class is an abstract class that defines the interface for drought mitigation policies. Created by bernardo on 2/6/17.

Subclassed by InsuranceStorageToROF, Restrictions, Transfers

Public Functions

DroughtMitigationPolicy(const int id, const int type)

Constructs a new DroughtMitigationPolicy object with specified attributes. This constructor initializes a DroughtMitigationPolicy object using the provided id and type.

Parameters:
virtual void applyPolicy(int week) = 0

Applies the Drought Mitigation Policy for a given week.

This is a purely virtual function that must be implemented by derived classes.

Parameters:

week – The week for which to extract the Drought Mitigation Policy.

Returns:

None

virtual void addSystemComponents(vector<Utility*> utilities, vector<WaterSource*> water_sources, vector<MinEnvFlowControl*> min_env_flow_controls) = 0

Adds system components (utilities, water sources, and minimum environment flow controls) to the Drought Mitigation Policy.

This function is a purely virtual function that must be implemented by derived classes.

Parameters:
  • utilities – A vector of pointers to the utilities associated with the Drought Mitigation Policy.

  • water_sources – A vector of pointers to the water sources associated with the Drought Mitigation Policy.

  • min_env_flow_controls – A vector of pointers to the minimum environment flow controls associated with the Drought Mitigation Policy.

Returns:

None

const vector<int> &getUtilities_ids() const

Retrieves the list of utility IDs associated with this DroughtMitigationPolicy. This function returns a reference to a vector containing the utility IDs.

Returns:

A constant reference to a vector of integers representing utility IDs.

bool operator<(const DroughtMitigationPolicy *other)

Compares two DroughtMitigationPolicy objects based on their IDs. This operator checks whether the current object’s ID is less than the ID of another DroughtMitigationPolicy object.

Parameters:

other – A pointer to the DroughtMitigationPolicy object to compare with.

Returns:

true if the current object’s ID is less than the ID of the other object; otherwise, false.

bool operator>(const DroughtMitigationPolicy *other)

Compares two DroughtMitigationPolicy objects based on their IDs. This operator checks whether the current object’s ID is greater than the ID of another DroughtMitigationPolicy object.

Parameters:

other – A pointer to the DroughtMitigationPolicy object to compare with.

Returns:

true if the current object’s ID is greater than the ID of the other object; otherwise, false.

virtual ~DroughtMitigationPolicy()

Destructor for the DroughtMitigationPolicy class. This function cleans up resources used by the DroughtMitigationPolicy object.

Returns:

None

void setStorage_to_rof_table_(vector<Matrix2D<double>> &storage_to_rof_table_, int use_imported_tables)

Sets the storage-to-ROF table and configuration for imported tables. This function updates the reference to the storage-to-ROF table and specifies whether imported tables are used.

Parameters:
  • storage_to_rof_table_ – A reference to a vector of Matrix2D<double> representing the storage-to-ROF table.

  • use_imported_tables – An integer flag indicating whether imported tables should be used. This is compared with IMPORT_ROF_TABLES.

Returns:

None.

virtual void setRealization(unsigned long realization_id, vector<double> &utilities_rdm, vector<double> &water_sources_rdm, vector<double> &policy_rdm) = 0

Retrieves the risk-of-failure (ROF) value for a specified utility, week, and tier. This function accesses the storage-to-ROF table to fetch the corresponding ROF value based on the input parameters.

Parameters:
  • utility_id – The ID of the utility for which the ROF value is to be retrieved.

  • week – The week for which the ROF value is needed.

  • tier – The ROF tier required.

Returns:

The ROF value as a double for the specified utility, week, and tier.

Public Members

const int id

The unique ID of the DroughtMitigationPolicy object.

const int type

The type of DroughtMitigationPolicy object.

Protected Functions

DroughtMitigationPolicy(const DroughtMitigationPolicy &drought_mitigation_policy)

Constructs a new DroughtMitigationPolicy object by copying an existing one. This function initializes a new DroughtMitigationPolicy object by copying the id and type attributes from another instance.

Parameters:

drought_mitigation_policy – The DroughtMitigationPolicy object to be copied.

Returns:

None. This is a constructor.

double getRofFromRealizationTable(int utility_id, int week, int tier)

Retrieves the risk-of-failure (ROF) value for a given utility, week, and tier from a given realization. This function accesses the storage-to-ROF table to fetch the corresponding ROF value.

Parameters:
  • utility_id – The ID of the utility for which the ROF value is to be retrieved.

  • week – The week for which the ROF value is needed.

  • tier – The tier for which the ROF value is required.

Returns:

The ROF value as a double for the specified utility, week, and tier from a given realization.

Protected Attributes

vector<int> utilities_ids

A vector of the utility IDs associated with the DroughtMitigationPolicy.

vector<Utility*> realization_utilities

A vector of pointers to the utilities associated with the DroughtMitigationPolicy in a given realization.

vector<WaterSource*> realization_water_sources

A vector of pointers to the water sources associated with the DroughtMitigationPolicy in a given realization.

vector<MinEnvFlowControl*> realization_min_env_flow_controls

A vector of pointers to the MinEnvFlowControls associated with the DroughtMitigationPolicy in a given realization.

vector<vector<double>> *rdm_factors_all

A 2D vector of pointers to the RDM factors for all utilities associated with the DroughtMitigationPolicy in a given realization.

double *rdm_factors_realization

A pointer to the RDM factors for the current realization.

bool use_imported_tables

A boolean flag indicating whether to use imported ROF tables.

Private Members

vector<Matrix2D<double>> *storage_to_rof_table_

A vector of 2D matrices that maps the storage of a utility to the ROF of that utility.