Struct VariableMap

Source
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:

  1. In order define constraints for the optimisation
  2. 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

Source

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 problem
  • model - The model
  • input_prices - Optional explicit prices for input commodities
  • existing_assets - The asset pool
  • candidate_assets - Candidate assets for inclusion in active pool
  • year - Current milestone year
Source

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 problem
  • model - The model
  • commodities - The subset of commodities the problem is being run for
Source

fn get_asset_var(&self, asset: &AssetRef, time_slice: &TimeSliceID) -> Col

Get the asset Variable corresponding to the given parameters.

Source

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.

Source

fn iter_asset_vars( &self, ) -> impl Iterator<Item = (&AssetRef, &TimeSliceID, Col)>

Iterate over the asset variables

Source

fn asset_var_keys(&self) -> Keys<'_, (AssetRef, TimeSliceID), Col>

Iterate over the keys for asset variables

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.