Precompute investment objective coefficients#888
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #888 +/- ##
==========================================
+ Coverage 85.37% 85.41% +0.04%
==========================================
Files 50 50
Lines 5319 5335 +16
Branches 5319 5335 +16
==========================================
+ Hits 4541 4557 +16
Misses 559 559
Partials 219 219 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This reverts commit ddec2e5.
|
|
||
| let mut round = 0; | ||
| let objective_type = &agent.objectives[&year]; | ||
| let mut best_assets: Vec<AssetRef> = Vec::new(); |
There was a problem hiding this comment.
Do you need the type hint?
| let mut best_assets: Vec<AssetRef> = Vec::new(); | |
| let mut best_assets = Vec::new(); |
There was a problem hiding this comment.
Not sure what the linters say, but sometimes, even though type hints might not be necessary for the program to compile, they are really useful for people reading the code.
There was a problem hiding this comment.
Correct that the type annotation isn't required here.
I'm in two minds about this (and giving non-mandatory type annotations in general). On the one hand, not giving them means trimmer code that's easier to change, and if you're using the rust-analyzer plugin in vscode then it gives you these annotations anyway. On the other hand, you are quite reliant on rust-analyzer for readability, which doesn't help when looking at diffs on GitHub
There was a problem hiding this comment.
I'm going to merge this as it is, but looking into it I think the idiomatic approach here is to not give the type hint
Description
We currently calculate the coefficients (
ObjectiveCoefficients, formerlyCoefficientsMap) used in the investment algorithm multiple times (every time a new round of appraisal is performed), even though these values won't change.A better approach is to calculate these upfront for all assets, store them, and pass individual
ObjectiveCoefficientss toappraise_investment.This won't be that impactful currently as the work to calculate the coefficients is small, but this will be more significant once we move the current code for calculating "reduced costs" over to the investment module
Close #885