muse2/
model.rs

1//! The model represents the static input data provided by the user.
2use crate::agent::AgentMap;
3use crate::commodity::{CommodityID, CommodityMap};
4use crate::process::ProcessMap;
5use crate::region::{Region, RegionID, RegionMap};
6use crate::time_slice::TimeSliceInfo;
7use std::collections::HashMap;
8use std::path::PathBuf;
9
10pub mod parameters;
11pub use parameters::{
12    ALLOW_BROKEN_OPTION_NAME, ModelParameters, PricingStrategy, broken_model_options_allowed,
13};
14
15/// Model definition
16pub struct Model {
17    /// Path to model folder
18    pub model_path: PathBuf,
19    /// Parameters from the model TOML file
20    pub parameters: ModelParameters,
21    /// Agents for the simulation
22    pub agents: AgentMap,
23    /// Commodities for the simulation
24    pub commodities: CommodityMap,
25    /// Processes for the simulation
26    pub processes: ProcessMap,
27    /// Information about seasons and time slices
28    pub time_slice_info: TimeSliceInfo,
29    /// Regions for the simulation
30    pub regions: RegionMap,
31    /// Commodity ordering for each region and year
32    pub commodity_order: HashMap<(RegionID, u32), Vec<CommodityID>>,
33}
34
35impl Model {
36    /// Iterate over the model's milestone years.
37    pub fn iter_years(&self) -> impl Iterator<Item = u32> + '_ {
38        self.parameters.milestone_years.iter().copied()
39    }
40
41    /// Iterate over the model's regions (region IDs).
42    pub fn iter_regions(&self) -> indexmap::map::Keys<'_, RegionID, Region> {
43        self.regions.keys()
44    }
45}