Skip to main content

cobre_core/
lib.rs

1//! # cobre-core
2//!
3//! Shared data model for the [Cobre](https://github.com/cobre-rs/cobre) power systems ecosystem.
4//!
5//! This crate defines the fundamental types used across all Cobre tools:
6//! buses, branches, generators (hydro, thermal, renewable), loads, network
7//! topology, and the top-level [`system`] struct. A power system defined with
8//! `cobre-core` types can be used for power flow analysis, optimization, dynamic
9//! simulation, and any other analysis procedure in the ecosystem.
10//!
11//! ## Design principles
12//!
13//! - **Solver-agnostic**: no solver or algorithm dependencies.
14//! - **Validate at construction**: invalid states are caught when building
15//!   the system, not at solve time.
16//! - **Shared types**: a `Hydro` is the same struct whether used in
17//!   stochastic optimization or steady-state analysis.
18//! - **Declaration-order invariance**: all entity collections are stored in
19//!   canonical ID-sorted order so results are identical regardless of input ordering.
20//!
21//! ## Status
22//!
23//! This crate is in early development. The API **will** change.
24//!
25//! See the [repository](https://github.com/cobre-rs/cobre) for the full roadmap.
26
27// Relax strict production lints for test builds. These lints (unwrap_used,
28// expect_used, etc.) guard library code but are normal in tests.
29#![cfg_attr(
30    test,
31    allow(
32        clippy::unwrap_used,
33        clippy::expect_used,
34        clippy::float_cmp,
35        clippy::panic,
36        clippy::too_many_lines
37    )
38)]
39
40pub mod entities;
41pub mod entity_id;
42pub mod error;
43pub mod generic_constraint;
44pub mod initial_conditions;
45pub mod penalty;
46pub mod resolved;
47pub mod scenario;
48pub mod system;
49pub mod temporal;
50pub mod topology;
51pub mod training_event;
52pub mod welford;
53
54pub use entities::{
55    Bus, ContractType, DeficitSegment, DiversionChannel, EfficiencyModel, EnergyContract,
56    FillingConfig, GnlConfig, HydraulicLossesModel, Hydro, HydroGenerationModel, HydroPenalties,
57    Line, NonControllableSource, PumpingStation, TailraceModel, TailracePoint, Thermal,
58    ThermalCostSegment,
59};
60pub use entity_id::EntityId;
61pub use error::ValidationError;
62pub use generic_constraint::{
63    ConstraintExpression, ConstraintSense, GenericConstraint, LinearTerm, SlackConfig, VariableRef,
64};
65pub use initial_conditions::{HydroPastInflows, HydroStorage, InitialConditions};
66pub use penalty::{
67    GlobalPenaltyDefaults, HydroPenaltyOverrides, resolve_bus_deficit_segments,
68    resolve_bus_excess_cost, resolve_hydro_penalties, resolve_line_exchange_cost,
69    resolve_ncs_curtailment_cost,
70};
71pub use resolved::{
72    BoundsCountsSpec, BoundsDefaults, BusStagePenalties, ContractStageBounds, HydroStageBounds,
73    HydroStagePenalties, LineStageBounds, LineStagePenalties, NcsStagePenalties,
74    PenaltiesCountsSpec, PenaltiesDefaults, PumpingStageBounds, ResolvedBounds,
75    ResolvedExchangeFactors, ResolvedGenericConstraintBounds, ResolvedLoadFactors,
76    ResolvedNcsBounds, ResolvedNcsFactors, ResolvedPenalties, ThermalStageBounds,
77};
78pub use scenario::{
79    CorrelationEntity, CorrelationGroup, CorrelationModel, CorrelationProfile,
80    CorrelationScheduleEntry, ExternalSelectionMode, InflowModel, LoadModel, NcsModel,
81    SamplingScheme, ScenarioSource,
82};
83pub use system::{System, SystemBuilder};
84pub use temporal::{
85    Block, BlockMode, NoiseMethod, PolicyGraph, PolicyGraphType, ScenarioSourceConfig,
86    SeasonCycleType, SeasonDefinition, SeasonMap, Stage, StageRiskConfig, StageStateConfig,
87    Transition,
88};
89pub use topology::{BusGenerators, BusLineConnection, BusLoads, CascadeTopology, NetworkTopology};
90pub use training_event::{StageSelectionRecord, StoppingRuleResult, TrainingEvent};
91pub use welford::WelfordAccumulator;