DataCollector Module
API Reference
Below is the API reference for submodules of the DataCollector
module.
Submodule Components
AllocatedIntakeDataCollector.h
-
class AllocatedIntakeDataCollector : public DataCollector
- #include <AllocatedIntakeDataCollector.h>
The
AllocatedIntakeDataCollector
class is a subclass of theDataCollector
class that implements the data collection of allocated intake objects.Created by dgorelic on 3/2/2020.
Public Functions
-
AllocatedIntakeDataCollector(AllocatedIntake *intake, unsigned long realization)
Constructor for the AllocatedIntakeDataCollector class. This function initializes an AllocatedIntakeDataCollector object with the specified intake and realization.
This constructor initializes the AllocatedIntakeDataCollector object by calling the base DataCollector constructor with specific parameters derived from the intake. It also initializes the
utilities_with_allocations
member using data from theAllocatedIntake
object.See also
- Parameters:
intake – A pointer to the AllocatedIntake object associated with this data collector.
realization – The realization number associated with the data collection.
-
virtual string printTabularString(int week) override
Generates a tabular string representation of data for a specific week.
This function creates a formatted string that represents the weekly data for demands, inflows, outflows, and allocations. The data is formatted into a tabular structure with fixed column widths and precision. It includes:
Demand for the week.
Total upstream source inflows.
Wastewater inflows.
Total inflows from catchments.
Outflows.
Allocated supply capacities and demands for utilities with allocations.
This function overrides the base class
printTabularString
function.- Parameters:
week – The week number for which the data should be printed.
- Throws:
std::out_of_range – If the
week
parameter is out of bounds for any of the accessed data arrays.- Returns:
A string containing the tabular data for the specified week.
-
virtual string printCompactString(int week) override
Generates a compact, comma-separated string representation of data for a specific week.
This function creates a compact string that represents the weekly data for demands, inflows, outflows, and allocations. The data is structured as a comma-separated list and includes:
Demand for the week.
Total upstream source inflows.
Wastewater inflows.
Total inflows from catchments.
Outflows.
Allocated supply capacities and demands for utilities with allocations.
This function overrides the base class
printCompactString
function.- Parameters:
week – The week number for which the data should be printed.
- Throws:
std::out_of_range – If the
week
parameter is out of bounds for any of the accessed data arrays.- Returns:
A string containing the compact data for the specified week, with values separated by commas.
-
virtual string printTabularStringHeaderLine1() override
Generates the first header line for a tabular string representation.
This function creates a formatted header line for tabular data representation. The header includes:
Blank space for alignment.
Column headers for upstream inflows, wastewater inflows, and catchment inflows.
Identifiers for utilities with allocations, listed twice for supply capacities and demands.
This function overrides the base class
printTabularStringHeaderLine1
function.- Returns:
A string containing the first header line of the tabular data.
-
virtual string printTabularStringHeaderLine2() override
Generates the second header line for a tabular string representation.
This function creates a formatted second header line for tabular data representation. The header includes:
Column labels for demands, spillage, inflows (upstream, wastewater, and catchment), and outflows.
Labels for allocated supply capacities and demands for utilities with allocations.
This function overrides the base class
printTabularStringHeaderLine2
function.- Returns:
A string containing the second header line of the tabular data.
-
virtual string printCompactStringHeader() override
Generates a compact, comma-separated header string for the compact data representation.
This function creates a compact header string for the data, where each column is prefixed by the
id
of the AllocatedIntakeDataCollector object. The header includes:Demand.
Upstream spillage.
Wastewater inflow.
Catchment inflow.
Downstream spillage.
Allocated supply capacities and demands for utilities with allocations, each uniquely identified with the utility ID.
This function overrides the base class
printCompactStringHeader
function.- Returns:
A string containing the header for the compact data, with column identifiers separated by commas.
-
virtual void collect_data() override
Collects and stores data from the associated AllocatedIntake object.
This function retrieves data from the AllocatedIntake object and appends it to the corresponding member variables. The collected data includes:
Current demand.
Total inflow from upstream sources.
Inflow from wastewater sources.
Total inflow from upstream catchments.
Total outflow.
Allocated supply capacities for utilities with allocations.
Allocated demands for utilities with allocations.
This function overrides the base class
collect_data
function.- Returns:
void
Private Members
-
AllocatedIntake *intake
The AllocatedIntake object from which data will be collected.
-
vector<double> total_upstream_sources_inflows
The timeseries of total inflow from upstream sources.
-
vector<double> demands
The timeseries of demands.
-
vector<double> wastewater_inflows
The timeseries of inflow from wastewater sources.
-
vector<double> outflows
The timeseries of total outflows from each intake.
-
vector<double> total_catchments_inflow
The timeseries of total inflow from catchments.
-
vector<vector<double>> allocated_demands
A 2D vector of across demands from all sources allocated to each utility.
-
vector<vector<double>> allocated_supply_capacity
A 2D vector of supply capacities across all sources allocated to each utility.
-
vector<int> utilities_with_allocations
A IDs of utilities with allocations to the intake.
-
AllocatedIntakeDataCollector(AllocatedIntake *intake, unsigned long realization)
AllocatedReservoirDataCollector.h
-
class AllocatedReservoirDataCollector : public ReservoirDataCollector
- #include <AllocatedReservoirDataCollector.h>
The
AllocatedReservoirDataCollector
class is a subclass of theReservoirDataCollector
class, which in turn is a subclass of the mainDataCollector
class. It implements the data collection of allocated reservoir objects.Created by Created by bernardoct on 8/26/17.
Public Functions
-
AllocatedReservoirDataCollector(AllocatedReservoir *allocated_reservoir, unsigned long realization)
Constructs an AllocatedReservoirDataCollector for managing and collecting data from an AllocatedReservoir. This function initializes the data collector with specific attributes for allocated reservoirs.
- Parameters:
allocated_reservoir – Pointer to the AllocatedReservoir object that this collector will manage.
realization – Unsigned long integer representing the realization (scenario or simulation ID).
-
virtual string printTabularString(int week) override
Generates a tabular string representation of the allocated reservoir’s data for a given week. This function extends the tabular output by including data for utilities with allocations.
This function overrides the virtual function
printTabularString
from theReservoirDataCollector
class.- Parameters:
week – Integer representing the week for which the tabular data is being generated.
- Returns:
A string containing the tabular representation of the reservoir data for the specified week.
-
virtual string printCompactString(int week) override
Generates a compact, comma delimited string representation of the allocated reservoir’s data for a given week. This function extends the compact output by appending data for utilities with allocations.
This function overrides the virtual function
printCompactString
from theReservoirDataCollector
class.- Parameters:
week – Integer representing the week for which the compact data is being generated.
- Returns:
A string containing the compact representation of the reservoir data for the specified week.
-
virtual string printTabularStringHeaderLine1() override
Generates the first header line for a tabular representation of allocated reservoir data. This includes the base header line and additional columns for the stored volume of utilities with allocations.
This function overrides the virtual function
printTabularStringHeaderLine1
from theReservoirDataCollector
class.- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printTabularStringHeaderLine2() override
Generates the second header line for a tabular representation of allocated reservoir data. This includes the base header line and additional columns for allocation percentage for each utility.
This function overrides the virtual function
printTabularStringHeaderLine2
from theReservoirDataCollector
class.- Returns:
A string containing the second header line for the tabular representation.
-
virtual string printCompactStringHeader() override
Generates a compact string header for the allocated reservoir’s data. This includes the base header and additional columns for utility allocations.
This function overrides the virtual function
printCompactStringHeader
from theReservoirDataCollector
class.- Returns:
A string containing the compact header representation for the reservoir data.
-
virtual void collect_data() override
Collects data for the allocated reservoir, including its allocated stored volumes. This function extends the base class data collection by storing allocated volume data.
This function overrides the virtual function
collect_data
from theDataCollector
class.- Returns:
void
Private Members
-
AllocatedReservoir *allocated_reservoir
The AllocatedReservoir object from which data will be collected.
-
vector<vector<double>> allocated_stored_volumes
A 2D vector containing each utility’s allocation of the stored volume for each utility in each week.
-
vector<int> utilities_with_allocations
A vector containing the IDs of the utilities with allocations.
-
AllocatedReservoirDataCollector(AllocatedReservoir *allocated_reservoir, unsigned long realization)
EmptyDataCollector.h
-
class EmptyDataCollector : public DataCollector
- #include <EmptyDataCollector.h>
The
EmptyDataCollector
class is a subclass of theEmptyDataCollector
class that implements default data collection behavior.Created by bernardoct on 8/26/17.
Public Functions
-
EmptyDataCollector()
Constructs an EmptyDataCollector with default values for uninitialized or placeholder data collection. This is a default constructor initializing the base class with non-initialized values.
-
virtual string printTabularString(int week) override
Generates an empty tabular string representation for a given week. This function is a placeholder implementation for data collectors that do not manage data.
This function is overrides the pure virtual function in the base class.
- Parameters:
week – Integer representing the week for which the tabular data is being generated.
- Returns:
An empty string as no data is managed by this collector.
-
virtual string printCompactString(int week) override
Generates an empty comma-delimited string representation for a given week. This function is a placeholder implementation for data collectors that do not manage data.
This function is overrides the pure virtual function in the base class.
- Parameters:
week – Integer representing the week for which the tabular data is being generated.
- Returns:
An empty string as no data is managed by this collector.
-
virtual string printTabularStringHeaderLine1() override
Generates an empty string representation for the first header line. This function is a placeholder implementation for data collectors that do not manage data.
This function is overrides the pure virtual function in the base class.
- Returns:
An empty string as no data is managed by this collector.
-
virtual string printTabularStringHeaderLine2() override
Generates an empty string representation for the first header line. This function is a placeholder implementation for data collectors that do not manage data.
This function is overrides the pure virtual function in the base class.
- Returns:
An empty string as no data is managed by this collector.
-
virtual string printCompactStringHeader() override
Generates an empty string representation for the first header line. This function is a placeholder implementation for data collectors that do not manage data.
This function is overrides the pure virtual function in the base class.
- Returns:
An empty string as no data is managed by this collector.
-
virtual void collect_data() override
A placeholder implementation for data collection. This function does nothing, as the EmptyDataCollector does not manage or collect any data.
- Returns:
void
-
EmptyDataCollector()
IntakeDataCollector.h
-
class IntakeDataCollector : public DataCollector
- #include <IntakeDataCollector.h>
The
IntakeDataCollector
class is a subclass of theDataCollector
class that implements the data collection of intake objects.Created by bernardoct on 8/26/17.
Public Functions
-
IntakeDataCollector(Intake *intake, unsigned long realization)
Constructs an IntakeDataCollector for managing and collecting data from an Intake. This function initializes the data collector with specific attributes for intakes.
- Parameters:
intake – Pointer to the Intake object that this collector will manage.
realization – Unsigned long integer representing the realization (scenario or simulation ID).
-
virtual string printTabularString(int week) override
Generates a tabular string representation of intake data for a given week. This includes demand, upstream inflows, wastewater inflows, catchment inflows, and outflows. Each of these values is separated by a column with a fixed width.
This function overrides the virtual function in the DataCollector class.
- Parameters:
week – Integer representing the week for which the tabular data is being generated.
- Returns:
A string containing the tabular representation of the intake data for the specified week.
-
virtual string printCompactString(int week) override
Generates a compact string representation of intake data for a given week. This includes demand, upstream inflows, wastewater inflows, catchment inflows, and outflows in a compact format. Each of these values is separated by a column.
This function overrides the virtual function in the DataCollector class.
- Parameters:
week – Integer representing the week for which the compact data is being generated.
- Returns:
A string containing the compact representation of the intake data for the specified week.
-
virtual string printTabularStringHeaderLine1() override
Generates the first header line for a tabular representation of intake data. This line includes column headers for upstream, wastewater, and catchment inflows, separated into columns with a fixed width.
This function overrides the virtual function in the DataCollector class.
- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printTabularStringHeaderLine2() override
Generates the second header line for a tabular representation of intake data. This line includes detailed column headers for demands, spillage, inflows, and outflows, separated into columns with a fixed width.
This function overrides the virtual function in the DataCollector class.
- Returns:
A string containing the second header line for the tabular representation.
-
virtual string printCompactStringHeader() override
Generates a compact string header for the intake data. This header includes column identifiers for demand, upstream spillage, wastewater inflow, catchment inflow, and downstream spillage, in a comma-delimited format.
This function overrides the virtual function in the DataCollector class.
- Returns:
A string containing the compact header representation for the intake data.
-
virtual void collect_data() override
Collects data for the intake, including demand, wasterwater and catchment inflows, as well as total outflows. This function stores the intake’s weekly data into corresponding data structures.
This function overrides the virtual function in the DataCollector class.
- Returns:
void
Private Members
-
Intake *intake
The intake object associated with this DataCollector.
-
vector<double> total_upstream_sources_inflows
A vector with the total inflows from all upstream sources.
-
vector<double> demands
A vector with the total demands from utilities.
-
vector<double> wastewater_inflows
A vector with the total inflows from wastewater treatment plants.
-
vector<double> outflows
A vector with the total outflows from the intake.
-
vector<double> total_catchments_inflow
A vector with the total inflows from all upstream catchments.
-
IntakeDataCollector(Intake *intake, unsigned long realization)
JointWTPDataCollector.h
-
class JointWTPDataCollector : public DataCollector
- #include <JointWTPDataCollector.h>
The
JointWTPDataCollector
class is a subclass of theDataCollector
class that implements the data collection of joint WTP objects.Created by dgorelic on 11/4/2019.
Public Functions
-
explicit JointWTPDataCollector(JointWTP *joint_wtp, unsigned long realization)
Constructs a JointWTPDataCollector for managing and collecting data from a Joint Water Treatment Plant (WTP). This function initializes the data collector with specific attributes for a Joint WTP.
- Parameters:
joint_wtp – Pointer to the JointWTP object that this collector will manage.
realization – Unsigned long integer representing the realization (scenario or simulation ID).
-
virtual string printTabularString(int week) override
Generates a tabular string representation of the Joint WTP data for a given week. This includes allocated treatment capacities for each utility partner with a treatment allocation to the Joint WTP, formatted in columns.
This function overrides the DataCollector::printTabularString() function.
- Parameters:
week – Integer representing the week for which the tabular data is being generated.
- Returns:
A string containing the tabular representation of the allocated treatment capacities for the specified week.
-
virtual string printCompactString(int week) override
Generates a comma, delimited compact string representation of the Joint WTP data for a given week. This includes allocated treatment capacities for each utility partner with a treatment allocation to the Joint WTP.
This function overrides the DataCollector::printCompactString() function.
- Parameters:
week – Integer representing the week for which the compact data is being generated.
- Returns:
A string containing the compact representation of the allocated treatment capacities for the specified week.
-
virtual string printTabularStringHeaderLine1() override
Generates the first header line for a tabular representation of Joint WTP data. This line includes column headers for treatment capacities of utility partners.
This function overrides the DataCollector::printTabularStringHeaderLine1() function.
- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printTabularStringHeaderLine2() override
Generates the second header line for a tabular representation of Joint WTP data. This line includes column headers for treatment allocations of utility partners.
This function overrides the DataCollector::printTabularStringHeaderLine2() function.
- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printCompactStringHeader() override
Generates a compact string header, in a comma-delimited format, for the Joint WTP data. This header includes column identifiers for allocated treatment capacities of utility partners.
This function overrides the DataCollector::printCompactStringHeader() function.
- Returns:
A string containing the compact header representation for the Joint WTP data.
-
virtual void collect_data() override
Collects data for the Joint WTP, specifically the allocated treatment capacities for utility partners. This function stores the treatment capacity data for the current week.
This function overrides the DataCollector::collect_data() function.
- Returns:
void
-
explicit JointWTPDataCollector(JointWTP *joint_wtp, unsigned long realization)
MasterDataCollector.h
-
class MasterDataCollector
- #include <MasterDataCollector.h>
The
MasterDataCollector
class implements the data collection of all WaterSource, Utility, and Bond objects across multiple hydroclimatic realizations.Public Functions
-
MasterDataCollector(vector<unsigned long> &realizations_to_run)
Constructs a MasterDataCollector to manage and collect data across multiple realizations. Initializes the number of realizations and the list of realizations to run.
- Parameters:
realizations_to_run – A reference to a vector of unsigned long integers representing the realizations to be run.
-
virtual ~MasterDataCollector()
Destroys the MasterDataCollector, cleaning up all dynamically allocated DataCollector and UtilitiesDataCollector objects.
-
int printNETCDFUtilities(string base_file_name)
Writes utility data collected during the simulation into a NetCDF file. The data includes variables such as storage, risk of failure, demands, and payments for each utility across all realizations.
FIXME: NetCDF file being saved with hardly any compression. Someone who knows more about NetCDF may be able to improve compression, which would be great given the amount of output that can be generated in one run.
- Parameters:
base_file_name – The base name for the NetCDF file to be created.
- Throws:
NcException – If a NetCDF operation fails, an exception is thrown with error details.
- Returns:
An integer representing the status of the operation:
0
if the file is successfully written.NC_ERR
if an error occurs during the NetCDF operations.1
if NetCDF is not enabled in this build.
-
vector<double> calculatePrintObjectives(string file_name, bool print)
-
void printPoliciesOutputCompact(int week_i, int week_f, string file_name)
Prints the output of drought mitigation policies in a compact CSV format for a specified time range. This function generates separate CSV files for each realization.
- Parameters:
week_i – Integer representing the starting week of the time range.
week_f – Integer representing the ending week of the time range.
file_name – String specifying the base name for the output files.
- Returns:
void
-
void printPoliciesOutputTabular(int week_i, int week_f, string file_name)
Prints the output of drought mitigation policies in a tabular format for a specified time range. This function generates separate
.tab
files for each realization.See also
DataCollector::printTabularString, DataCollector::printTabularStringHeaderLine1, DataCollector::printTabularStringHeaderLine2
- Parameters:
week_i – Integer representing the starting week of the time range.
week_f – Integer representing the ending week of the time range.
file_name – String specifying the base name for the output files.
- Returns:
void
-
void printUtilitiesOutputCompact(int week_i, int week_f, string file_name)
Prints the output of utility data in a compact CSV format for a specified time range. This function generates separate CSV files for each realization.
See also
UtilitiesDataCollector::printCompactString, UtilitiesDataCollector::printCompactStringHeader
- Parameters:
week_i – Integer representing the starting week of the time range.
week_f – Integer representing the ending week of the time range.
file_name – String specifying the base name for the output files.
- Returns:
void
-
void printUtilitesOutputTabular(int week_i, int week_f, string file_name)
Prints the output of utility data in a tabular format for a specified time range. This function generates separate
.tab
files for each realization.See also
UtilitiesDataCollector::printTabularString, UtilitiesDataCollector::printTabularStringHeaderLine1, UtilitiesDataCollector::printTabularStringHeaderLine2
- Parameters:
week_i – Integer representing the starting week of the time range.
week_f – Integer representing the ending week of the time range.
file_name – String specifying the base name for the output files.
- Returns:
void
-
void printWaterSourcesOutputCompact(int week_i, int week_f, string file_name)
Prints the output of water source data in a compact CSV format for a specified time range. This function generates separate CSV files for each realization.
- Parameters:
week_i – Integer representing the starting week of the time range.
week_f – Integer representing the ending week of the time range.
file_name – String specifying the base name for the output files.
- Throws:
A – warning is printed and the specific realization’s data is skipped.
- Returns:
void
-
void printWaterSourcesOutputTabular(int week_i, int week_f, string file_name)
Prints the output of water source data in a tabular format for a specified time range. This function generates separate
.tab
files for each realization.See also
DataCollector::printTabularString, DataCollector::printTabularStringHeaderLine1, DataCollector::printTabularStringHeaderLine2
- Parameters:
week_i – Integer representing the starting week of the time range.
week_f – Integer representing the ending week of the time range.
file_name – String specifying the base name for the output files.
- Returns:
void
-
void setOutputDirectory(string io_directory, string sub_directory)
Sets the output directory for storing generated output files. If the specified directory differs from the current one, it creates the directory and updates the output location.
- Parameters:
io_directory – String representing the base directory for output files.
sub_directory – String specifying the sub-directory to append to the base directory.
- Returns:
void
-
void printPathways(string file_name)
Prints the infrastructure pathways for each utility and realization into an output file. The output includes a text file with tab-separate columns showing data on the realization ID, utility ID, week, and infrastructure ID.
- Parameters:
file_name – String specifying the base name for the output file.
- Returns:
void
-
void addRealization(vector<WaterSource*> water_sources_realization, vector<DroughtMitigationPolicy*> drought_mitigation_policies_realization, vector<Utility*> utilities_realization, unsigned long r)
Adds data collectors for a new realization, initializing data structures and creating collectors for water sources, drought mitigation policies, and utilities.
- Parameters:
water_sources_realization – Vector of pointers to
WaterSource
objects for the realization.drought_mitigation_policies_realization – Vector of pointers to
DroughtMitigationPolicy
objects for the realization.utilities_realization – Vector of pointers to
Utility
objects for the realization.r – Unsigned long integer representing the realization ID.
- Returns:
void
-
void removeRealization(unsigned long r)
Removes a specified realization, deallocating associated data collectors and updating tracking structures.
- Parameters:
r – Unsigned long integer representing the realization ID to be removed.
- Returns:
void
-
void cleanCollectorsOfDeletedRealizations()
Cleans up data collector vectors by removing entries corresponding to deleted realizations. This ensures that no
nullptr
entries remain in the data collector structures.- Returns:
void
-
void collectData(unsigned long r)
Collects data for a specified realization
r
by invoking thecollect_data
method on all associated data collectors.See also
- Parameters:
r – Unsigned long integer representing the realization ID for which data will be collected.
- Returns:
void
-
void performBootstrapAnalysis(int sol_id, int n_sets, int n_samples, int n_threads, vector<vector<int>> bootstrap_samples = vector<vector<int>>())
Performs a bootstrap analysis to generate statistical samples for objectives based on multiple sets of realizations.
See also
- Parameters:
sol_id – Integer representing the solution ID for which the bootstrap analysis is conducted.
n_sets – Integer specifying the number of bootstrap sample sets to generate.
n_samples – Integer specifying the number of samples per bootstrap set.
n_threads – Integer representing the number of threads to use for parallelization.
bootstrap_samples – Vector of vectors containing pre-defined bootstrap samples, if available. Otherwise, new samples will be generated.
- Returns:
void
-
DataCollector *createPolicyDataCollector(DroughtMitigationPolicy *dmp, unsigned long r)
Creates and returns a data collector for a specified drought mitigation policy based on its type.
- Parameters:
dmp – Pointer to the
DroughtMitigationPolicy
object for which a data collector is to be created.r – Unsigned long integer representing the realization ID.
- Throws:
std::invalid_argument – If the policy type is not recognized or not handled in the implementation.
- Returns:
A pointer to the newly created
DataCollector
object corresponding to the given policy.
-
DataCollector *createWaterSourceDataCollector(WaterSource *ws, unsigned long r)
Creates and returns a data collector for a specified water source based on its type.
- Parameters:
ws – Pointer to the
WaterSource
object for which a data collector is to be created.r – Unsigned long integer representing the realization ID.
- Throws:
std::invalid_argument – If the water source type is not recognized or not handled in the implementation.
- Returns:
A pointer to the newly created
DataCollector
object corresponding to the given water source.
-
void printUtilityObjectivesToRowOutStream(vector<UtilitiesDataCollector*> &u, std::ofstream &outStream, vector<double> &objectives)
Calculates and writes utility objectives to a row in an output stream and appends the results to the objectives vector.
- Parameters:
u – Reference to a vector of
UtilitiesDataCollector *
representing the utility data collectors for the realization.outStream – Reference to the
std::ofstream
where the objectives will be written.objectives – Reference to a vector of doubles where the calculated objectives will be appended.
- Returns:
void
-
void readOrCreateBSSamples(int sol_id, int n_sets, int n_samples, const vector<vector<int>> &bootstrap_samples, vector<vector<int>> &bootstrap_sample_sets) const
Performs a bootstrap analysis to compute statistical objectives based on multiple sets of realizations and writes results to output files.
See also
readOrCreateBSSamples, isolateRestrictionDataCollectors, printObjsBSSamples, printBSSamples, printObjectivesOfAllRealizationsForBSAnalysis
- Parameters:
sol_id – Integer representing the solution ID for which the bootstrap analysis is conducted.
n_sets – Integer specifying the number of bootstrap sample sets to generate.
n_samples – Integer specifying the number of samples per bootstrap set.
n_threads – Integer representing the number of threads to use for parallelization.
bootstrap_samples – Vector of vectors containing pre-defined bootstrap samples. If empty, new samples will be generated.
- Returns:
void
-
void printObjsBSSamples(int sol_id, int n_sets, int n_samples, vector<vector<double>> &objectives)
Prints the calculated objectives for bootstrap samples to a CSV file. Each row represents the objectives for a specific bootstrap set.
- Parameters:
sol_id – Integer representing the solution ID for which the objectives are being printed.
n_sets – Integer specifying the number of bootstrap sample sets.
n_samples – Integer specifying the number of samples per bootstrap set.
objectives – Reference to a vector of vectors containing the calculated objectives for each bootstrap set.
- Returns:
void
-
void printObjectivesOfAllRealizationsForBSAnalysis(int sol_id, int n_sets, int n_samples)
-
void printBSSamples(int sol_id, int n_sets, int n_samples, const vector<vector<int>> &bootstrap_sample_sets) const
-
void isolateRestrictionDataCollectors(vector<UtilitiesDataCollector*> &u, vector<RestrictionsDataCollector*> &utility_restrictions) const
-
int getRealizations_created() const
Private Members
-
string output_directory
The output directory where the data will be saved.
-
unsigned long n_realizations
The number of realizations for which data will be collected.
-
vector<vector<DataCollector*>> water_source_collectors
A 2D vector of DataCollector objects that store the data collected for all water sources in across all realizations.
-
vector<vector<DataCollector*>> drought_mitigation_policy_collectors
A 2D vector of DataCollector objects that store the data collected for all drought mitigation policies in across all realizations.
-
vector<vector<UtilitiesDataCollector*>> utility_collectors
A 2D vector of UtilitiesDataCollector objects that store the data collected for all utilities in across all realizations.
-
vector<unsigned long> crashed_realizations
A vector of the IDs of realizations that have crashed.
-
vector<unsigned long> realizations_ran
A vector of the IDs of realizations that have been successfully run.
-
int realizations_created = 0
The number of realizations that have been created.
Private Static Attributes
-
static int seed
The seed used for the random number generator.
-
MasterDataCollector(vector<unsigned long> &realizations_to_run)
QuaryDataCollector.h
-
class QuaryDataCollector : public ReservoirDataCollector
- #include <QuaryDataCollector.h>
The
QuaryDataCollector
class is a subclass of theReservoirDataCollector
class, which in turn is a subclass of the mainDataCollector
class. It implements the data collection of quarry objects. FIXME: Needs to be renamed toQuarryDataCollector
.Created by bernardoct on 8/26/17.
ReservoirDataCollector.h
-
class ReservoirDataCollector : public DataCollector
- #include <ReservoirDataCollector.h>
The
ReservoirDataCollector
class is a subclass of theDataCollector
class that implements the data collection of Reservoir objects.Created by bernardoct on 8/25/17.
Subclassed by AllocatedReservoirDataCollector, QuaryDataCollector
Public Functions
-
explicit ReservoirDataCollector(Reservoir *reservoir, unsigned long realization)
Constructs a ReservoirDataCollector for managing and collecting data from a Reservoir. This function initializes the data collector with specific attributes for a Reservoir.
- Parameters:
reservoir – Pointer to the Reservoir object that this collector will manage.
realization – Unsigned long integer representing the realization (scenario or simulation ID).
-
explicit ReservoirDataCollector(Reservoir *reservoir, int type, int table_width, unsigned long realization)
Constructs a ReservoirDataCollector instance.
This constructor initializes the ReservoirDataCollector object by associating it with a specified reservoir and configuring its data collection parameters such as type, table width, and realization.
- Parameters:
reservoir – Pointer to the Reservoir object whose data is being collected.
type – Integer representing the type of data collection.
table_width – Integer specifying the width of the data table.
realization – Unsigned long integer representing the realization or simulation instance.
-
virtual string printTabularString(int week) override
Generates a tabular string representation of reservoir data for a given week. This function formats and returns reservoir data values as a tab-separated string.
- Parameters:
week – The week index for which the data is to be printed.
- Returns:
A string containing the formatted reservoir data for the specified week.
-
virtual string printCompactString(int week) override
Generates a compact, comma-delimited string representation of reservoir data for a specified week.
This function overrides the
printCompactString
function in theDataCollector
class.- Parameters:
week – Integer representing the week for which the compact data is generated.
- Returns:
A string containing the compact representation of the demand offsets for the specified week.
-
virtual string printTabularStringHeaderLine1() override
Generates the first header line for the tabular representation of reservoir data.
This function overrides the
printTabularStringHeaderLine1
function in theDataCollector
class.- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printTabularStringHeaderLine2() override
Generates the second header line for the tabular representation of reservoir data.
This function overrides the
printTabularStringHeaderLine2
function in theDataCollector
class.- Returns:
A string containing the second header line for the tabular representation.
-
virtual string printCompactStringHeader() override
Generates a compact, comma-delimited string header for the reservoir data.
This function overrides the
printCompactStringHeader
function in theDataCollector
class.- Returns:
A string containing the compact header representation for the reservoir data.
-
virtual void collect_data() override
Collects the reservoir data for the current week.
This function overrides the
collect_data
function in theDataCollector
class.- Returns:
void
Private Members
-
vector<double> stored_volume
The total stored volume in the reservoir across all weeks.
-
vector<double> total_upstream_sources_inflows
The total upstream inflows to the reservoir across all weeks.
-
vector<double> wastewater_inflows
The total waterwater inflows to the reservoir across all weeks.
-
vector<double> demands
The total demands from the reservoir across all weeks.
-
vector<double> outflows
The total outflow, including spill, from the reservoir across all weeks.
-
vector<double> total_catchments_inflow
The total inflow from catchments to the reservoir across all weeks.
-
vector<double> evaporated_volume
The total evaporation from the reservoir across all weeks.
-
vector<double> area
The total surface area of the reservoir across all weeks.
-
bool fixed_area
A boolean flag indicating if the reservoir has a fixed area.
-
double fixed_area_value
The fixed surface area of the reservoir.
-
explicit ReservoirDataCollector(Reservoir *reservoir, unsigned long realization)
RestrictionsDataCollector.h
-
class RestrictionsDataCollector : public DataCollector
- #include <RestrictionsDataCollector.h>
The
RestrictionsDataCollector
class is a subclass of theDataCollector
class that implements the data collection of water use restrictions.Created by bernardoct on 8/25/17.
Public Functions
-
explicit RestrictionsDataCollector(Restrictions *restriction_policy, unsigned long realization)
Constructs a
RestrictionsDataCollector
object to collect data related to a specific restriction policy. Initializes the baseDataCollector
with relevant identifiers and type information.- Parameters:
restriction_policy – A pointer to the
Restrictions
object representing the restriction policy.realization – The realization index associated with the restriction policy.
-
virtual string printTabularString(int week) override
Generates a tabular string representation of water restriction multipliers.
This function overrides the
printTabularString
function in theDataCollector
class.- Parameters:
week – Integer representing the week for which the tabular data is generated.
- Returns:
A string containing the tabular representation of the demand offsets for the specified week.
-
virtual string printCompactString(int week) override
Generates a compact, comma-delimited string representation of restriction multipliers for a specified week.
This function overrides the
printCompactString
function in theDataCollector
class.- Parameters:
week – Integer representing the week for which the compact data is generated.
- Returns:
A string containing the compact representation of the demand offsets for the specified week.
-
virtual string printTabularStringHeaderLine1() override
Generates the first header line for the tabular representation of restriction multipliers.
This function overrides the
printTabularStringHeaderLine1
function in theDataCollector
class.- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printTabularStringHeaderLine2() override
Generates the second header line for the tabular representation of restriction multipliers.
This function overrides the
printTabularStringHeaderLine2
function in theDataCollector
class.- Returns:
A string containing the second header line for the tabular representation.
-
virtual string printCompactStringHeader() override
Generates a compact, comma-delimited string header for the water restriction multipliers.
This function overrides the
printCompactStringHeader
function in theDataCollector
class.- Returns:
A string containing the compact header representation for the water restriction multipliers.
-
virtual void collect_data() override
Collects the current restriction multiplier from the associated restriction policy.
This function overrides the
collect_data
function in theDataCollector
class.- Returns:
void
-
const vector<double> &getRestriction_multipliers() const
Retrieves the vector of collected restriction multipliers.
- Returns:
A constant reference to the
vector<double>
containing the collected restriction multipliers.
Private Members
-
Restrictions *restriction_policy
A pointer to the restrictions policy associated with the data collector.
-
vector<double> restriction_multipliers
The DU factor multipliers applied to scale the effectiveness of water use restrictions for each week.
-
explicit RestrictionsDataCollector(Restrictions *restriction_policy, unsigned long realization)
TransfersDataCollector.h
-
class TransfersDataCollector : public DataCollector
- #include <TransfersDataCollector.h>
The
TransfersDataCollector
class is a subclass of theDataCollector
class that implements the data collection of treated water transfers.Created by bernardoct on 8/25/17.
Public Functions
-
TransfersDataCollector(Transfers *transfer_policy, unsigned long realization)
Constructs a
TransfersDataCollector
for managing and collecting data related to a transfer policy. Initializes the data collector with the policy’s attributes and associated utilities.- Parameters:
transfer_policy – Pointer to the
Transfers
object representing the transfer policy.realization – Unsigned long integer representing the realization ID.
-
virtual string printTabularString(int week) override
Generates a tabular string representation of demand offsets for a specified week. This representation includes the demand offset values for all utilities involved in the transfer policy.
This function overrides the
printTabularString
function in theDataCollector
class.- Parameters:
week – Integer representing the week for which the tabular data is generated.
- Returns:
A string containing the tabular representation of the demand offsets for the specified week.
-
virtual string printCompactString(int week) override
Generates a compact, comma-delimited string representation of demand offsets for a specified week. This representation includes the demand offset values for all utilities involved in the transfer policy, separated by commas.
This function overrides the
printCompactString
function in theDataCollector
class.- Parameters:
week – Integer representing the week for which the compact data is generated.
- Returns:
A string containing the compact representation of the demand offsets for the specified week.
-
virtual string printTabularStringHeaderLine1() override
Generates the first header line for the tabular representation of transfer allocation data. This line includes repeated column headers for the transfer demand offsets for each utility involved in the transfer policy.
This function overrides the
printTabularStringHeaderLine1
function in theDataCollector
class.- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printTabularStringHeaderLine2() override
Generates the second header line for the tabular representation of transfer allocation data. This line includes repeated column headers for the transfer demand offsets for each utility involved in the transfer policy.
This function overrides the
printTabularStringHeaderLine2
function in theDataCollector
class.- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printCompactStringHeader() override
Generates a compact, comma-delimited string header for the transfer data. This header includes identifiers for the transfer demand offsets for each utility involved in the transfer policy.
This function overrides the
printCompactStringHeader
function in theDataCollector
class.- Returns:
A string containing the compact header representation for the transfer data.
-
virtual void collect_data() override
Collects the demand offset data for the current week from the transfer policy and appends it to the
demand_offsets
vector.This function overrides the
collect_data
function in theDataCollector
class.- Returns:
void
-
TransfersDataCollector(Transfers *transfer_policy, unsigned long realization)
UtilitiesDataCollector.h
-
class UtilitiesDataCollector : public DataCollector
- #include <UtilitiesDataCollector.h>
The
UtilitiesDataCollector
class is a subclass of theDataCollector
class that implements the data collection of Utility objects. It is the main subclass that results in the Utilities’ output CSV files.Created by bernardoct on 8/25/17.
Public Functions
-
explicit UtilitiesDataCollector(const Utility *utility, unsigned long realization)
Constructs a
UtilitiesDataCollector
for managing and collecting data related to a specific utility. Initializes the data collector with utility-specific attributes.- Parameters:
utility – Pointer to the
Utility
object for which the data collector is being created.realization – Unsigned long integer representing the realization ID.
-
UtilitiesDataCollector &operator=(const UtilitiesDataCollector &utility_data_collector)
Overloads the assignment operator for the
UtilitiesDataCollector
class, allowing assignment of one data collector to another. This operator performs a deep copy of the data collector’s attributes.This function does not have an implementation in the .cpp file.
- Parameters:
utility_data_collector – A constant reference to the
UtilitiesDataCollector
object to be assigned.- Returns:
A reference to the updated
UtilitiesDataCollector
object after the assignment.
-
virtual string printTabularString(int week) override
Generates a tabular string representation of utility data for a specified week. This includes data such as combined storage, capacity, net inflow, ROFs, demand, insurance, contingency funds, debt service payments, and revenues.
This function overrides the
printTabularString
function in theDataCollector
class.- Parameters:
week – Integer representing the week for which the tabular data is generated.
- Returns:
A string containing the tabular representation of the utility data for the specified week.
-
virtual string printCompactString(int week) override
Generates a compact, comma-delimited representation of utility data for a specified week. This includes data such as combined storage, capacity, net inflow, ROFs, demand, insurance, contingency funds, debt service payments, and revenues.
This function overrides the
printCompactString
function in theDataCollector
class.- Parameters:
week – Integer representing the week for which the tabular data is generated.
- Returns:
A string containing the compact representation of the utility data for the specified week.
-
virtual string printTabularStringHeaderLine1() override
Generates the first header line for the tabular representation of utility data. This header provides general column titles for data such as combined storage, capacity, net inflow, ROFs, demand, insurance, contingency funds, debt service payments, and revenues.
This function overrides the
printTabularStringHeaderLine1
function in theDataCollector
class.- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printTabularStringHeaderLine2() override
Generates the second header line for the tabular representation of utility data. This header provides general column titles for data such as combined storage, capacity, net inflow, ROFs, demand, insurance, contingency funds, debt service payments, and revenues.
This function overrides the
printTabularStringHeaderLine2
function in theDataCollector
class.- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printCompactStringHeader() override
Generates the header line for the compact, comma-delimited representation of utility data. This header provides general column titles for data such as combined storage, capacity, net inflow, ROFs, demand, insurance, contingency funds, debt service payments, and revenues.
This function overrides the
printCompactStringHeader
function in theDataCollector
class.- Returns:
A string containing the header line for the compact, comma-delimited representation.
-
virtual void collect_data() override
Collects data for the utility and appends it to the respective data vectors. This includes combined storage, capacity, net inflow, ROFs, demand, insurance, contingency funds, debt service payments, revenues, and infrastructure net present costs.
This function overrides the
collect_data
function in theDataCollector
class.- Returns:
void
-
const vector<double> &getCombined_storage() const
Retrieves the vector of combined storage data collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the combined storage data for the utility.
-
const vector<double> &getCapacity() const
Retrieves the vector of storage capacity data collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the storage capacity data for the utility.
-
const vector<double> &getGross_revenues() const
Retrieves the vector of gross revenue data collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the gross revenue data for the utility.
-
const vector<double> &getContingency_fund_contribution() const
Retrieves the vector of contingency fund contribution data collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the contingency fund contribution data for the utility.
-
const vector<double> &getDebt_service_payments() const
Retrieves the vector of weekly debt service payments collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the weekly debt service payments made by the utility.
-
const vector<double> &getInsurance_contract_cost() const
Retrieves the vector of weekly insurance contract costs paid by the utility collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the weekly insurance contract costs paid by the utility.
-
const vector<double> &getDrought_mitigation_cost() const
Retrieves the vector of drought mitigation costs paid by the utility collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the contingency fund contribution data for the utility.
-
const vector<double> &getContingency_fund_size() const
Retrieves the vector of a utility’s net contingency fund sizes as it changes across all weeks collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the contingency fund size data for the utility.
-
const vector<vector<int>> &getPathways() const
Retrieves the 2D vector of infrastructure pathways (infrastructure IDs and their associated realizations) build by the utility.
- Returns:
A constant reference to a 2D vector of integers a utility’s infrastructure pathways.
-
const vector<double> &getNet_present_infrastructure_cost() const
Retrieves the vector of a utility’s weekly net infrastructure net present cost collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the utility’s infrastructure net present cost.
-
const vector<double> &getSt_rof() const
Retrieves the vector of a utility’s weekly short-term ROF collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the utility’s short-term ROF.
-
const vector<double> &getLt_rof() const
Retrieves the vector of a utility’s weekly long-term ROF collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the utility’s long-term ROF.
-
const vector<double> &getRestricted_demand() const
Retrieves the vector of a utility’s weekly volumetric restricted demand collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the utility’s weekly restricted demand.
-
const vector<double> &getUnrestricted_demand() const
Retrieves the vector of a utility’s weekly volumetric unrestricted demand collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the utility’s weekly unrestricted demand.
-
const vector<double> &getRecorded_annual_demand() const
Retrieves the vector of a utility’s recorded (historical) annual demand collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the utility’s weekly restricted demand.
-
const vector<double> &getPresent_value_debt_service_payments() const
Retrieves the vector of the present value of a utility’s weekly debt service payments collected by the
UtilitiesDataCollector
.- Returns:
A constant reference to a vector of doubles containing the utility’s weekly restricted demand.
-
void checkForNans() const
Checks for
NaN
values in the most recent data entries collected by theUtilitiesDataCollector
. Throws a runtime error if anyNaN
value is detected.- Throws:
std::runtime_error – If a
NaN
value is detected in any of the data fields for the utility. Additionally, logs a warning if the net present infrastructure cost exceeds an absurdly high threshold.- Returns:
void
Private Members
-
vector<double> st_rof
A vector of weekly short-term ROFs for a utility taken as the max between the storage and treatment short-term ROFs.
-
vector<double> st_stor_rof
A vector of weekly short-term storage ROFs for a utility.
-
vector<double> st_trmt_rof
A vector of weekly short-term treatment ROFs for a utility.
-
vector<double> lt_rof
A vector of weekly long-term ROFs for a utility taken as the max between the storage and treatment long-term ROFs.
-
vector<double> lt_stor_rof
A vector of weekly long-term storage ROFs for a utility.
-
vector<double> lt_trmt_rof
A vector of weekly long-term treatment ROFs for a utility.
-
vector<double> combined_storage
A vector of weekly combined storage for a utility.
-
vector<double> unrestricted_demand
A vector of weekly unrestricted demand for a utility.
-
vector<double> restricted_demand
A vector of weekly restricted demand for a utility.
-
vector<double> contingency_fund_size
A vector of weekly cumulative contingency fund sizes for a utility.
-
vector<double> gross_revenues
A vector of weekly gross revenues for a utility.
-
vector<double> contingency_fund_contribution
A vector of weekly contingency fund contributions for a utility.
-
vector<double> debt_service_payments
A vector of weekly debt service payments for a utility.
-
vector<double> present_valued_debt_service_payments
A vector of weekly present-valued debt service payments for a utility.
-
vector<double> insurance_contract_cost
A vector of weekly insurance contract costs for a utility.
-
vector<double> insurance_payout
A vector of weekly insurance payouts received by a utility from the insurance company.
-
vector<double> drought_mitigation_cost
A vector of weekly drought mitigation costs for a utility.
-
vector<double> capacity
A vector of weekly net present infrastructure costs for a utility.
-
vector<double> net_present_infrastructure_cost
A vector of weekly net present infrastructure costs for a utility.
-
vector<double> waste_water_discharge
A vector of weekly waste water discharge for a utility.
-
vector<double> unfulfilled_demand
A vector of weekly unfulfilled demand for a utility.
-
vector<double> net_stream_inflow
A vector of weekly net stream inflow for a utility.
-
vector<double> total_treatment_capacity
A vector of weekly total treatment capacity for a utility.
-
vector<double> final_stored_volume
A vector of weekly final stored volume for a utility across all its water sources.
-
vector<double> recorded_annual_demand
A vector of weekly recorded annual demand for a utility. This value stays constant for all weeks within the same year.
-
vector<double> projected_demand_estimate
A vector of annual projected demand estimates for a utility.
-
vector<vector<int>> pathways
A 2D vector of infrastructure pathways for a utility.
-
explicit UtilitiesDataCollector(const Utility *utility, unsigned long realization)
WaterReuseDataCollector.h
-
class WaterReuseDataCollector : public DataCollector
- #include <WaterReuseDataCollector.h>
The
WaterReuseDataCollector
class is a subclass of theDataCollector
class that implements the data collection of WaterSource objects. It is the main subclass that results in the WaterSource’s output CSV files.Created by bernardoct on 8/26/17.
Public Functions
-
WaterReuseDataCollector(WaterReuse *water_reuse, unsigned long realization)
Constructs a
WaterReuseDataCollector
for managing and collecting data related to water reuse. Initializes the data collector with water reuse-specific attributes.- Parameters:
water_reuse – Pointer to the
WaterReuse
object representing the water reuse entity.realization – Unsigned long integer representing the realization ID.
-
virtual string printTabularString(int week) override
Generates a tabular string representation of the reused water volume for a specified week.
This function overrides the
printTabularString
function in theDataCollector
class.- Parameters:
week – Integer representing the week for which the reused volume data is generated.
- Returns:
A string containing the tabular representation of the reused water volume for the specified week.
-
virtual string printCompactString(int week) override
Generates a compact, comma-delimited string representation of the reused water volume for a specified week.
This function overrides the
printCompactString
function in theDataCollector
class.- Parameters:
week – Integer representing the week for which the reused volume data is generated.
- Returns:
A string containing the compact, comma-delimited representation of the reused water volume for the specified week.
-
virtual string printTabularStringHeaderLine1() override
Generates the first header line for the tabular representation of water reuse data. This header provides a title for the reused water volume column.
This function overrides the
printTabularStringHeaderLine1
function in theDataCollector
class.- Returns:
A string containing the first header line for the tabular representation.
-
virtual string printTabularStringHeaderLine2() override
Generates the second header line for the tabular representation of water reuse data. This header provides a title for the reused water volume column.
This function overrides the
printTabularStringHeaderLine2
function in theDataCollector
class.- Returns:
A string containing the second header line for the tabular representation.
-
virtual string printCompactStringHeader() override
Generates the compact, comma-delimited header line for the tabular representation of water reuse data. This header provides a title for the reused water volume column.
This function overrides the
printCompactStringHeader
function in theDataCollector
class.- Returns:
A string containing the header line for the compact, comma-delimited representation.
-
virtual void collect_data() override
Collects the data for the DataCollector object.
This function does not have an implementation in the DataCollector class and must be implemented by derived classes.
- Returns:
void
Private Members
-
WaterReuse *water_reuse
Pointer to the WaterReuse object from which data will be collected.
-
double reused_volume
Volume of water reused.
-
WaterReuseDataCollector(WaterReuse *water_reuse, unsigned long realization)