-
Notifications
You must be signed in to change notification settings - Fork 3
NPV: Avoid excessive candidate capacity during investment #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,13 +69,14 @@ impl AppraisalOutput { | |
| /// Create a new `AppraisalOutput` | ||
| fn new<T: MetricTrait>( | ||
| asset: AssetRef, | ||
| capacity: AssetCapacity, | ||
| results: ResultsMap, | ||
| metric: Option<T>, | ||
| coefficients: Rc<ObjectiveCoefficients>, | ||
| ) -> Self { | ||
| Self { | ||
| asset, | ||
| capacity: results.capacity, | ||
| capacity, | ||
| activity: results.activity, | ||
| unmet_demand: results.unmet_demand, | ||
| metric: metric.map(|m| Box::new(m) as Box<dyn MetricTrait>), | ||
|
|
@@ -252,7 +253,7 @@ impl MetricTrait for NPVMetric {} | |
| fn calculate_lcox( | ||
| model: &Model, | ||
| asset: &AssetRef, | ||
| max_capacity: Option<AssetCapacity>, | ||
| max_capacity: AssetCapacity, | ||
| commodity: &Commodity, | ||
| coefficients: &Rc<ObjectiveCoefficients>, | ||
| demand: &DemandMap, | ||
|
|
@@ -276,6 +277,7 @@ fn calculate_lcox( | |
|
|
||
| Ok(AppraisalOutput::new( | ||
| asset.clone(), | ||
| results.capacity, | ||
| results, | ||
| cost_index.map(LCOXMetric::new), | ||
| coefficients.clone(), | ||
|
|
@@ -290,7 +292,7 @@ fn calculate_lcox( | |
| fn calculate_npv( | ||
| model: &Model, | ||
| asset: &AssetRef, | ||
| max_capacity: Option<AssetCapacity>, | ||
| max_capacity: AssetCapacity, | ||
| commodity: &Commodity, | ||
| coefficients: &Rc<ObjectiveCoefficients>, | ||
| demand: &DemandMap, | ||
|
|
@@ -320,13 +322,14 @@ fn calculate_npv( | |
|
|
||
| Ok(AppraisalOutput::new( | ||
| asset.clone(), | ||
| max_capacity, | ||
| results, | ||
| Some(NPVMetric::new(profitability_index)), | ||
| coefficients.clone(), | ||
| )) | ||
|
Comment on lines
323
to
329
|
||
| } | ||
|
|
||
| /// Appraise the given investment with the specified objective type | ||
| /// Appraise the given investment with the specified objective type. | ||
| /// | ||
| /// # Returns | ||
| /// | ||
|
|
@@ -341,6 +344,7 @@ pub fn appraise_investment( | |
| coefficients: &Rc<ObjectiveCoefficients>, | ||
| demand: &DemandMap, | ||
| ) -> Result<AppraisalOutput> { | ||
| let max_capacity = max_capacity.unwrap_or(asset.capacity()); | ||
| let appraisal_method = match objective_type { | ||
| ObjectiveType::LevelisedCostOfX => calculate_lcox, | ||
| ObjectiveType::NetPresentValue => calculate_npv, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_capacity(including the new demand-limiting-capacity recomputation) is calculated before the group-id de-duplication check. If there are many identical candidates in the same group, this recomputes DLC/tranche/remaining for assets that will be skipped anyway. Consider moving the group check before computingmax_capacity(or computingmax_capacityonly for the representative asset) to avoid unnecessary work in large models.