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;
52
53pub use entities::{
54    Bus, ContractType, DeficitSegment, DiversionChannel, EfficiencyModel, EnergyContract,
55    FillingConfig, GnlConfig, HydraulicLossesModel, Hydro, HydroGenerationModel, HydroPenalties,
56    Line, NonControllableSource, PumpingStation, TailraceModel, TailracePoint, Thermal,
57    ThermalCostSegment,
58};
59pub use entity_id::EntityId;
60pub use error::ValidationError;
61pub use generic_constraint::{
62    ConstraintExpression, ConstraintSense, GenericConstraint, LinearTerm, SlackConfig, VariableRef,
63};
64pub use initial_conditions::{HydroStorage, InitialConditions};
65pub use penalty::{
66    GlobalPenaltyDefaults, HydroPenaltyOverrides, resolve_bus_deficit_segments,
67    resolve_bus_excess_cost, resolve_hydro_penalties, resolve_line_exchange_cost,
68    resolve_ncs_curtailment_cost,
69};
70pub use resolved::{
71    BusStagePenalties, ContractStageBounds, HydroStageBounds, HydroStagePenalties, LineStageBounds,
72    LineStagePenalties, NcsStagePenalties, PumpingStageBounds, ResolvedBounds, ResolvedPenalties,
73    ThermalStageBounds,
74};
75pub use scenario::{
76    CorrelationEntity, CorrelationGroup, CorrelationModel, CorrelationProfile,
77    CorrelationScheduleEntry, ExternalSelectionMode, InflowModel, LoadModel, SamplingScheme,
78    ScenarioSource,
79};
80pub use system::{System, SystemBuilder};
81pub use temporal::{
82    Block, BlockMode, NoiseMethod, PolicyGraph, PolicyGraphType, ScenarioSourceConfig,
83    SeasonCycleType, SeasonDefinition, SeasonMap, Stage, StageRiskConfig, StageStateConfig,
84    Transition,
85};
86pub use topology::{BusGenerators, BusLineConnection, BusLoads, CascadeTopology, NetworkTopology};
87pub use training_event::{StoppingRuleResult, TrainingEvent};