Open robfitzgerald opened 6 months ago
@kylecarow - just updated this if you end up having the chance to work on it.
WIP in kjc/interpolation
FASTSim has benchmarks for interpolation, see https://github.nrel.gov/MBAP/fastsim/issues/328
Compass now uses the new interpolation stuff (in the branch), but should be replumbed to allow generic Feature
inputs that track units, I'm thinking something like:
pub enum Feature {
value: InternalFloat,
unit: FeatureUnit,
}
pub enum FeatureUnit {
SpeedUnit,
GradeUnit,
// ...
}
And change the arguments of InterpolationSpeedGradeModel::new()
(along with corresponding fields) to be close to this:
pub fn new<P: AsRef<Path>>(
underlying_model_path: &P,
underlying_model_type: ModelType,
underlying_model_name: String,
- speed_unit: SpeedUnit,
- speed_bounds: (Speed, Speed),
- speed_bins: usize,
- grade_unit: GradeUnit,
- grade_bounds: (Grade, Grade),
- grade_bins: usize,
+ features: &[Feature],
+ lower_bounds: &[Feature],
+ upper_bounds: &[Feature],
+ bins: usize,
energy_rate_unit: EnergyRateUnit,
) -> Result<Self, TraversalModelError> {
We currently support a bilinear interpolation model for providing very fast energy rate predictions by doing a linear interpolation over a structured grid. This could be extended to support N dimensions such that it could support more than two incoming features (currently just speed and grade).
Some things to keep in mind is that we want the
interpolate
method to be as fast as possible since it will be called for every link traversal, minimizing any memory allocations and ideally just performing simple operations.This work will eventually support a broader refactor of the
PredictionModel
trait that supports an arbitrary number of incoming features, building toward this API: