pub struct VariableMap {
asset_vars: IndexMap<(AssetRef, TimeSliceID), Col>,
existing_asset_var_idx: Range<usize>,
unmet_demand_vars: IndexMap<(CommodityID, RegionID, TimeSliceID), Col>,
unmet_demand_var_idx: Range<usize>,
}
Expand description
A map for easy lookup of variables in the problem.
The entries are ordered (see [IndexMap
]).
We use this data structure for two things:
- In order define constraints for the optimisation
- To keep track of the combination of parameters that each variable corresponds to, for when we are reading the results of the optimisation.
Fields§
§asset_vars: IndexMap<(AssetRef, TimeSliceID), Col>
§existing_asset_var_idx: Range<usize>
§unmet_demand_vars: IndexMap<(CommodityID, RegionID, TimeSliceID), Col>
§unmet_demand_var_idx: Range<usize>
Implementations§
Source§impl VariableMap
impl VariableMap
Sourcefn new_with_asset_vars(
problem: &mut Problem,
model: &Model,
input_prices: Option<&CommodityPrices>,
existing_assets: &[AssetRef],
candidate_assets: &[AssetRef],
year: u32,
) -> Self
fn new_with_asset_vars( problem: &mut Problem, model: &Model, input_prices: Option<&CommodityPrices>, existing_assets: &[AssetRef], candidate_assets: &[AssetRef], year: u32, ) -> Self
Create a new VariableMap
and add variables to the problem
§Arguments
problem
- The optimisation problemmodel
- The modelinput_prices
- Optional explicit prices for input commoditiesexisting_assets
- The asset poolcandidate_assets
- Candidate assets for inclusion in active poolyear
- Current milestone year
Sourcefn add_unmet_demand_variables(
&mut self,
problem: &mut Problem,
model: &Model,
commodities: &[CommodityID],
)
fn add_unmet_demand_variables( &mut self, problem: &mut Problem, model: &Model, commodities: &[CommodityID], )
Add unmet demand variables to the map and the problem
§Arguments
problem
- The optimisation problemmodel
- The modelcommodities
- The subset of commodities the problem is being run for
Sourcefn get_asset_var(&self, asset: &AssetRef, time_slice: &TimeSliceID) -> Col
fn get_asset_var(&self, asset: &AssetRef, time_slice: &TimeSliceID) -> Col
Get the asset Variable
corresponding to the given parameters.
Sourcefn get_unmet_demand_var(
&self,
commodity_id: &CommodityID,
region_id: &RegionID,
time_slice: &TimeSliceID,
) -> Col
fn get_unmet_demand_var( &self, commodity_id: &CommodityID, region_id: &RegionID, time_slice: &TimeSliceID, ) -> Col
Get the unmet demand Variable
corresponding to the given parameters.
Sourcefn iter_asset_vars(
&self,
) -> impl Iterator<Item = (&AssetRef, &TimeSliceID, Col)>
fn iter_asset_vars( &self, ) -> impl Iterator<Item = (&AssetRef, &TimeSliceID, Col)>
Iterate over the asset variables
Sourcefn asset_var_keys(&self) -> Keys<'_, (AssetRef, TimeSliceID), Col>
fn asset_var_keys(&self) -> Keys<'_, (AssetRef, TimeSliceID), Col>
Iterate over the keys for asset variables
Auto Trait Implementations§
impl Freeze for VariableMap
impl RefUnwindSafe for VariableMap
impl !Send for VariableMap
impl !Sync for VariableMap
impl Unpin for VariableMap
impl UnwindSafe for VariableMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more