In the case where a utility has (a) projects triggered by both ROF and demand and (b) the number of ROF-triggered projects differs than the number of demand-triggered projects, this routine will always throw an error.
Suggested solution: the function argument infra_construction_triggers is passed from the Utility constructor. If ROF project triggers are always placed first in this vector when a utility object is created in the Problem class, followed by demand triggers, the process to build a standard infra_construction_triggers_new within the rearrangeInfraRofVector function can be changed, replacing lines 146-161 of InfrastructureManager.cpp of the master to:
vector<double> infra_construction_triggers_new((unsigned long) size, 1e10);
for (unsigned long i = 0; i < infra_construction_triggers.size(); ++i) {
// first, check ROF triggers
if (i < rof_infra_construction_order.size()) {
auto ws = (unsigned long) rof_infra_construction_order.at(i);
infra_construction_triggers_new.at(ws) = infra_construction_triggers.at(i);
} else { // next, follow with demand triggers
auto ws = (unsigned long) demand_infra_construction_order.at(i-rof_infra_construction_order.size());
if (infra_construction_triggers_new.at(ws) != 1e10)
throw invalid_argument("A source can be triggered only by "
"either rof or by demand.");
infra_construction_triggers_new.at(ws) = infra_construction_triggers.at(i);
}
}
In the case where a utility has (a) projects triggered by both ROF and demand and (b) the number of ROF-triggered projects differs than the number of demand-triggered projects, this routine will always throw an error.
Suggested solution: the function argument infra_construction_triggers is passed from the Utility constructor. If ROF project triggers are always placed first in this vector when a utility object is created in the Problem class, followed by demand triggers, the process to build a standard infra_construction_triggers_new within the rearrangeInfraRofVector function can be changed, replacing lines 146-161 of InfrastructureManager.cpp of the master to: