# ecohn44/cascaded-hydro architecture

> Architecture diagram of the GitHub repository ecohn44/cascaded-hydro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ecohn44/cascaded-hydro
- Repository: https://github.com/ecohn44/cascaded-hydro

## Overview

This is a MATLAB research implementation of rolling-horizon, chance-constrained dispatch for a four-project Columbia River hydropower cascade. A study driver configures a sweep; the sweep loads a water year and runs each job, whose simulation rebuilds and solves a dispatch model hourly, implements the first-hour action, and advances state. Results are aggregated into summaries and publication tables. The README also documents ARCH-X fitting, Bonferroni and sequential-hyperplane risk enforcement, and benchmark comparisons. Edges follow the documented workflow; unsampled internals are represented at their supported directory paths.

Main entry points: [`realtimeDispatch.m`](https://github.com/ecohn44/cascaded-hydro/blob/main/realtimeDispatch.m) (Hourly dispatch), [`realtimeSimulation.m`](https://github.com/ecohn44/cascaded-hydro/blob/main/realtimeSimulation.m) (State and hour loop), [`results/runs`](https://github.com/ecohn44/cascaded-hydro/tree/main/results/runs) (Run summaries), [`runSweep.m`](https://github.com/ecohn44/cascaded-hydro/blob/main/runSweep.m) (Job sweep)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_study["Study configuration"]
  node_study_driver["Study driver"]
  node_sweep["Job sweep<br/>[runSweep.m]"]
  node_job_runner["Job runner<br/>[sweepRunOne.m]"]
end

subgraph group_models["Forecast and inputs"]
  node_inputs[("Model inputs")]
  node_fit["ARCH-X fitting"]
  node_water_year["Water-year loader<br/>[dataload.m]"]
end

subgraph group_dispatch["Rolling dispatch"]
  node_simulation["State and hour loop"]
  node_setup["Fixed job setup<br/>[dispatchSetup.m]"]
  node_dispatch["Hourly dispatch<br/>[realtimeDispatch.m]"]
  node_model_builder["Optimization model<br/>[makeModel.m]"]
  node_risk_margin["Risk margins<br/>[scenarioMargin.m]"]
  node_ssh_probability["SSH probability<br/>[sshProbability.m]"]
  node_recourse["Dispatch recourse"]
end

subgraph group_outputs["Results and analysis"]
  node_run_results[("Job results")]
  node_collector["Result collector<br/>[collectResults.m]"]
  node_summaries[("Run summaries")]
  node_tables["Published tables<br/>[makeTables.m]"]
  node_benchmarks["Benchmark studies<br/>[benchmarks.m]"]
  node_figures["Research figures"]
end

node_researcher(("Researcher"))
node_solver["Gurobi solver"]

node_researcher -->|"configures study"| node_study_driver
node_study_driver -->|"calls sweep"| node_sweep
node_sweep -->|"loads once"| node_water_year
node_sweep -->|"runs each job"| node_job_runner
node_inputs -->|"supplies inputs"| node_water_year
node_fit -.->|"fits parameters"| node_inputs
node_job_runner -->|"runs job"| node_simulation
node_simulation -->|"builds setup"| node_setup
node_simulation -->|"dispatches hourly"| node_dispatch
node_dispatch -.->|"builds model"| node_model_builder
node_dispatch -.->|"applies margins"| node_risk_margin
node_dispatch -.->|"evaluates SSH"| node_ssh_probability
node_dispatch -->|"solves model"| node_solver
node_dispatch -->|"performs recourse"| node_recourse
node_simulation -->|"saves job"| node_run_results
node_run_results -->|"reads jobs"| node_collector
node_collector -->|"writes summaries"| node_summaries
node_summaries -->|"feeds tables"| node_tables
node_summaries -.->|"supports studies"| node_benchmarks
node_summaries -.->|"feeds figures"| node_figures

click node_study_driver "https://github.com/ecohn44/cascaded-hydro/tree/main/reproduce"
click node_sweep "https://github.com/ecohn44/cascaded-hydro/blob/main/runSweep.m"
click node_inputs "https://github.com/ecohn44/cascaded-hydro/tree/main/data"
click node_fit "https://github.com/ecohn44/cascaded-hydro/blob/main/fitting/fitInflowFullYear.py"
click node_water_year "https://github.com/ecohn44/cascaded-hydro/blob/main/dataload.m"
click node_job_runner "https://github.com/ecohn44/cascaded-hydro/blob/main/functions/sweepRunOne.m"
click node_simulation "https://github.com/ecohn44/cascaded-hydro/blob/main/realtimeSimulation.m"
click node_setup "https://github.com/ecohn44/cascaded-hydro/blob/main/dispatchSetup.m"
click node_dispatch "https://github.com/ecohn44/cascaded-hydro/blob/main/realtimeDispatch.m"
click node_model_builder "https://github.com/ecohn44/cascaded-hydro/blob/main/functions/makeModel.m"
click node_risk_margin "https://github.com/ecohn44/cascaded-hydro/blob/main/functions/scenarioMargin.m"
click node_ssh_probability "https://github.com/ecohn44/cascaded-hydro/blob/main/functions/sshProbability.m"
click node_recourse "https://github.com/ecohn44/cascaded-hydro/tree/main/functions"
click node_run_results "https://github.com/ecohn44/cascaded-hydro/tree/main/results/runs"
click node_collector "https://github.com/ecohn44/cascaded-hydro/blob/main/collectResults.m"
click node_summaries "https://github.com/ecohn44/cascaded-hydro/tree/main/results/runs"
click node_tables "https://github.com/ecohn44/cascaded-hydro/blob/main/reproduce/makeTables.m"
click node_benchmarks "https://github.com/ecohn44/cascaded-hydro/blob/main/reproduce/benchmarks.m"
click node_figures "https://github.com/ecohn44/cascaded-hydro/tree/main/figures"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_study_driver,node_sweep,node_job_runner toneBlue
class node_inputs,node_fit,node_water_year toneAmber
class node_simulation,node_setup,node_dispatch,node_model_builder,node_risk_margin,node_ssh_probability,node_recourse toneMint
class node_run_results,node_collector,node_summaries,node_tables,node_benchmarks,node_figures toneRose
class node_researcher,node_solver toneIndigo
```

## Components

### Study configuration

- [Study driver](https://github.com/ecohn44/cascaded-hydro/tree/main/reproduce): `reproduce`
- [Job sweep](https://github.com/ecohn44/cascaded-hydro/blob/main/runSweep.m): `runSweep.m`
- [Job runner](https://github.com/ecohn44/cascaded-hydro/blob/main/functions/sweepRunOne.m): `functions/sweepRunOne.m`

### Forecast and inputs

- [Model inputs](https://github.com/ecohn44/cascaded-hydro/tree/main/data): `data`
- [ARCH-X fitting](https://github.com/ecohn44/cascaded-hydro/blob/main/fitting/fitInflowFullYear.py): `fitting/fitInflowFullYear.py`
- [Water-year loader](https://github.com/ecohn44/cascaded-hydro/blob/main/dataload.m): `dataload.m`

### Rolling dispatch

- [State and hour loop](https://github.com/ecohn44/cascaded-hydro/blob/main/realtimeSimulation.m): `realtimeSimulation.m`
- [Fixed job setup](https://github.com/ecohn44/cascaded-hydro/blob/main/dispatchSetup.m): `dispatchSetup.m`
- [Hourly dispatch](https://github.com/ecohn44/cascaded-hydro/blob/main/realtimeDispatch.m): `realtimeDispatch.m`
- [Optimization model](https://github.com/ecohn44/cascaded-hydro/blob/main/functions/makeModel.m): `functions/makeModel.m`
- [Risk margins](https://github.com/ecohn44/cascaded-hydro/blob/main/functions/scenarioMargin.m): `functions/scenarioMargin.m`
- [SSH probability](https://github.com/ecohn44/cascaded-hydro/blob/main/functions/sshProbability.m): `functions/sshProbability.m`
- [Dispatch recourse](https://github.com/ecohn44/cascaded-hydro/tree/main/functions): `functions`

### Results and analysis

- [Job results](https://github.com/ecohn44/cascaded-hydro/tree/main/results/runs): `results/runs`
- [Result collector](https://github.com/ecohn44/cascaded-hydro/blob/main/collectResults.m): `collectResults.m`
- [Run summaries](https://github.com/ecohn44/cascaded-hydro/tree/main/results/runs): `results/runs`
- [Published tables](https://github.com/ecohn44/cascaded-hydro/blob/main/reproduce/makeTables.m): `reproduce/makeTables.m`
- [Benchmark studies](https://github.com/ecohn44/cascaded-hydro/blob/main/reproduce/benchmarks.m): `reproduce/benchmarks.m`
- [Research figures](https://github.com/ecohn44/cascaded-hydro/tree/main/figures): `figures`

### Other components

- **Researcher**
- **Gurobi solver**

## Connections

- Researcher → Study driver: configures study (evidence: `README.md`)
- Study driver → Job sweep: calls sweep (evidence: `README.md`)
- Job sweep → Water-year loader: loads once (evidence: `README.md`)
- Job sweep → Job runner: runs each job (evidence: `README.md`)
- Model inputs → Water-year loader: supplies inputs (evidence: `README.md`)
- ARCH-X fitting → Model inputs: fits parameters
- Job runner → State and hour loop: runs job (evidence: `README.md`)
- State and hour loop → Fixed job setup: builds setup (evidence: `README.md`)
- State and hour loop → Hourly dispatch: dispatches hourly (evidence: `README.md`)
- Hourly dispatch → Optimization model: builds model
- Hourly dispatch → Risk margins: applies margins
- Hourly dispatch → SSH probability: evaluates SSH
- Hourly dispatch → Gurobi solver: solves model (evidence: `README.md`)
- Hourly dispatch → Dispatch recourse: performs recourse (evidence: `README.md`)
- State and hour loop → Job results: saves job (evidence: `README.md`)
- Job results → Result collector: reads jobs (evidence: `README.md`)
- Result collector → Run summaries: writes summaries (evidence: `README.md`)
- Run summaries → Published tables: feeds tables (evidence: `README.md`)
- Run summaries → Benchmark studies: supports studies
- Run summaries → Research figures: feeds figures
