Skip to main content

PolicyGraph

Struct PolicyGraph 

Source
pub struct PolicyGraph {
    pub graph_type: PolicyGraphType,
    pub annual_discount_rate: f64,
    pub transitions: Vec<Transition>,
    pub season_map: Option<SeasonMap>,
}
Expand description

Parsed and validated policy graph defining stage transitions, horizon type, and global discount rate.

This is the cobre-core clarity-first representation loaded from stages.json. It stores the graph topology as specified by the user. The solver-level HorizonMode enum (see Horizon Mode Trait SS1) is built from this struct during initialization — it precomputes transition maps, cycle detection, and discount factors for efficient runtime dispatch.

Cross-reference: Horizon Mode Trait defines the HorizonMode enum that interprets this graph structure.

Source: stages.json policy_graph. See Input Scenarios §1.2.

Fields§

§graph_type: PolicyGraphType

Horizon type: finite (acyclic chain) or cyclic (infinite periodic). Determines which HorizonMode variant will be constructed at solver initialization.

§annual_discount_rate: f64

Global annual discount rate. Converted to per-transition factors using source stage durations: d = 1 / (1 + annual_discount_rate)^dt. A value of 0.0 means no discounting (d = 1.0 for all transitions). For cyclic graphs, must be > 0 for convergence (validation rule 7). See Discount Rate §3.

§transitions: Vec<Transition>

Stage transitions with probabilities and optional per-transition discount rate overrides. For finite horizon, these form a linear chain or DAG. For cyclic horizon, at least one transition has source_id >= target_id (the back-edge).

§season_map: Option<SeasonMap>

Season definitions loaded from season_definitions in stages.json. Required when PAR models or inflow history aggregation are used. None when no season definitions are provided and none are required.

Trait Implementations§

Source§

impl Clone for PolicyGraph

Source§

fn clone(&self) -> PolicyGraph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PolicyGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PolicyGraph

Source§

fn default() -> Self

Returns a finite-horizon policy graph with no transitions and no discounting.

This is the minimal-viable-solver default: a finite study horizon with zero terminal value and no discount factor. cobre-io replaces this with the fully specified graph loaded from stages.json.

Source§

impl PartialEq for PolicyGraph

Source§

fn eq(&self, other: &PolicyGraph) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for PolicyGraph

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.