Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/simulation/investment/appraisal/coefficients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,14 @@ pub fn calculate_coefficients_for_npv(
// Capacity coefficient
let capacity_coefficient = -annual_fixed_cost(asset);

// Small epsilon to ensure break-even assets are dispatched
let epsilon = MoneyPerActivity(1e-14);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would define this as a const at the top of the function. E.g. see

const MAX_DISPLAY: usize = 10;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also use f64::EPSILON, so it is not an arbitrary small number. See https://doc.rust-lang.org/std/f64/constant.EPSILON.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's interesting didn't know about that. I changed it to f64::EPSILON * 100.0 because we need it to big enough to force out precision errors. Multiplying by 100.0 is still a bit arbitrary but seems more elegant this way


// Activity coefficients
let mut activity_coefficients = IndexMap::new();
for time_slice in time_slice_info.iter_ids() {
let coefficient = calculate_activity_coefficient_for_npv(asset, time_slice, prices, year);
activity_coefficients.insert(time_slice.clone(), coefficient);
activity_coefficients.insert(time_slice.clone(), coefficient + epsilon);
}

// Unmet demand coefficient (we don't apply a cost to unmet demand, so we set this to zero)
Expand Down