Skip to content

Running Studies

End-to-end workflow for running an SDDP study with cobre run, interpreting output, and inspecting results.


A case directory is a folder containing all input data files required by Cobre. The minimum required structure is:

my_study/
config.json
penalties.json
stages.json
initial_conditions.json
system/
buses.json
hydros.json
thermals.json
lines.json

All eight files are required. Before running, validate the input:

Terminal window
cobre validate /path/to/my_study

Successful validation prints entity counts and exits with code 0:

Validation Demo

When validation detects errors — such as missing required fields or constraint violations — it reports them with severity labels and exits with code 1:

Validation Error Demo

Fix any reported errors before proceeding. See Case Directory Format for the full schema.


Terminal window
cobre run /path/to/my_study

By default, results are written to <CASE_DIR>/output/. To specify a different location:

Terminal window
cobre run /path/to/my_study --output /path/to/results
  1. Load — reads input files, runs layered validation (exits code 1 on validation failure, 2 on I/O error)
  2. Train — builds the SDDP policy by iterating forward/backward passes; stops when stopping rules are met
  3. Simulate — (optional) evaluates the policy over independent scenarios; requires simulation.enabled = true
  4. Write — writes Hive-partitioned Parquet (tabular), JSON manifests/metadata, and FlatBuffers output

When stderr is a terminal, a banner shows the version and solver backend. Use --quiet to suppress the banner, progress bars, and post-run summary. Errors are always written to stderr regardless of --quiet.

During training, a progress bar shows current iteration count. In --quiet mode, no progress bars are printed. Errors are always written to stderr.

After all stages complete, a run summary is printed to stderr with:

  • Training: iteration count, convergence status, bounds, gap, cuts, solves, time
  • Simulation (when enabled): scenarios requested, completed, failed
  • Output directory: absolute path to results

Use cobre report to inspect the results:

Terminal window
cobre report /path/to/my_study/output

Reads manifest files and prints JSON to stdout (suitable for piping to jq):

Terminal window
cobre report /path/to/my_study/output | jq '.training.convergence.final_gap_percent'

Exits with code 0 on success or 2 if the results directory does not exist.


To run training without simulation, set simulation.enabled to false in config.json:

{ "simulation": { "enabled": false } }

To evaluate a previously trained policy without re-training:

{
"training": { "enabled": false },
"policy": { "mode": "warm_start", "path": "./policy" }
}

Cobre loads the policy cuts, skips training entirely, and runs simulation. See Policy Management for details on warm-start and resume modes.

Use --threads to accelerate training and simulation with intra-rank parallelism:

Terminal window
cobre run /path/to/my_study --threads 4

Multi-threading Speedup

The thread pool is used for forward-pass batching and simulation scenario evaluation. Speedup depends on the number of forward passes and simulation scenarios configured.

A single cobre run uses the local (single-process) backend; launching under an MPI launcher (mpiexec, mpirun, or srun) distributes the work across ranks. By default (--comm-backend auto) cobre detects the launcher and selects the backend accordingly, so no flag is needed in either case. Pass --comm-backend mpi to force the MPI backend — it fails with a clear message on a binary built without MPI support — or --comm-backend local to force a single process even under a launcher.

Terminal window
cobre run /path/to/my_study --quiet
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "Study failed with exit code $exit_code" >&2
fi

Suppresses banner and progress output, suitable for batch scripts.

Exit CodeMeaningAction
0SuccessResults are available in the output directory
1Validation errorFix the input data and re-run cobre validate
2I/O errorCheck file paths and permissions
3Solver errorCheck constraint bounds in the case data
4Internal errorCheck environment; report at the issue tracker

See CLI Reference for the full exit code table.


Set exports.stochastic to true in config.json to write the stochastic preprocessing artifacts to output/stochastic/ before training begins:

{
"exports": {
"stochastic": true
}
}
FileWritten when
output/stochastic/inflow_seasonal_stats.parquetEstimation was performed
output/stochastic/inflow_ar_coefficients.parquetEstimation was performed
output/stochastic/correlation.jsonAlways
output/stochastic/fitting_report.jsonEstimation was performed
output/stochastic/noise_openings.parquetAlways
output/stochastic/load_seasonal_stats.parquetLoad buses exist

“Estimation was performed” means the user did not supply the corresponding scenario file; Cobre derived it from inflow_history.parquet.

Because every exported file uses the exact same schema as the corresponding input file, you can copy the exported artifacts back to scenarios/ and re-run to reproduce the identical stochastic context without re-running estimation:

Terminal window
# Step 1: initial run with stochastic export enabled in config.json
cobre run my_case
# Step 2: copy artifacts to scenarios/
cp -r my_case/output/stochastic/* my_case/scenarios/
# Step 3: re-run — estimation is skipped, opening tree is loaded directly
cobre run my_case

The re-run is faster (no Levinson-Durbin fitting or spectral decomposition) and produces bit-for-bit identical stochastic artifacts.

For the complete schema of each exported file, see Stochastic Artifacts in the Output Format Reference.


  • Theory: SDDP Algorithm — the forward/backward pass algorithm this workflow trains and runs.