Pular para o conteúdo

Case Conversion (cobre-bridge)

Este conteúdo não está disponível em sua língua ainda.

cobre-bridge is a standalone Python package that converts power system case data from legacy formats to the Cobre input format. It currently supports conversion from the data format used by Brazilian hydrothermal dispatch tools.

The package is maintained in a separate repository: github.com/cobre-rs/cobre-bridge.


Terminal window
pip install cobre-bridge

To enable post-conversion validation with the Cobre solver:

Terminal window
pip install cobre-bridge cobre-python

The convert subcommand reads a source case directory and writes a complete Cobre case directory:

Terminal window
cobre-bridge convert newave /path/to/source/case /path/to/output/case
FlagDescription
--validateRun cobre validate on the output after conversion.
--forceOverwrite the destination directory if it already exists.
--verboseEnable detailed logging output.

The conversion pipeline transforms the source case’s input files into a complete Cobre case directory. The mapping covers:

Source ConceptCobre EntityOutput File
Hydro plant configurationHydroPlantsystem/hydros.json
Thermal plant configurationThermalUnitsystem/thermals.json
Subsystem definitionsBussystem/buses.json
Inter-area exchange limitsLinesystem/lines.json
Non-controllable sourcesNonControllableSourcesystem/non_controllable_sources.json
Historical inflow recordsPAR(p) inflow modelscenarios/inflow_history.parquet
Demand time seriesLoad seasonal statisticsscenarios/load_seasonal_stats.parquet
Study horizon configurationStage definitionsstages.json
Solver parametersConfigconfig.json
Reservoir bounds/overridesPer-stage hydro boundsconstraints/hydro_bounds.parquet
Thermal maintenance windowsPer-stage thermal boundsconstraints/thermal_bounds.parquet
Transmission capacityPer-stage line boundsconstraints/line_bounds.parquet
VminOP / electric / AGRINTGeneric LP constraintsconstraints/generic_constraints.json
output/
config.json
stages.json
penalties.json
initial_conditions.json
system/
hydros.json
thermals.json
buses.json
lines.json
non_controllable_sources.json
hydro_production_models.json (when applicable)
hydro_geometry.parquet (forebay/tailrace curves)
scenarios/
inflow_seasonal_stats.parquet
inflow_history.parquet
load_seasonal_stats.parquet
load_factors.json
non_controllable_stats.parquet
non_controllable_factors.json
constraints/
generic_constraints.json
generic_constraint_bounds.parquet
hydro_bounds.parquet
thermal_bounds.parquet
line_bounds.parquet
exchange_factors.json

Not all files are always produced. Optional files (e.g., hydro_production_models.json, generic constraints) are written only when the source data contains the relevant configuration.


After running both the source tool and Cobre on the same case, the compare subcommand checks LP bounds for consistency:

Terminal window
cobre-bridge compare newave /path/to/source/sintese /path/to/cobre/output \
--tolerance 1e-3
FlagDescription
--toleranceAbsolute tolerance for bound comparison (default: 1e-3).
--output PATHWrite a detailed diff report as a Parquet file.
--summaryPrint only summary counts, not individual mismatches.
--variablesFilter to specific variables (e.g., storage_min,turbined_max).

The comparison reads the source tool’s synthesis output and Cobre’s training/dictionaries/bounds.parquet, aligns entities by name, and reports any mismatches beyond the tolerance.


For programmatic use, import the conversion pipeline directly:

from pathlib import Path
from cobre_bridge.pipeline import convert_newave_case
report = convert_newave_case(
src=Path("/path/to/source/case"),
dst=Path("/path/to/output/case"),
)
print(report) # ConversionReport with entity counts and warnings

Source systems typically use 1-based integer IDs. cobre-bridge remaps all entity IDs to 0-based integers in a deterministic order derived from the source configuration files. This ensures consistent output regardless of file ordering.

Plants marked as fictitious in the source data (used internally by some tools for accounting purposes) are automatically excluded from the conversion output.

When the source case configures risk-averse optimization (CVaR), cobre-bridge converts the alpha and lambda parameters to per-stage risk_measure entries in stages.json. Three modes are supported:

  • Disabled — all stages use "expectation".
  • Constant — all stages use the same CVaR parameters.
  • Temporal — per-stage alpha/lambda values, with fallback to constants when a stage override is zero.

Three types of user-defined constraints are converted and merged into a single generic_constraints.json file with sequential IDs:

  • VminOP — minimum stored energy constraints (weighted sum of storage across a group of reservoirs).
  • Electric — operational constraints on hydro generation and line flows.
  • AGRINT — group dispatch constraints for thermal and hydro plants.

PackagePurpose
inewaveReads legacy fixed-width and binary input files
pyarrowWrites Parquet output tables
pandasDataFrame manipulation during conversion
cobre-pythonOptional: post-conversion validation