//! # cobre-core
//!
//! Shared data model for the [Cobre](https://github.com/cobre-rs/cobre) power systems ecosystem.
//!
//! This crate defines the fundamental types used across all Cobre tools:
//! buses, branches, generators (hydro, thermal, renewable), loads, network
//! topology, and the top-level [`system`] struct. A power system defined with
//! `cobre-core` types can be used for power flow analysis, optimization, dynamic
//! simulation, and any other analysis procedure in the ecosystem.
//!
//! ## Design principles
//!
//! - **Solver-agnostic**: no solver or algorithm dependencies.
//! - **Validate at construction**: invalid states are caught when building
//!   the system, not at solve time.
//! - **Shared types**: a `Hydro` is the same struct whether used in
//!   stochastic optimization or steady-state analysis.
//! - **Declaration-order invariance**: all entity collections are stored in
//!   canonical ID-sorted order so results are identical regardless of input ordering.
//!
//! ## Status
//!
//! This crate is in early development. The API **will** change.
//!
//! See the [repository](https://github.com/cobre-rs/cobre) for the current status.

// Relax strict production lints for test builds. These lints (unwrap_used,
// expect_used, etc.) guard library code but are normal in tests.
#![cfg_attr(
    test,
    allow(
        clippy::unwrap_used,
        clippy::expect_used,
        clippy::float_cmp,
        clippy::panic,
        clippy::too_many_lines
    )
)]

pub mod constraints;
pub mod entities;
pub mod entity_id;
pub mod error;
pub mod model;
pub mod stats;
pub mod system;
pub mod topology;

// Crate-root module-alias re-exports: make `crate::resolved::` /
// `crate::scenario::` / `crate::temporal::` / `crate::parameters::` /
// `crate::penalty::` valid module paths for in-crate callers (system.rs,
// scenario.rs) and external `cobre_core::<module>::Symbol` consumers. The
// canonical sources are the `model::{...}` submodules.
pub use model::{parameters, penalty, resolved, scenario, temporal};

// Crate-root module-alias re-exports: make `cobre_core::generic_constraint::` /
// `cobre_core::initial_conditions::` / `cobre_core::training_event::` valid
// module paths for external consumers. Canonical source: the `constraints::`
// submodules.
pub use constraints::{generic_constraint, initial_conditions, training_event};

pub use constraints::generic_constraint::{
    ConstraintExpression, ConstraintSense, GenericConstraint, LinearTerm, SlackConfig, VariableRef,
};
pub use constraints::initial_conditions::{
    AnticipatedCommitmentHistory, HydroPastInflows, HydroStorage, InitialConditions,
    RecentObservation,
};
pub use constraints::training_event::{
    StageRowSelectionRecord, StoppingRuleResult, TrainingEvent, WORKER_TIMING_SLOT_BWD_SETUP,
    WORKER_TIMING_SLOT_BWD_WALL, WORKER_TIMING_SLOT_COUNT, WORKER_TIMING_SLOT_FWD_SETUP,
    WORKER_TIMING_SLOT_FWD_WALL, WORKER_TIMING_SLOT_SCORING, WorkerPhaseTimings, WorkerTimingPhase,
};
pub use entities::{
    AnticipatedConfig, Bus, ContractType, DeficitSegment, DiversionChannel, EfficiencyModel,
    EnergyContract, FillingConfig, HydraulicLossesModel, Hydro, HydroGenerationModel,
    HydroPenalties, Line, NonControllableSource, PumpingStation, TailraceModel, TailracePoint,
    Thermal,
};
pub use entity_id::EntityId;
pub use error::ValidationError;
pub use model::parameters::{CoefficientRef, ComputedParameter, ParameterKind, ScalarParameter};
pub use model::penalty::{
    GlobalPenaltyDefaults, HydroPenaltyOverrides, resolve_bus_deficit_segments,
    resolve_bus_excess_cost, resolve_hydro_penalties, resolve_line_exchange_cost,
    resolve_ncs_curtailment_cost,
};
pub use model::resolved::{
    BoundsCountsSpec, BoundsDefaults, BusStagePenalties, ContractStageBounds, HydroStageBounds,
    HydroStagePenalties, LineStageBounds, LineStagePenalties, NcsStagePenalties,
    PenaltiesCountsSpec, PenaltiesDefaults, PumpingStageBounds, ResolvedBounds,
    ResolvedExchangeFactors, ResolvedGenericConstraintBounds, ResolvedLoadFactors,
    ResolvedNcsBounds, ResolvedNcsFactors, ResolvedPenalties, ThermalStageBounds,
};
pub use model::scenario::{
    CorrelationEntity, CorrelationGroup, CorrelationModel, CorrelationProfile,
    CorrelationScheduleEntry, ExternalLoadRow, ExternalNcsRow, ExternalScenarioRow,
    HistoricalYears, InflowHistoryRow, InflowModel, LoadModel, NcsModel, SamplingScheme,
    ScenarioSource,
};
pub use model::temporal::{
    Block, BlockMode, NoiseMethod, PolicyGraph, PolicyGraphType, ScenarioSourceConfig,
    SeasonCycleType, SeasonDefinition, SeasonMap, Stage, StageRiskConfig, StageStateConfig,
    Transition,
};
pub use stats::welford::WelfordAccumulator;
pub use system::{System, SystemBuilder};
pub use topology::{BusGenerators, BusLineConnection, BusLoads, CascadeTopology, NetworkTopology};
