GTOpt Python Scripts

The scripts/ directory contains Python command-line utilities for preparing, converting, visualizing, and post-processing data for use with GTOpt.

Detailed documentation for each script is available in the docs/scripts/ directory. This page provides a summary with links to the full documentation.

Table of Contents

  • Installation
  • Public tools at a glance
  • Supported source versions
  • Data Preparation & Conversion
    • gtopt_diagram · full docs
    • plp2gtopt · full docs
    • gtopt-fetch
    • plexos2gtopt — PLEXOS XML / CEN PCP bundles, typical weeks / days
    • sddp2gtopt · full docs
    • gtopt2plp / gtopt2sddp / gtopt2plexos — export a gtopt case to PLP / PSR SDDP .dat files / a PLEXOS dataset (+ PLEXOS solution tables)
    • psse2gtopt · full docs
    • opendss2gtopt / gtopt2opendss · full docs
    • pp2gtopt · full docs
    • nrel118_to_gtopt · full docs
    • cucdata2gtopt · full docs
    • sienna2gtopt · full docs
    • gasnet2gtopt — gas networks with native gas elements
    • dlr2gtopt — dynamic line rating inputs (critical spans)
    • tcheby2gtopt — Chebyshev point-stage test cases (python -m)
    • rts_gmlc_to_gtopt — RTS-GMLC emission / reserve benchmark (python -m)
    • gtopt2pp — convert gtopt JSON back to pandapower
    • igtopt · full docs · Excel template · igtopt --make-template regenerates the template
    • cvs2parquet · full docs
    • ts2gtopt · full docs
    • gtopt_compare · full docs
    • gtopt_compare_runs — compare two gtopt output directories (or a PLP / SDDP / PLEXOS solution imported with --results)
  • Running & Monitoring
    • run_gtopt — smart solver wrapper with pre/post-flight checks
    • gtopt_monitor — live solver convergence dashboard
  • Validation & Diagnostics
    • gtopt_check_json — validate JSON planning files
    • gtopt_check_lp — diagnose infeasible LP files
    • gtopt_check_topology — network islands per stage, KVL loops, bridges · full docs
    • gtopt_check_output — analyze solver output
    • gtopt_check_solvers — discover and validate LP solver plugins
    • gtopt_compress_lp — compress LP debug files
    • gtopt_check_fingerprint — LP structural fingerprint verification · full docs
    • gtopt_check_pampl — validate PAMPL expression syntax and LP resolution
    • gtopt_check_cases — check a case collection (gtopt-cases) against its catalog
    • plp_compress_case — compress PLP case files
  • Utilities
    • gtopt_config — unified configuration for all tools
    • gtopt_field_extractor (developer tool, python -m)
  • Tool Comparison (gtopt vs PLP vs pandapower)
  • Using with gtopt\_guisrv and gtopt\_websrv

Installation

Install all tools with a single pip command from the repository root:

pip install ./scripts

This registers every public command-line tool on your PATH — the authoritative list is [project.scripts] in scripts/pyproject.toml, summarised in Public tools at a glance. Every one of them is exercised by scripts/tests/test_public_cli.py (--help plus an end-to-end run on a tiny case). An editable install is useful during development:

pip install -e "./scripts[dev]"

Bundled data files

Several tools read non-Python data files at runtime. They ship inside the Python packages (declared in [tool.setuptools.package-data] of scripts/pyproject.toml), so a regular pip install ./scripts and an editable install see exactly the same files:

FileUsed by
plexos2gtopt/data/cen_pcp_hard_ucs.txtPLEXOS-HARD user-constraint list (plexos2gtopt, python -m plexos2gtopt.uc_audit)
gtopt_shared/data/emissions/cen_chile.jsondefault --emissions-file of plexos2gtopt
gtopt_shared/data/ipcc_emission_factors.jsonIPCC-2006 emission defaults
gtopt_shared/data/cogen/cen_chile_cogen.csvCEN cogen list (plexos2gtopt, plp2gtopt, gtopt_marginal_units)
{plexos2gtopt,plp2gtopt}/solvers/*.prm, *.optssolver parameter files copied into each converted case
gtopt_expand/templates/*PAMPL/TSON templates, RoR and pmin-as-flowright whitelists

A missing data file is a hard error (MissingDataFileError, a FileNotFoundError) — the tools never silently fall back to a default that changes the model. Wheels built before 2026-11 lacked most of these files: plexos2gtopt then demoted ~100 CEN user constraints from hard to soft, used the bare IPCC emission factors, tagged no cogen units and wrote no solvers/ directory. Reinstall with:

pip install --force-reinstall --no-deps ./scripts   # regular install
# or, for development:
pip install -e "./scripts[dev]"

pytest -m wheel gtopt_shared/tests/test_wheel_package_data.py builds a wheel, installs it into a throwaway venv and checks every bundled file (see gtopt_shared.resources.REQUIRED_DATA_FILES). New runtime data files go under <package>/data/, solvers/ or templates/, must be added to the package-data globs and to REQUIRED_DATA_FILES, and should be located via gtopt_shared.resources.package_data_file().

Optional extras unlock additional output formats:

pip install -e "./scripts[dev,diagram]"
# adds: graphviz, pyvis, cairosvg

Public tools at a glance

One line per console script installed by pip install ./scripts:

CommandPurposeDocs
plp2gtoptPLP (plp*.dat) case → gtopt JSON + Parquetplp2gtopt
plexos2gtoptPLEXOS XML / CEN PCP bundle → gtopt JSONplexos2gtopt
plexos2gtopt-line-liftsRank binding lines of a solved PLEXOS-derived case to choose --lift-line-capsplexos2gtopt
sddp2gtoptPSR SDDP/NCP case → gtopt JSONsddp2gtopt
gtopt2plpgtopt JSON → PLP plp*.dat case (read back by plp2gtopt)gtopt2plp
gtopt2sddpgtopt JSON → PSR SDDP .dat block study (read back by sddp2gtopt)gtopt2sddp
gtopt2plexosgtopt JSON → PLEXOS MasterDataSet XML + Data Files (read back by plexos2gtopt); gtopt results → PLEXOS solution tablesgtopt2plexos
psse2gtoptPSS®E RAW → gtopt DC OPF casepsse2gtopt
opendss2gtoptOpenDSS .dss distribution circuit → gtopt (DC or LinDistFlow) caseopendss2gtopt
gtopt2opendssgtopt case (+ solved dispatch) → OpenDSS script for AC validationopendss2gtopt
gasnet2gtopt*.gasnet.json gas network + power system → gtopt JSON with native gas elementsgasnet2gtopt
pp2gtoptpandapower network → gtopt JSONpp2gtopt
gtopt2ppgtopt JSON → pandapower networkgtopt2pp
nrel118_to_gtoptNREL-118 test system → multi-stage gtopt casenrel118_to_gtopt
sienna2gtoptSienna (PowerSimulations.jl) reference systems → gtopt JSON (sienna_to_gtopt is a deprecated alias)sienna2gtopt
cucdata2gtoptClustered-UC benchmark (Morales-España & Tejada-Arango 2019, IEEE 39/118-bus) → gtopt IUC casecucdata2gtopt
dlr2gtoptTowers + weather → IEEE 738 span ratings → critical spans (Matus et al. 2012) → Line.dlr inputdlr2gtopt
tcheby2gtopttcheby SQLite test systems → gtopt JSON (hourly block and Chebyshev point-stage cases)tcheby2gtopt
rts_gmlc_to_gtoptRTS-GMLC test system → single-day gtopt dispatch case with emissions, reserves and inertiarts_gmlc_to_gtopt
igtoptExcel workbook → gtopt JSON (and --make-template)igtopt
cvs2parquetCSV → Parquet converter for gtopt input tablescvs2parquet
ts2gtoptProject time series onto a gtopt block horizonts2gtopt
gtopt_expandExpansion transforms: LNG terminal, ROR promotion, pumped storage, irrigation agreementsirrigation
gtopt-netNetwork reduction (reduce / project results / cascade run)proposal
run_gtoptSmart gtopt wrapper with pre/post-flight checksrun_gtopt
gtopt_monitorLive solver status dashboard (GUI or --no-gui)gtopt_monitor
gtopt_check_jsonValidate a gtopt planning JSONgtopt_check_json
gtopt_check_topologyPre-flight network topology analysis (per-stage islands, KVL loops)gtopt_check_topology
gtopt_check_pamplValidate PAMPL/TAMPL user-constraint filesgtopt_check_pampl
gtopt_check_lpDiagnose infeasible LP filesgtopt_check_lp
gtopt_check_outputAnalyse a gtopt output directorygtopt_check_output
gtopt_check_solversDiscover and validate LP solver pluginsgtopt_check_solvers
gtopt_check_fingerprintCompute / verify / compare LP structural fingerprintslp-fingerprint
gtopt_check_casesCheck a case collection (gtopt-cases) against its cataloggtopt_check_cases
gtopt_compress_lpCompress LP debug filesgtopt_compress_lp
gtopt_compareCompare gtopt results with pandapower / PLP referencesgtopt_compare
gtopt_compare_runsCompare two gtopt output directories: objective, every stream, top differing elements, elements in one run only; exit 1 beyond tolerancegtopt_compare_runs
gtopt_diagramNetwork topology and planning-structure diagramsgtopt_diagram
gtopt_results_summarySummarise a gtopt output directory—
gtopt_pricing_upliftMake-whole and lost-opportunity uplift and price statistics of unit-commitment runs (compare pricing_modes)Pricing modes
gtopt_cost_recoveryPer-project cost recovery of expansion runs: revenue at marginal prices vs opex + annualised capex, profit, make-whole uplift, market balanceInvestment economics
gtopt_private_evalPrivate-investor (pre-tax EBIT) evaluation of the selected projects under a market model (energy_only, capacity_market, reliability_option, cfd, cl Chile): revenue stack, EBITDA, NPV, IRR, payback, LCOE vs the planning annuity; capex-trajectory sub-commandPrivate-investor evaluation
gtopt_timeseries_exportExport gtopt results as tidy time series—
gtopt2pbiReshape gtopt Parquet outputs for Power BI—
gtopt-marginal-unitsMarginal-unit / marginal-emission identification from gtopt resultsplan
plp_compress_caseCompress / decompress PLP case directoriesplp_compress_case
plexos_compress_caseCompress / decompress PLEXOS bundle directories—
cen_demandaDownload CEN SIPUB hourly demand data—
cen2gtoptFetch CEN real-operation data into a canonical feedreview
cen2gtopt-marginal-periodMulti-day CEN marginal-unit runs → Parquet datasetreview
cen2gtopt-busesCEN bus catalogue and operational islandsreview
cen2gtopt-cacheInspect / pre-warm the CEN download cachereview
gtopt-fetchDownload operator data (CEN, AMM, EOR, AEMO, …) through the source registry, with a checksummed cachegtopt-fetch
cen2gtopt-pcp-archiveDownload CEN PCP base / solution bundles (deprecated: use gtopt-fetch cen)review
cen2gtopt-pcp-inputsRead CEN PCP LP-input CSV bundlesreview
cen2gtopt-pcp-solutionRead CEN PCP .accdb solution files (needs mdbtools)review

Two converters have no console script; they are installed with the package and run as modules:

ModulePurposeDocs
python -m tcheby2gtoptChebyshev scheduling SQLite test systems → hourly-block and Chebyshev point-stage cases; rebuilds cases/cheby_smalltcheby2gtopt
python -m rts_gmlc_to_gtoptRTS-GMLC → single-bus 24 h case with per-generator multi-pollutant emissions, optional reserves and inertiarts_gmlc_to_gtopt

Supported source versions

Every input converter declares the versions of its source tool or format it supports and the subset the repository's tests or cases exercise (SOURCE_FORMAT, built on gtopt_shared.source_versions). At run time it detects the input's version when the input carries one, logs the resolution (and records it in its provenance file where it has one), and warns on an untested version or an unknown one, which falls back to the closest supported version. --source-version X overrides the detection; --help prints the list below for each tool. plp2gtopt, whose source has no version numbers, declares known variants instead: several may apply at once and an unsupported one is ignored with a warning.

ConverterSourceSupportedTestedDetected fromRecorded in
plp2gtoptPLP Fortran .dat (known variants)CEN65, ESS, BESS, maule-agreement, laja-agreement, cenfi-legacy, cenfi-segmented, cuts-plpplaem, cuts-plpplemallfiles present / layouts (plpstrcen.dat → unsupported PLPv6.1-strcen); several tags at oncelog, plp2gtopt_state.json
sddp2gtoptPSR SDDP / NCP .dat16, 1716, 17a !Code, CSV header → 17; else undetectablelog
psse2gtoptPSS®E RAW32, 3332, 33REV field of the case-id linelog
pp2gtoptpandapower2.13, 2.14, 3.0–3.53.4, 3.5net.versionlog, pp2gtopt_state.json (time-series mode)
cen2gtoptCEN SIP API44 (recorded fixtures)endpoint versions in a --cache fetch cachelog, manifest.json
rts_gmlc_to_gtoptRTS-GMLC release0.2.30.2.3 (slow CTest)SOURCE_VERSION marker of a fresh cachelog, summary line
sienna2gtoptPowerSystemsTestData commita2ecae9…a2ecae9…bundle files matching the manifest SHA-256log
cucdata2gtoptCUC-data commit624abbb…624abbb… (synthetic workbook + cached data)files matching the manifest SHA-256log
nrel118_to_gtoptPowerSystemsTestData commita2ecae9…noneSOURCE_REF marker of a fresh cache, or a checkout's HEADlog, nrel118_to_gtopt_state.json
gasnet2gtopt*.gasnet.json schema11optional top-level schema_versionlog, .meta.json

plexos2gtopt adopts the same helper separately. ts2gtopt and cvs2parquet read plain CSV / Parquet tables and gtopt's own JSON, which have no versioned source format. Per-tool details: the "Supported source versions" section of each tool's page.

Developer tools (not installed as commands)

Repository-maintenance helpers stay importable but are not console scripts; run them from scripts/ with python -m:

ModulePurpose
python -m gtopt_field_extractorGenerate field-reference tables from the C++ headers (needs the source tree)
python -m cen2gtopt.marginal_unitsSingle-day marginal-unit diagnostic (hard-coded date; research use)
python -m cen2gtopt.pcp_validateBack-test the marginal-emission pipeline against CEN's PCP solution

The former aliases sddp_monitor (use gtopt_monitor) and gtopt_irrigation (use gtopt_expand) were removed. Other developer tools live in tools/.

Package organization

Each tool lives in its own Python package directory under scripts/ (scripts/<package>/, with tests in scripts/<package>/tests/); shared code is in gtopt_shared/, gtopt_config/ and gtopt_writer/.

Dependencies

PackagePurpose
numpyNumerical array processing
pandasDataFrame I/O
pyarrowParquet read/write
openpyxlExcel file support (igtopt)
pandapowerPower system network data (pp2gtopt, gtopt2pp, gtopt_compare)
richStyled terminal output (gtopt_check_json, plp2gtopt, igtopt, run_gtopt)
matplotlib (optional)live charts (gtopt_monitor GUI mode)
graphviz (optional)SVG/PNG/PDF rendering (gtopt_diagram)
pyvis (optional)Interactive HTML diagrams (gtopt_diagram)
cairosvg (optional)High-res PNG/PDF export (gtopt_diagram)

gtopt_diagram

→ Full documentation

Generates network topology and planning-structure diagrams from a GTOpt JSON planning file. Supports multiple output formats (SVG, PNG, PDF, DOT, Mermaid, interactive HTML) and automatic simplification of large cases via aggregation modes.

Image
IEEE 14-bus network drawn by gtopt_diagram: buses, lines with their

ratings, generators and demands"

ratings, generators and demands"

ratings, generators and demands"

ratings, generators and demands"

ratings, generators and demands"

Basic usage

# Auto mode (default) – picks the best aggregation for your case size
gtopt_diagram cases/ieee_9b/ieee_9b.json -o ieee9b.svg

# Interactive HTML with physics simulation
gtopt_diagram cases/ieee_9b/ieee_9b.json --format html -o ieee9b.html

# Mermaid Markdown snippet (no extra dependencies)
gtopt_diagram cases/ieee_9b/ieee_9b.json --format mermaid

# Network-only: no generator nodes (clean topology view)
gtopt_diagram large_case.json --no-generators -o topo.svg

# Planning time-structure diagram
gtopt_diagram cases/c0/system_c0.json --diagram-type planning --format html

Output formats (--format)

FormatDescriptionRequires
svgScalable vector graphic (default)graphviz
pngRaster imagegraphviz + cairosvg
pdfPDF documentgraphviz + cairosvg
dotGraphviz DOT source— (no extra deps)
mermaidMermaid flowchart source— (no extra deps)
htmlInteractive vis.js browser diagrampyvis

Aggregation modes (--aggregate)

ModeWhen auto selects itDescription
auto(default)Chooses based on element count
none< 100 elementsEvery generator shown individually
bus100–999 elementsOne summary node per bus
type≥ 1000 elementsOne node per (bus, generator-type) pair
global— (manual only)One node per generator type, system-wide

Reducing large diagrams

# Keep only buses ≥ 220 kV (lump low-voltage buses into HV neighbours)
gtopt_diagram large_case.json --voltage-threshold 220 -o hv_topo.svg

# Show only hydro generators within 3 hops of a specific bus
gtopt_diagram large_case.json --filter-type hydro --focus-bus Chapo220 --focus-hops 3

# Hard node-count cap: escalate aggregation until ≤ 50 nodes remain
gtopt_diagram large_case.json --max-nodes 50 -o compact.svg

# Keep only the top-2 generators per bus by pmax
gtopt_diagram large_case.json --top-gens 2 -o top2.svg

Visual features

  • Voltage-based line coloring: transmission lines are drawn with color intensity and width proportional to the bus voltage level (higher voltage lines appear darker and wider).
  • Reservoir sizing: reservoir nodes are scaled by their storage capacity (emax), so larger reservoirs appear visually larger in the diagram.
  • Reserve zones and provisions: reserve_zone_array entries are rendered as zone nodes connected to the generators that provide reserves via reserve_provision_array.
  • Generator and demand profiles: generator_profile_array and demand_profile_array entries are rendered as profile nodes linked to their parent generator or demand.
  • Colorblind palette: use --palette colorblind to switch all element colors to a palette designed for color-vision deficiency accessibility.

File-referenced value resolution

When fields like pmax or lmax are stored as Parquet file references, gtopt_diagram resolves them using --scenario, --stage, and --block (all default to UID 1). This controls which row of the Parquet file is used for sizing and labeling diagram elements.

All options

positional arguments:
  json_file             gtopt JSON planning file

options:
  -t, --diagram-type    topology (default) or planning
  -f, --format          dot | png | svg | pdf | mermaid | html  (default: svg)
  -o, --output          output file path
  -s, --subsystem       full | electrical | hydro  (default: full)
  -L, --layout          dot | neato | fdp | sfdp | circo | twopi
  -d, --direction       LR | TD | BT | RL  (Mermaid direction, default: LR)
  --clusters            Group in Graphviz sub-clusters
  --palette             default | colorblind  (default: default)
  --scenario UID        Scenario UID for resolving file-referenced values (default: 1)
  --stage UID           Stage UID for resolving file-referenced values (default: 1)
  --block UID           Block UID for resolving file-referenced values (default: 1)

reduction options:
  -a, --aggregate       auto | none | bus | type | global  (default: auto)
  --no-generators       Omit all generator nodes
  -g, --top-gens N      Keep only top-N generators per bus by pmax
  --filter-type TYPE    Show only: hydro solar wind thermal battery
  --focus-bus BUS       Show only elements within N hops of BUS (repeatable)
  --focus-generator GEN Focus on bus(es) connected to these generators (by name or uid)
  --focus-area KV       Focus on buses at or above this voltage level (kV)
  --focus-hops N        Hops for --focus-bus (default: 2)
  --max-nodes N         Hard cap; escalate aggregation until ≤ N nodes
  -V, --voltage-threshold KV  Lump buses below KV into HV neighbours
  --hide-isolated       Remove unconnected nodes
  --compact             Omit detail labels (names/counts only)

plp2gtopt

→ Full documentation

Converts a PLP (Programación de Largo Plazo) case directory to the GTOpt JSON + Parquet format. Reads the standard PLP data files (plpblo.dat, plpbar.dat, plpcosce.dat, plpcnfce.dat, plpcnfli.dat, plpdem.dat, plpeta.dat, and others) and writes:

  • A GTOpt JSON file (<output-dir>.json) with the complete system, simulation, and options configuration.
  • Parquet time-series files organised in subdirectories under <output-dir>/ (e.g. Demand/lmax.parquet, Generator/pmin.parquet, Afluent/afluent.parquet).

Hydro system conversion

When plpcnfce.dat contains reservoir (embalse) or series (serie) centrals, plp2gtopt converts the cascaded hydro system into GTOpt arrays. Two additional optional PLP files extend the hydro model:

PLP fileGTOpt arrayDescription
plpcnfce.datjunction_array, waterway_array, turbine_array, reservoir_array, flow_arrayMain hydro topology (required when hydro centrals exist)
plpcenre.datreservoir_production_factor_arrayVolume-dependent turbine production factor (PLP rendimiento): piecewise-linear conversion rate as a function of reservoir storage
plpcenfi.datreservoir_seepage_arrayWaterway-to-reservoir seepage (PLP filtración): linear model flow = slope × volume + constant

Both plpcenre.dat and plpcenfi.dat are optional — if absent, the corresponding arrays are simply not written. When present and non-empty they are silently parsed and appended to the JSON output.

plpcenre.dat format (Archivo de Rendimiento de Embalses):

# Number of entries
N
# For each entry:
'CENTRAL_NAME'     ← turbine (central) name
'EMBALSE_NAME'     ← reservoir name
mean_production_factor    ← fallback production factor [MW·s/m³]
num_segments       ← number of piecewise-linear segments
idx  volume  slope  constant  scale  ← one line per segment

plpcenfi.dat format (Archivo de Centrales Filtración):

# Number of entries
N
# For each entry:
'CENTRAL_NAME'     ← waterway source central name
'EMBALSE_NAME'     ← receiving reservoir name
slope  constant    ← seepage model [m³/s/dam³] and [m³/s]

Basic usage

# Default: reads ./input, writes ./output/output.json + data in ./output/
plp2gtopt

# Explicit input/output directories
plp2gtopt -i plp_case_dir -o gtopt_case_dir

# Limit conversion to the first 5 stages
plp2gtopt -i input/ -s 5

# Single hydrology (1-based; the default is all hydrologies)
plp2gtopt -i input/ -y 1

# Two hydrology scenarios (1-based) with 60/40 probability split
plp2gtopt -i input/ -y 1,2 -p 0.6,0.4

# Range selector: hydrologies 1, 2, and 5 through 10
plp2gtopt -i input/ -y 1,2,5-10

# Group PLP stages 1–4 into phase 1, then one stage per phase after
plp2gtopt -i input/ --stages-phase '1:4,5,6,7,8,9,10,...'

# Apply a 10% annual discount rate
plp2gtopt -i input/ -d 0.10

# Verbose debug output
plp2gtopt -i input/ -l DEBUG

Hydrology index format (-y / --hydrologies)

Hydrology indices follow the Fortran 1-based convention: index 1 refers to the first hydrology column in the PLP data files. The argument accepts comma-separated values and ranges:

SyntaxMeaning
allEvery hydrology (default)
firstThe first available hydrology (same as --first-scenario)
1Hydrology 1 only
1,2Hydrologies 1 and 2
1,2,5-10Hydrologies 1, 2, and 5 through 10
1,2,5-10,11Hydrologies 1, 2, 5-10, and 11

The internal 0-based index stored in the output JSON ("hydrology" field in scenario_array) is automatically computed as input_index - 1.

Phase layout (--stages-phase)

By default, phase assignment is controlled by -M / --method (default cascade):

  • sddp, cascade, cascade-reduced: one phase per PLP stage
  • monolithic (mono is a deprecated alias): one phase covering all stages

The -g / --stages-phase option overrides this with an explicit mapping. Tokens are comma-separated and use 1-based PLP stage indices:

TokenMeaning
NSingle stage N as one phase
N:MStages N through M (inclusive) as one phase
...(trailing) auto-expand one stage per phase for remaining stages
# Stages 1-4 as phase 1, stages 5-10 each as their own phase,
# then one stage per phase for any remaining stages
plp2gtopt -i input/ --stages-phase '1:4,5,6,7,8,9,10,...'

# Group all stages into two phases: 1-12 and 13-24
plp2gtopt -i input/ --stages-phase '1:12,13:24'

Pasada (run-of-river) modeling (--pasada-mode)

--pasada-mode selects how PLP pasada (run-of-river) centrals are modelled:

ModeEffect
auto (default)per central: solar / wind → generator profile, hydro → flow + turbine
hydrofull hydro topology (junctions, waterways, turbines, flows)
flow-turbineevery pasada central as a simplified flow + turbine
profileevery pasada central as a generator profile (normalised capacity factors)

Block-to-hour map (indhor.csv)

When the PLP input directory contains indhor.csv, plp2gtopt reads it and writes a normalised BlockHourMap/block_hour_map.parquet file alongside the other Parquet outputs. A "block_hour_map" key is added to the simulation section of the output JSON so that post-processing tools (e.g. ts2gtopt) can reconstruct hourly time-series from block-granularity solver output.

The indhor.csv format has columns: Año, Mes, Dia, Hora, Bloque (all integers; Hora is 1-based 1-24).

ZIP output (-z / --zip)

The -z flag creates a single ZIP archive that bundles the JSON configuration file and all Parquet/CSV data files together, preserving the full output directory structure. This archive is directly compatible with gtopt_guisrv (upload via the GUI) and gtopt_websrv (submit via the REST API):

plp2gtopt -z -i plp_case -o my_case
# Produces: my_case.zip

The ZIP layout is:

my_case.zip
├── my_case.json
└── my_case/              ← every file of the output directory
    ├── my_case.json      ← main system/simulation/options config
    ├── Demand/
    │   └── lmax.parquet
    ├── Generator/
    │   └── pmax.parquet
    └── Flow/
        └── discharge.parquet

The JSON inside my_case/ uses input_directory: ".", so the data files resolve relative to it.

Conversion statistics

After a successful conversion, plp2gtopt logs statistics (at INFO level) similar to the pre-solve statistics printed by the gtopt solver:

=== System statistics ===
  System name     : plp2gtopt
=== System elements  ===
  Buses           : 2
  Generators      : 3
  Generator profs : 1
  Demands         : 2
  Lines           : 1
  Batteries       : 0
  Converters      : 0
  Junctions       : 2
  Waterways       : 1
  Reservoirs      : 1
  Turbines        : 1
=== Simulation statistics ===
  Blocks          : 8760
  Stages          : 5
  Scenarios       : 2
=== Key options ===
  use_single_bus  : False
  scale_objective : 1000
  demand_fail_cost: 1000
  input_directory : my_case
  annual_discount : 0.1
=== Conversion time ===
  Elapsed         : 1.234s

Use -l DEBUG to also see which individual .dat files are being parsed.

Common options

plp2gtopt has well over 100 options (plp2gtopt --help); the most used ones are below. The full documentation lists the rest (SDDP / cascade tuning, maintenance and works plans, failure tiers, solver files, …).

FlagDefaultDescription
-i, --input-dir DIRinputPLP input directory
-o, --output-dir DIRoutput (gtopt_NAME for input plp_NAME)Output directory for the JSON and data files
-f, --output-file FILE<output-dir>/<output-dir-name>.jsonJSON output file path
-F, --output-format {parquet,csv}parquetData file format
-z, --zipoffCreate a ZIP archive of the JSON + data files
-s, --last-stage NallStop after stage N
-t, --last-time TallInclude stages up to an accumulated time (hours, or 1y, 6m, …)
-d, --discount-rate RATE0.0Annual discount rate (e.g. 0.10 for 10%)
-m, --management-factor F0.0Demand reduction fraction in [0, 1)
-c, --compression ALGzstdOutput file compression
-y, --hydrologies SPECallHydrology selector (1-based; all, first, 1,2,5-10)
-p, --probability-factors P1[,P2,…]equalProbability weights per scenario
-M, --method METHODcascadesddp, cascade, cascade-reduced, monolithic
-g, --stages-phase SPECper --methodExplicit phase layout; comma-separated stage indices/ranges with optional ... wildcard
--pasada-mode MODEautoRun-of-river modelling (see above)
--stationary-tol TOL--convergence-tolSecondary convergence tolerance for stationary-gap detection
--stationary-window Nnot set (gtopt uses 4)Iterations to look back when checking gap stationarity
-l, --log-level LEVELINFOVerbosity (DEBUG, INFO, WARNING, ERROR)
-V, --version—Print version and exit

Isolated centrals

During hydro topology conversion, PLP centrals that have no bus assignment (bus <= 0), no waterway connections, and are not referenced by any other central are considered isolated and are silently skipped. After the conversion statistics, a "Skipped Centrals" section lists all isolated centrals by name so the user can verify that they are genuinely unused.

Error messages

plp2gtopt raises descriptive errors for common problems:

SituationError message
Input directory missingInput directory does not exist: 'plp_case/'
Required .dat file missingRequired file not found: …/plpblo.dat
Invalid data formatInvalid data format: …

gtopt-fetch

Common download CLI over the per-operator source registries (scripts/gtopt_operators/<op>/sources.toml; design in operator-split). The registry holds only URLs, file-name patterns and the names of the environment variables that carry API keys: keys are never stored in the repository and never logged.

gtopt-fetch operators                              # registered operators
gtopt-fetch cen list                               # datasets of the CEN
gtopt-fetch cen info pcp                           # URL, terms, credential
export GTOPT_CEN_PORTAL_KEY=...                    # portal browse key
gtopt-fetch cen get pcp --date 2026-04-22 --out case/source
gtopt-fetch cen get plp_inputs --date 2026-05-15   # bundle in force
gtopt-fetch verify case/source                     # sha256 vs MANIFEST.jsonl
  • Cache: $GTOPT_FETCH_CACHE (default ~/.cache/gtopt/fetch), one directory per <operator>/<dataset> with a MANIFEST.jsonl (file, sha256, size, URL without query string, fetched/published dates). Files already downloaded by cen2gtopt-pcp-archive are reused.
  • --out DIR hard-links the files into DIR and writes the manifest there; gtopt-fetch verify DIR --write-lock pins them in a sources.lock (sha256sum format) for a case repository.
  • Datasets whose source forbids redistribution (AEMO workbooks and models) are manual: get prints the page and the terms (exit 3); download the file yourself and register it with --file. Never commit those files.
  • Exit status: 0 ok, 1 error, 2 missing credential, 3 manual download required.
  • TLS: every operator client (gtopt-fetch, cen2gtopt*) verifies server certificates. Set GTOPT_CA_BUNDLE=/path/ca.pem behind a proxy or private CA; GTOPT_INSECURE_TLS=1 turns verification off (local debugging only, logged as a warning). Public intermediate certificates that a server omits from its chain ship in gtopt_operators/<op>/certs/.

sddp2gtopt

→ Full documentation

Converts a PSR SDDP (Stochastic Dual Dynamic Programming, by PSR Inc.) case directory to a GTOpt JSON planning, mirroring the role plp2gtopt plays for PLP cases. v0 is JSON-first: it reads the typed psrclasses.json snapshot the SDDP GUI saves alongside the Fortran-style .dat files, parses the standard PSR collections (PSRStudy, PSRSystem, PSRDemand, PSRDemandSegment, PSRFuel, PSRThermalPlant, PSRHydroPlant, PSRGaugingStation), and writes a single-bus monolithic GTOpt planning that gtopt --lp-only ingests directly.

⚠️ Targets the PSR Inc. commercial SDDP format only — not the academic Julia SDDP.jl package.

Basic usage

# Inspect a case (no conversion)
sddp2gtopt --info  /path/to/sddp_case

# Schema sanity check
sddp2gtopt --validate /path/to/sddp_case

# Convert (default: writes ./gtopt_<case>/<case>.json)
sddp2gtopt /path/to/sddp_case

# Explicit output dir
sddp2gtopt -i /path/to/sddp_case -o gtopt_case

What gets mapped

PSR collectionGTOpt targetStatus
PSRStudyoptions + simulation✅
PSRSystemsynthesised single bus per system✅ (single)
PSRThermalPlant + PSRFuelgenerator_array (gcost = CEsp × Custo)✅
PSRHydroPlantgenerator_array (zero-cost, flat)⚠️ flattened
PSRDemand + PSRDemandSegmentdemand_array with inline lmax✅ (GWh→MW)
PSRGaugingStationinflow series⏳ deferred
Multi-system / multi-busextra bus_array + line_array⏳ deferred

The converter's roadmap (hydro reservoir + waterway, multi-bus, multi-scenario, .dat fallback) is tracked in scripts/sddp2gtopt/DESIGN.md; the per-element mapping rules and unit conversions are documented in detail in scripts/sddp2gtopt.md.

The sddp2gtopt front-end auto-detects the input: the typed psrclasses.json snapshot or the raw PSR .dat collection real SDDP/NCP deployments ship (e.g. the Guatemalan AMM weekly/daily cases). The .dat path builds a multi-bus DC OPF with real thermal merit costs, per-plant water-value hydro pricing, inflow-limited run-of-river, and an interconnection import cap (--import-limit).


psse2gtopt

→ Full documentation

Converts a PSS®E .raw power-flow case (revisions 32/33) into a single-snapshot multi-bus DC OPF GTOpt planning — the sister tool to plp2gtopt / sddp2gtopt for the Siemens PSS/E dialect. Buses → Bus, branches + transformers → Line (per-unit reactance; 3-winding → star bus), generators → Generator (uniform --gcost, since RAW has no costs), loads → Demand. Optional AMM side-car inputs: --nomenclatura (readable bus names), --ldm (merit-order costs), --rating-set A|B|C.

psse2gtopt --info case.raw                 # case summary
psse2gtopt -i case.raw -o gtopt_case        # convert
gtopt -s gtopt_case/gtopt_case.json --set output_directory=out  # solve DC OPF

opendss2gtopt

→ Full documentation

Converts an OpenDSS distribution circuit (.dss script; own parser, no engine needed) into a gtopt planning: the phase-coordinate circuit is reduced to a balanced single-phase equivalent (lines, transformers, regulator banks with optimisable taps, loads, generators, PV, storage, capacitors, daily load shapes). --network-model lindistflow writes the distribution fields (voltage limits, reactive power, taps, capacitors). gtopt2opendss writes a gtopt case and its solved dispatch back as an OpenDSS script, so an AC power flow (through the optional opendssdirect.py) validates gtopt's voltages and losses.

opendss2gtopt --info IEEE13Nodeckt.dss
opendss2gtopt IEEE13Nodeckt.dss -o ieee13 --network-model lindistflow
gtopt ieee13/ieee13.json -d ieee13/out
gtopt2opendss ieee13/ieee13.json -r ieee13/out --solve

cucdata2gtopt

→ Full documentation

Converts the case studies of Morales-España & Tejada-Arango, "Modeling the hidden flexibility of clustered unit commitment" (IEEE TPWRS 2019) — modified IEEE 39-bus (90 units) and 118-bus (540 units) systems, 24 h, DC network, up/down reserve — into gtopt individual-unit UC cases. The data (CUC-data) has no licence: it is fetched from a pinned commit into ~/.cache/gtopt/cucdata/ and never committed.

cucdata2gtopt --fetch-only                       # prime the cache
cucdata2gtopt --system 39 --reserve 10 -o cuc/   # cuc/cuc39_r10_s10.json
cucdata2gtopt --system 118 --reserve 2.5 --scale 10 -o cuc/
gtopt cuc/cuc39_r10_s10.json --mip-gap 1e-4

sienna2gtopt

→ Full documentation

Ports a test case of NREL-Sienna PowerSimulations.jl to a gtopt planning JSON. The Sienna data bundle (5bus, the only one with the CSV tables the variants read) is downloaded from a pinned upstream commit on first use and cached; set GTOPT_OFFLINE=1 to forbid downloads. sienna_to_gtopt is kept as a deprecated alias of the command.

sienna2gtopt hvdc -o hvdc.json
sienna2gtopt battery_degeneracy --subcase c -o bd_c.json
sienna2gtopt reserves --golden reserves_uc.json --ordc auto -o res.json
ArgumentDescription
VARIANTbattery_degeneracy, cascading_hydro, fuel_cost_ts, hvdc, interruptible_load, monitored_line, pumped_storage, reserves, wecc_240
-o, --output FILEOutput JSON (default <variant>.json)
--bundle {5bus,14bus}Sienna data bundle; 14bus holds only data_14bus_pu.jl (PowerSystems.jl data, no CSV tables) and is rejected with a usage error
--subcase {b,c,d,e,f}battery_degeneracy only
--golden FILEreserves only: a reserve golden written by tools/sienna_solve_golden.jl; its system data is the input (unit commitment, range reserves and ORDC)
--ordc {auto,stacked,omit}reserves only: ORDC as stacked priced reserve zones, omitted, or as in the golden
--source-version XAssume this PowerSystemsTestData version

nrel118_to_gtopt

→ Full documentation

Builds the NREL-118 extended IEEE 118-bus test system (Peña et al. 2018) as a full-network gtopt case: 118 buses, 186 lines, 327 generators at their buses, hourly regional load distributed by bus participation factors (Demand/lmax.parquet), hourly wind / solar / hydro availability (GeneratorProfile/profile.parquet) and IPCC AR6 CO₂ factors. Source CSVs are downloaded on demand (pinned commit) into ~/.cache/gtopt/nrel118/ and never vendored.

nrel118_to_gtopt -o nrel118/nrel118.json               # 366 daily stages x 24 h
nrel118_to_gtopt --hours 168+168 -o week2/nrel118.json  # one week
nrel118_to_gtopt --block-hours 4 --stage-hours 168 -o y/nrel118.json

pp2gtopt

→ Full documentation

Converts a pandapower network to GTOpt JSON format. Accepts either a built-in IEEE test network (via -n) or any pandapower network file saved to disk (via -f). Writes a self-contained GTOpt JSON file ready to be solved directly with the gtopt binary or submitted via gtopt_guisrv / gtopt_websrv.

Basic usage

# Convert the default IEEE 30-bus built-in network → ieee30b.json
pp2gtopt

# Convert a saved pandapower JSON file
pp2gtopt -f my_network.json -o my_case.json

# Convert a MATPOWER case file
pp2gtopt -f case39.m -o case39.json

# Convert a pandapower Excel workbook
pp2gtopt -f network.xlsx -o network.json

# Use a specific built-in test network
pp2gtopt -n case14 -o ieee14b.json

# List all available built-in test networks
pp2gtopt --list-networks

Input from file (-f / --file)

-f FILE loads any pandapower network saved to disk. The format is auto-detected from the file extension:

ExtensionFormatProduced by
.jsonpandapower JSONpandapower.to_json()
.xlsx / .xlspandapower Excelpandapower.to_excel()
.mMATPOWER case fileMATPOWER / Octave

The output JSON system name is derived from the file stem (e.g. case39.m → "case39").

Available built-in networks (-n / --network)

Network namepandapower functionDescription
ieee30b (default)case_ieee30IEEE 30-bus (Washington)
case4gscase4gs4-bus Glover-Sarma
case5case55-bus example
case6wwcase6ww6-bus Wood-Wollenberg
case9case9IEEE 9-bus
case14case14IEEE 14-bus
case33bwcase33bw33-bus Baran-Wu
case57case57IEEE 57-bus
case118case118IEEE 118-bus

All options

FlagDefaultDescription
-f, --file FILE—pandapower network file (.json, .xlsx/.xls, MATPOWER .m/.mat)
--matpower FILE—MATPOWER case (alias of -f); --mpc-var NAME (default mpc) names the struct in a .mat file
-n, --network NAMEieee30bbuilt-in test network (mutually exclusive with -f)
-o, --output FILE<stem>.jsonOutput JSON file path
--method {monolithic,sddp,cascade}cascade (snapshot), monolithic (with --profiles)options.method to embed (--solver is an alias)
--scale-objective F1000Objective scaling factor
--demand-fail-cost C1000Unserved-demand penalty [$/MWh]
-k, --use-kirchhoff / --no-use-kirchhoffonDC Kirchhoff constraints
-b, --use-single-bus / --no-use-single-busoffSingle-bus (copper-plate) mode
--check / --no-checkonPost-conversion validation via gtopt_check_json
--list-networks—Print all available built-in network names and exit
-l, --log-level LEVELINFOLogging verbosity
-V, --version—Print version and exit

Time-series mode (--profiles, --hours, --block-hours, --stage-hours, --stage-period, …) builds multi-block, multi-stage cases from hourly profiles; see the full documentation.


igtopt

→ Full documentation · Excel template

Converts an Excel workbook to a GTOpt JSON case. Reads all named sheets from the workbook and writes:

  • A GTOpt JSON file with the complete system, simulation, and options configuration.
  • Parquet (or CSV) time-series files written to the input_directory for any sheet whose name contains @ (e.g. Demand@lmax → <input_dir>/Demand/lmax.parquet).

Basic usage

# Basic conversion – output JSON and input directory derived from workbook name
igtopt system.xlsx

# Write output to an explicit JSON file
igtopt system.xlsx -j output/system.json

# Pretty-printed JSON (4-space indented), skip null/NaN values
igtopt system.xlsx --pretty --skip-nulls

# CSV time-series files instead of Parquet
igtopt system.xlsx -f csv

# Bundle JSON + data files into a ZIP archive (ready for gtopt_guisrv/websrv)
igtopt system.xlsx --zip

# Convert multiple workbooks in one run (merges into a single JSON)
igtopt case_a.xlsx case_b.xlsx -d /data/input

# Validate the workbook without writing output (exit 0 = OK, 1 = errors)
igtopt system.xlsx --validate

# Proceed even if some sheets have errors (partial output)
igtopt system.xlsx --ignore-errors

# Show debug log messages
igtopt system.xlsx -l DEBUG

Template generation (-T / --make-template)

The --make-template flag generates a ready-to-use Excel template with one sheet per element class and one column per field GTOpt accepts. The sheets and columns come from gtopt --json-schema (the C++ JSON contracts), or from the contract snapshot bundled with the scripts when no GTOpt binary is found, so a new C++ element appears in the template automatically.

# Regenerate docs/templates/gtopt_template.xlsx (default output)
igtopt --make-template

# Write to a custom path (reuses the -j/--json-file flag)
igtopt --make-template -j /tmp/my_template.xlsx

# Print the sheet list that would be generated (no file written)
igtopt --make-template --list-sheets

# Pin the contract source (auto | gtopt | snapshot) or use a saved dump
igtopt --make-template --schema-source gtopt --gtopt-bin build/standalone/gtopt
igtopt --make-template --schema-file schema.json

ZIP output (-z / --zip)

The -z flag creates a single ZIP archive that bundles the JSON configuration file and all Parquet/CSV data files together, preserving the full directory structure. This archive is directly compatible with gtopt_guisrv (upload via the GUI) and gtopt_websrv (submit via the REST API):

igtopt system.xlsx --zip
# Produces: system.zip
#   system.zip
#   ├── system.json
#   └── system/
#       ├── Demand/
#       │   └── lmax.parquet
#       └── GeneratorProfile/
#           └── profile.parquet

Conversion statistics

After a successful conversion, igtopt logs statistics (at INFO level) similar to those printed by plp2gtopt:

=== System statistics ===
  Buses           : 57
  Generators      : 7
  Demands         : 42
  Lines           : 80
=== Simulation statistics ===
  Blocks          : 1
  Stages          : 1
  Scenarios       : 1
=== Key options ===
  use_single_bus  : False
  scale_objective : 1000
  demand_fail_cost: 1000
  input_directory : system
=== Conversion time ===
  Elapsed         : 0.123s

Excel workbook format

The workbook can contain any of the following named sheets. Sheets whose name starts with . (e.g. .notes) are silently skipped.

System and simulation sheets

Sheet nameDescription
optionsKey/value pairs written to the JSON options block (two columns: option, value)
block_arrayTime blocks (uid, name, duration)
stage_arrayInvestment stages (uid, first_block, count_block, discount_factor)
scenario_arrayScenarios (uid, probability_factor)
phase_arraySDDP phases (uid, first_stage, count_stage, aperture_set) — leave empty for monolithic solver; aperture_set is a JSON array of aperture UIDs to restrict the SDDP backward pass for this phase
scene_arraySDDP scenes (uid, first_scenario, count_scenario) — leave empty for monolithic solver
bus_arrayElectrical buses (uid, name, voltage, reference_theta, use_kirchhoff)
generator_arrayGenerators (uid, name, bus, gcost, pmax, capacity, …)
generator_profile_arrayGenerator capacity factors (uid, name, generator, profile, scost)
demand_arrayDemands (uid, name, bus, lmax, fcost, …)
demand_profile_arrayDemand scaling profiles (uid, name, demand, profile, scost)
line_arrayTransmission lines (uid, name, bus_a, bus_b, reactance, tmax_ab, tmax_ba, …)
battery_arrayBatteries (uid, name, bus, emin, emax, pmax_charge, pmax_discharge, …)
converter_arrayBattery charge/discharge converter links (uid, name, battery, generator, demand)
reserve_zone_arraySpinning-reserve zones (uid, name, urreq, drreq)
reserve_provision_arrayGenerator–zone reserve provision links (uid, name, generator, reserve_zones)
junction_arrayHydraulic junctions (uid, name, drain)
waterway_arrayWater channels between junctions (uid, name, junction_a, junction_b, fmax)
flow_arrayExternal inflows/outflows at junctions (uid, name, junction, discharge, direction)
reservoir_arrayStorage lakes/dams (uid, name, junction, emin, emax, ecost)
reservoir_seepage_arrayWater seepage from waterways into reservoirs (uid, name, waterway, reservoir, slope, constant, segments — segments is a JSON array of {"volume", "slope", "constant"} for piecewise-linear seepage)
turbine_arrayHydro turbines (uid, name, waterway, generator, conversion_rate)
reservoir_production_factor_arrayVolume-dependent turbine productivity curves (uid, name, turbine, reservoir, mean_production_factor)
user_constraint_arrayUser-defined custom LP constraints added to the problem

Time-series sheets (@ convention)

Any sheet whose name contains @ encodes a time-series table that is written as a Parquet (or CSV) file to the input_directory. The naming convention is:

<component_type>@<field_name>

The sheet must contain scenario, stage, block index columns followed by one column per element (named after the element's name field).

Sheet name exampleProducesDescription
Demand@lmax<input_dir>/Demand/lmax.parquetPer-block demand limits
GeneratorProfile@profile<input_dir>/GeneratorProfile/profile.parquetSolar/wind capacity factors
Generator@pmax<input_dir>/Generator/pmax.parquetPer-block generator max output
Battery@emax<input_dir>/Battery/emax.parquetPer-block battery energy upper bound

When a time-series sheet is present, the corresponding field in the system array sheet (e.g. lmax in demand_array) should contain the string "lmax" (the file stem without extension) as a file reference.

Example: demand with a 24-hour lmax time-series

demand_array sheet:

uidnamebuslmax
1d3b3lmax
2d4b4lmax

Demand@lmax sheet:

scenariostageblockd3d4
1113020
1122818
……………

All options

FlagDefaultDescription
XLSX (positional)—Excel workbook(s) to convert (one or more)
-j, --json-file FILE<first stem>.jsonOutput JSON file path
-d, --input-directory DIR<first stem>/Directory for time-series data files
-f, --input-format {parquet,csv}parquetFormat for time-series output files
-n, --name NAME<first stem>System name written to JSON name field
-c, --compression ALGzstdParquet compression (zstd, gzip, snappy, …; '' for none); --compression-level N (default 1) sets the level
-p, --prettyoffWrite indented (4-space) JSON instead of compact
-N, --skip-nullsoffOmit keys with null/NaN values from JSON output
-U, --parse-unexpected-sheetsoffAlso process sheets not in the expected list
-z, --zipoffBundle JSON + data files into a ZIP archive
--validateoffCheck workbook for errors without writing output (exit 0 = OK, 1 = errors)
--ignore-errorsoffProceed despite errors in individual sheets (output may be incomplete)
-l, --log-level LEVELINFOVerbosity (DEBUG, INFO, WARNING, ERROR, CRITICAL)
-V, --version—Print version and exit
-T, --make-templateoffGenerate the Excel template from the gtopt input contract instead of converting
--schema-source SRCautoContract for the template: gtopt (gtopt --json-schema), snapshot (bundled), auto (gtopt if found, else snapshot)
--schema-file FILE—Use a saved gtopt --json-schema dump
--gtopt-bin PATHautodetectgtopt binary for --schema-source gtopt / auto
--list-sheetsoffPrint the template sheets (with column counts) and exit

cvs2parquet

→ Full documentation

Converts CSV time-series files to Parquet format.

# Convert a single file
cvs2parquet input.csv output.parquet

# Use an explicit PyArrow schema for type enforcement
cvs2parquet --schema input.csv output.parquet

Columns named stage, block, or scenario are cast to int32; all other columns are cast to float64.


ts2gtopt

→ Full documentation

Projects hourly (or finer) time-series data onto a GTOpt planning horizon and produces block-aggregated schedule files (Parquet or CSV) ready for use as GTOpt input schedules. It also embeds an hour_block_map in the output planning JSON so that block-level solver results can be reconstructed back into a full hourly time-series.

Concepts

TermMeaning
HorizonA JSON definition of scenarios, stages (investment periods), and blocks (representative operating hours)
Block scheduleA Parquet/CSV file with scenario, stage, block, uid:X columns consumed directly by GTOpt as an input schedule (e.g. Generator/pmax.parquet)
hour_block_mapAn array of {"hour": i, "stage": s, "block": b} entries embedded in the planning JSON that maps each processed calendar hour back to the (stage, block) it was projected into
output_hour/Post-processing output directory with scenario, hour, uid:X files reconstructed from block-level solver output

Basic usage

# Project a single hourly CSV onto an auto-generated 12-stage × 24-block horizon
ts2gtopt demand.csv -y 2023 -o input/

# Write 4 seasonal stages × 6 blocks each
ts2gtopt solar.csv -y 2023 --stages 4 --blocks 6 -o input/

# Use a custom horizon JSON and export updated block durations
ts2gtopt pmax.csv -y 2023 -H my_horizon.json --output-horizon updated_horizon.json -o input/

# Use the horizon embedded in an existing planning JSON (reads simulation.stage_array / block_array)
ts2gtopt load.csv -y 2023 -P case.json -o input/

Reconstructing hourly output

After running the gtopt solver (which produces output/Generator/generation_sol.csv etc.), use the hour_block_map embedded in the planning JSON to expand block-level results back into a full hourly time-series:

from ts2gtopt import write_output_hours

# Reads hour_block_map from case.json, writes output_hour/ next to output/
written = write_output_hours("bat_4b_2023.json")
# → output_hour/Generator/generation_sol.csv
#    scenario  hour   uid:1   uid:2
#    1          0    127.5    0.0
#    1          1    124.9    0.0
#    ...  (8760 rows for a full-year case)

Or from the public API:

from ts2gtopt import build_hour_block_map, reconstruct_output_hours, load_horizon

h = load_horizon("my_horizon.json")
hour_map = build_hour_block_map(h, year=2023)
reconstruct_output_hours("output/", hour_map, output_hour_dir="output_hour/")

CLI reference

ts2gtopt [options] FILE [FILE ...]

Positional arguments:
  FILE                   Input time-series file(s) (CSV or Parquet)

Options:
  -o, --output DIR       Output directory for schedule files (default: current directory)
  -H, --horizon FILE     JSON file defining the planning horizon
  -P, --planning FILE    gtopt case JSON; reads stage_array / block_array (needs --year)
  -y, --year YEAR        Calendar year of the series (filters the input, builds the auto-horizon)
  -s, --stages N         Stages of the auto-horizon (default: 12)
  -b, --blocks M         Blocks per stage of the auto-horizon (default: 24)
  --preset NAME          Built-in horizon: annual-3block, monthly-3block,
                         seasonal-3block, seasonal-hourly (overrides -s/-b)
  --list-presets         List the presets and exit
  -i, --interval-hours H Sampling interval of the input (default: auto-detected)
  -t, --time-column COL  Datetime column (default: datetime)
  -a, --agg FUNC         mean (default), median, min, max, sum
  -f, --format {parquet,csv}
                         Output file format (default: parquet)
  -c, --compression ALG  Parquet compression (default: zstd; '' for none)
  --output-horizon FILE  Write the duration-updated horizon JSON
  --verify               Print energy-conservation ratios after projection
  -l, --log-level LEVEL  Logging verbosity (default: INFO)
  -V, --version          Print version and exit
  --no-color             Disable coloured output

gtopt2pp

Converts a GTOpt JSON case back to a pandapower network file, optionally solving a DC OPF and/or running topology diagnostics. This is the reverse direction of pp2gtopt.

Basic usage

# Convert a gtopt case to pandapower JSON
gtopt2pp cases/ieee_9b_ori/ieee_9b_ori.json

# Specify output file
gtopt2pp cases/ieee_9b_ori/ieee_9b_ori.json -o ieee9b_pp.json

# Convert and solve DC OPF
gtopt2pp cases/ieee_9b_ori/ieee_9b_ori.json --solve

# Convert all blocks (one output file per block)
gtopt2pp cases/ieee_9b/ieee_9b.json --all-blocks

# Select specific blocks (comma-separated, ranges)
gtopt2pp cases/ieee_9b/ieee_9b.json -b 1,5-10

# Run pandapower diagnostic on converted network
gtopt2pp cases/ieee_14b_ori/ieee_14b_ori.json --diagnostic

Multi-block support

When the source case has multiple blocks (e.g. 24-hour dispatch), use --all-blocks or -b SPEC to produce one pandapower network per block:

gtopt2pp cases/ieee_9b/ieee_9b.json --all-blocks
# Produces: ieee_9b_pp_b1.json, ieee_9b_pp_b2.json, …, ieee_9b_pp_b24.json

Elements skipped during conversion

The following GTOpt elements have no pandapower equivalent and are silently skipped: batteries, converters, junctions, waterways, reservoirs, turbines, filtrations, flows. A summary of skipped elements is logged.

All options

FlagDefaultDescription
case_file (positional)—Path to GTOpt JSON case file
-o, --output PATH<stem>_pp.jsonOutput pandapower JSON file path
-s, --scenario UIDfirstScenario UID to convert
-b, --block SPECfirstBlock UID spec: single (1), list (1,2,4), range (1-5), or mix (1,3-5,8)
--solveoffRun pandapower DC OPF after conversion
--all-blocksoffConvert all blocks (one file per block)
--check / --no-checkenabledValidate source JSON via gtopt_check_json
--diagnosticoffRun pandapower topology diagnostic

run_gtopt

Smart solver wrapper that detects case types (PLP, PLEXOS, GTOpt directory, or JSON file), runs conversions when needed, and invokes the gtopt binary with appropriate runtime options. Integrates pre-flight and post-flight checks and, on a terminal, shows a live Rich dashboard.

ImageImage

An 8-scenario SDDP hydro-cascade run solved with HiGHS; keys and views are described in interfaces.md.

In an interactive terminal it shows a live dashboard: run status, bounds and gap, iteration history, CPU and memory use and the solver log. Keys 1/2/3 (or Tab) switch between the dashboard, the SDDP phase grid and the per-scene convergence view; s requests a graceful stop, q quits.

ImageImage

Frames from an 8-scenario, 24-phase SDDP hydro-cascade run (built from cases/hydro_valley_sddpjl) solved with HiGHS; captured with tools/figures/capture_tui.py.

Basic usage

# Auto-detect case type from CWD
run_gtopt

# PLP case: auto-convert to gtopt and solve
run_gtopt plp_case

# gtopt case directory: solve directly
run_gtopt cases/ieee_9b

# Explicit JSON file
run_gtopt cases/ieee_9b/ieee_9b.json

# Choose the LP solver plugin
run_gtopt cases/ieee_9b --solver highs

# Pass extra arguments to the gtopt binary after --
run_gtopt cases/ieee_9b -- --set use_single_bus=true --stats
run_gtopt case -- --set sddp_options.max_iterations=20

# CI / scripts: plain output, fail when SDDP did not converge
run_gtopt case --ui plain --fail-on-not-converged

# Re-attach the dashboard to a running gtopt
run_gtopt --attach            # the only live run, or list them
run_gtopt --attach 12345      # PID from `run_gtopt --list`

Everything after a bare -- goes to gtopt unchanged. The output directory is resolved the way gtopt resolves it: -- -d DIR > -- --set output_directory=DIR > options.output_directory in the planning JSON > the default (results inside a case directory, output next to a planning JSON). Command-line values are relative to the CWD; the JSON value and the default are anchored at the planning JSON's directory. The dashboard, the stop request, the post-run report and the post-flight checks all use this directory.

Pre-flight checks (enabled by default)

Before invoking the solver, run_gtopt validates:

  • JSON syntax and file readability (json_syntax)
  • Input file existence (Parquet/CSV references, input_files)
  • Output directory writability (output_dir)
  • Full JSON validation with gtopt_check_json (check_json, opt-in: slow; enable with --enable-check check_json)

run_gtopt --list-checks prints every check with its stage and default. Disable all with --no-check, abort on any warning with --strict.

Post-flight checks

After the solver completes, run_gtopt:

  • Analyzes any error LP files via gtopt_check_lp (check_lp)
  • Validates solver output via gtopt_check_output (check_output)
  • Prints a results summary: solution status, objective, output directory, gtopt log file and status file. A solution.csv older than the run is reported as "NO NEW SOLUTION" rather than as this run's result.

Display: dashboard and plain mode

On a terminal (--ui auto, the default) run_gtopt shows a live dashboard; with --ui plain / --no-tui, under TERM=dumb, or when stdout is not a terminal it streams gtopt's log instead.

  • Dashboard: progress (for SDDP the bar tracks the gap against sddp_options.convergence_tol, with the phase being solved and an ETA to the iteration limit), bounds history, colour-coded log (warnings yellow, errors red, repeats folded as (×N)), resource usage. Below 100 columns or 40 rows a compact layout is used. Keys: 1/2/3 views, s graceful stop, o paths (output dir, log, status, error LPs, and the gtopt_monitor command that charts the same status file), i system stats, h help, q quit (asks y/N after the first minute). If the dashboard itself fails, a warning says so and the run continues with gtopt's log printed as in plain mode. When gtopt ends, the last frame stays on screen followed by a summary (last 10 iterations, step timings, warning/error counts and the first warnings) and a banner with the outcome — Converged / Optimal (green), NOT converged / stopped (yellow), unknown (cyan), failed / NOT optimal / killed (red) — and the paths of the output directory, gtopt log, status file and captured solver output.
  • Plain mode: gtopt's log on stdout; on stderr one fixed-width line per SDDP iteration, a heartbeat every 30 s (run_gtopt: [00:05:00] running — iter 3/100, gap 1.25%, forward pass), lines cut to $COLUMNS, and an ASCII outcome block ([OK], [!!], [XX], ...) at the end.
  • --no-color (or NO_COLOR) disables colour; --ascii (or GTOPT_TUI_ASCII=1, automatic when the locale is not UTF-8) draws the dashboard with ASCII only; GTOPT_TUI_WIDTH / GTOPT_TUI_HEIGHT override the detected terminal size.

Solver output capture. Whatever gtopt prints on its own stdout/stderr (early failures that never reach its log file) is saved to <output>/logs/run_gtopt_stderr_<timestamp>.log. On failure the banner shows what the exit code means, gtopt's critical/error lines, the last lines it printed, and — when gtopt dumped error LPs for infeasible solves — the first error LP files with the command gtopt_check_lp <file> --solver all.

Stale files. Before a run, run_gtopt removes only solver_status.json and sddp_stop_request.json from the output directory (each removal is logged; a leftover stop request would stop the new SDDP run after one iteration). Results, cuts (needed by --recover) and logs are never deleted.

Interrupting a run

ActionEffect
1st Ctrl-C, or sGraceful stop: writes sddp_stop_request.json; SDDP / cascade finish the current iteration, save cuts and exit 0 (a monolithic solve cannot stop early)
2nd Ctrl-C, or qTerminate gtopt (SIGTERM); the dashboard shows "stopping…"
3rd Ctrl-CKill gtopt (SIGKILL); also sent automatically 10 s after an unanswered SIGTERM
SIGTERM to run_gtoptForwarded to gtopt, same SIGKILL fallback

With --attach, q detaches and leaves gtopt running.

Exit status

CodeMeaning
0gtopt succeeded (also after a graceful stop or at the SDDP iteration limit; the banner says whether the run converged)
1gtopt: non-optimal solution or CLI error
2gtopt: input error; run_gtopt: usage error, missing binary, failed pre-flight checks or JSON sanitizing; --attach with no unique target
3gtopt: internal error
4only with --fail-on-not-converged: gtopt exited 0 but SDDP did not converge
Na converter's (plp2gtopt / plexos2gtopt) non-zero exit code
127the gtopt binary could not be started
128+Ngtopt was killed by signal N (134 SIGABRT, 137 SIGKILL / out of memory, 139 SIGSEGV, 143 SIGTERM); Ctrl-C before gtopt starts exits 130

All options

FlagDefaultDescription
CASE (positional)CWDPLP / PLEXOS directory, GTOpt directory, or JSON file
-t, --threads NCPU countSolver threads, written to solver_options.threads in the sanitized JSON
--solver NAMEgtopt's choiceLP solver plugin, forwarded as gtopt --solver NAME (a --solver after -- wins)
-C, --compression CODECgtopt's defaultOutput compression; only set when given (an unsupported codec for CSV output is dropped with a warning)
--convert-dir DIR (-o, --output-dir)—Output directory of the PLP / PLEXOS conversion (the solve output is gtopt's -d, pass it after --)
--plp-args ARGS—Extra arguments for plp2gtopt (quote the whole string)
--plexos-args ARGS—Extra arguments for plexos2gtopt (quote the whole string)
--check / --no-checkenabledRun the pre-/post-flight checks
--strictoffAbort on any pre-flight warning
--enable-check NAME—Run only the named check(s) (repeatable; replaces the default set)
--disable-check NAME—Skip a check (repeatable)
--list-checks—Table of checks with stage and default, then exit
--list—List live gtopt runs and exit
--attach [PID\|PATH]—Attach the dashboard to a running gtopt; without an argument, the only live run
--convert-onlyoffConvert the case but do not run gtopt
--export-json FILE—Write the sanitized planning JSON to FILE and keep it
--dry-runoffPrint the sanitize changes and the exact gtopt command line
--log-level LEVELINFODEBUG, INFO, WARNING, ERROR (-l is a deprecated alias)
--ui {auto,tui,plain}autoDashboard or line-oriented output
--no-tui, --plain—Same as --ui plain
--no-coloroffDisable colour (also NO_COLOR)
--asciiautoASCII-only dashboard (also GTOPT_TUI_ASCII=1)
--fail-on-not-convergedoffExit 4 when SDDP did not converge
-V, --version—Print version and exit
-- [ARGS]—Pass the remaining arguments to the gtopt binary

gtopt_check_json

Validates GTOpt JSON planning files and reports potential issues. Also serves as a quick system/simulation statistics tool (similar to gtopt --stats).

Basic usage

# Validate a JSON case and report issues
gtopt_check_json cases/ieee_9b/ieee_9b.json

# Print system/simulation statistics only (no validation)
gtopt_check_json --info cases/ieee_9b/ieee_9b.json

# Show detailed simulation structure (scenarios, stages, phases, apertures)
gtopt_check_json --show-simulation cases/sddp_hydro_3phase/sddp_hydro_3phase.json

# Validate multiple JSON files (merged before checking)
gtopt_check_json system.json overrides.json

# Run interactive configuration setup
gtopt_check_json --init-config

Validation checks

The tool runs configurable checks organized by severity:

SeverityColorMeaning
CRITICALRedIssues that will likely cause solver failure
WARNINGYellowPotential problems or suboptimal configurations
NOTECyanInformational observations

Individual checks can be enabled/disabled via --init-config or the configuration file (~/.gtopt.conf).

The schema_keys check walks the case against a snapshot of gtopt's C++ JSON contract (scripts/gtopt_shared/data/json_contracts.json, generated from include/gtopt/json by python -m gtopt_shared.json_contracts --update). Every key gtopt's strict parser would reject — a typo, a removed field such as Battery.gcost, or a model option written directly under options instead of options.model_options — is CRITICAL; naming-dialect aliases (accepted by gtopt) are reported as a NOTE.

The future_cost_aliases check validates the FutureCost element (system.future_cost_array): every deprecated boundary-cut key (sddp_options.boundary_*, monolithic_options.boundary_*, simulation.boundary_cuts_file / boundary_cuts_valuation) is reported as a WARNING naming its FutureCost replacement (or noting that the declared method ignores it), and the same field given with different values is CRITICAL — gtopt rejects such a case at load. Rewrite old cases with python tools/migrate_future_cost.py FILE....

Exit codes

CodeMeaning
0OK — no critical issues (warnings/notes may be present)
1Critical issues found

All options

FlagDefaultDescription
json_files (positional)—Path(s) to GTOpt JSON case files
--infooffPrint system/simulation statistics and exit
--show-simulationoffPrint detailed simulation structure
--config PATH~/.gtopt.confPath to configuration file
--init-configoffRun interactive configuration setup
--no-coloroffDisable colored output

gtopt_check_lp

Diagnoses infeasible LP files generated by the GTOpt solver. Combines static analysis, local IIS (Irreducible Infeasible Subsystem) solvers, and optional NEOS remote analysis to pinpoint the root cause of infeasibility.

Basic usage

# Analyze an LP file
gtopt_check_lp error_0.lp

# Analyze a gzip-compressed LP file
gtopt_check_lp error_0.lp.gz

# Auto-find the newest error*.lp[.gz] in the current directory
gtopt_check_lp --last

# Static analysis only (no solver invocation)
gtopt_check_lp error_0.lp --analyze-only

# Use a specific solver
gtopt_check_lp error_0.lp --solver coinor

# Submit to NEOS remote server (requires email)
gtopt_check_lp error_0.lp --solver neos --email user@example.com

# Run interactive configuration setup
gtopt_check_lp --init-config

Analysis pipeline

  1. Static analysis — parses the LP file directly:
    • Variables with conflicting bounds (lb > ub)
    • Empty or fixed constraints
    • Numerical range issues (very large/small coefficients)
    • Duplicate constraint names
    • Problem statistics (rows, columns, non-zeros)
  2. Local IIS finding — tries available solvers in order: CPLEX → HiGHS → COIN-OR CLP → CBC → GLPK
  3. NEOS remote analysis — submits to https://neos-server.org via XML-RPC using CPLEX (requires email)
  4. AI diagnostics (opt-in, --ai) — expert infeasibility diagnosis from Claude, OpenAI, DeepSeek, GitHub Models, or a local server. Off by default: it runs only when --ai is passed explicitly. Having an API key in the environment (or ai_enabled = true in ~/.gtopt.conf) never enables it. When enabled, the analysis report — including constraint and variable names from your model — is sent to the selected provider.

Quiet mode

When called with --quiet (used automatically by the gtopt binary and run_gtopt), the tool never fails (always exits 0), never prompts for input, and handles all errors gracefully with warnings.

The automatic runs by gtopt and run_gtopt also pass --no-neos and --no-ai: an LP of your case is never sent to the public NEOS server or to an AI provider unless you run gtopt_check_lp yourself and ask for it.

All options

FlagDefaultDescription
LP_FILE (positional)—Path to LP file (.lp, .lp.gz, .lp.gzip)
--lastoffAuto-find newest error*.lp[.gz]
--analyze-onlyoffStatic analysis only, no solver
-q, --quietoffNon-failing quiet mode
--solver SOLVERallSolver strategy: all, auto, cplex, highs, coinor, glpk, neos
--no-neosoffSkip NEOS submissions
--email EMAIL—Email for NEOS submissions
--output FILE—Write report to file
--aioffOpt in to AI diagnostics (sends the report to the provider)
--no-aionDisable AI diagnostics (default; kept for compatibility)
--ai-provider Pclaudeclaude, openai, deepseek, github, local
--ai-model Mprovider defaultModel name override
--ai-key KEYenv varAPI key override (else the provider's env var)
-v, --verboseoffVerbose logging
--config FILE~/.gtopt.confConfig file path
--init-configoffInteractive config wizard

gtopt_check_output

Validates and analyzes GTOpt solver output for completeness and correctness. Auto-discovers results and JSON files in a case directory.

Basic usage

# Analyze output in a case directory
gtopt_check_output cases/ieee_9b

# Explicit paths to results and JSON
gtopt_check_output -r output/ -j ieee_9b.json

# Quiet mode — only show warnings and critical findings
gtopt_check_output cases/ieee_9b --quiet

# Run interactive configuration setup
gtopt_check_output --init-config

Checks performed

  • Output completeness — verifies expected output files exist (solution.csv, generation_sol, balance_dual, etc.)
  • Load shedding analysis — detects unserved energy in fail_sol
  • Generation/demand balance — validates energy conservation
  • Line congestion ranking — identifies most congested transmission lines
  • LMP statistics — locational marginal price analysis
  • Cost breakdown — dispatches by generator cost tier
  • Loss arbitrage — per-line phantom circulation, loss inflation and idle-line loss, with a loss_cost_eps override snippet (--emit-overrides)
  • Loss eps acceptance — loss_cost_eps (ε, default 0.1 $/MWh) keeps fictitious losses unprofitable only while every bus price stays at or above −ε. Each bus-hour below −ε of its lossy lines is a WARNING loss eps invalidated: bus B block H lambda=λ < -eps=-ε, excess loss X MW on <lines>, where X is the booked loss beyond (R/V²)·f²

All options

FlagDefaultDescription
CASE_DIR (positional)CWDCase directory (auto-discovers JSON and results)
-r, --results-dir DIR—Explicit results directory
-j, --json-file FILE—Explicit planning JSON file
--no-coloroffDisable colored output
-q, --quietoffOnly show warnings and critical findings
-l, --log-level LEVELWARNINGVerbosity: DEBUG, INFO, WARNING, ERROR
--config FILE~/.gtopt.confConfig file path
--init-configoffInitialize config section
-V, --version—Print version and exit

gtopt_check_solvers

Discovers and validates GTOpt LP solver plugins by running a built-in test suite against each available solver. Useful for quickly verifying that solver backends (CLP, CBC, HiGHS, CPLEX, …) are correctly installed and produce correct results.

Basic usage

# List all available LP solver plugins
gtopt_check_solvers --list

# Check all available solvers (default)
gtopt_check_solvers

# Check a specific solver
gtopt_check_solvers --solver clp

# Check multiple specific solvers
gtopt_check_solvers --solver clp --solver highs

# Use an explicit gtopt binary path
gtopt_check_solvers --gtopt-bin /opt/gtopt/bin/gtopt

# Run only a subset of built-in tests
gtopt_check_solvers --test single_bus_lp --test kirchhoff_lp

# Verbose output (show failure details)
gtopt_check_solvers --verbose

Built-in test cases

Test nameDescriptionExpected status
single_bus_lpSingle-bus copper-plate LP: 1 generator, 1 demand0 (optimal)
kirchhoff_lp4-bus DC OPF with Kirchhoff voltage-angle constraints0 (optimal)
feasibility_lpFeasibility check: demand exactly at generator capacity0 (optimal)

For each test the tool:

  1. Writes the problem as a temporary GTOpt JSON file
  2. Calls gtopt <file> --solver <name> with a per-test timeout
  3. Reads output/solution.csv and validates status and obj_value

Exit codes

CodeMeaning
0All solvers and all tests passed
1At least one test failed (or no solvers found)
2Error: GTOpt binary not found or invalid path

All options

FlagDefaultDescription
--list, -loffList available solvers and exit
--solver SOLVER, -sallSolver to test (repeatable)
--test TEST, -tallTest case to run (repeatable; choices: single_bus_lp, kirchhoff_lp, feasibility_lp)
--gtopt-bin PATHauto-detectPath to the gtopt binary
--timeout SECONDS60Per-test timeout in seconds
--no-coloroffDisable colored output
-v, --verboseoffShow failure details
-V, --version—Print version and exit

Binary discovery

The tool searches for the gtopt binary in this order:

  1. GTOPT_BIN environment variable
  2. gtopt on PATH
  3. Standard build directories (build/standalone/gtopt, etc.)

gtopt_compress_lp

Compresses LP debug files generated by the GTOpt solver (when lp_debug=true or lp_only=true, i.e. CLI --lp-debug / --lp-only). Supports multiple compression formats and integrates seamlessly with the solver's post-solve workflow.

Basic usage

# Compress an LP file
gtopt_compress_lp file.lp

# Use a specific compression codec
gtopt_compress_lp file.lp --codec zstd

# Quiet mode (non-interactive, never fails)
gtopt_compress_lp file.lp --quiet

# Show available compression tools
gtopt_compress_lp --list-tools

# Run interactive setup
gtopt_compress_lp --init-config

Supported compressors

ToolExtensionNotes
zstd.zstRecommended — fast with excellent compression ratio
gzip.gzUniversally available
lz4.lz4Fastest compression/decompression
bzip2.bz2Best ratio for text files
xz.xzExcellent ratio, slower compression
lzma.lzmaSimilar to xz

Compression cascade

  1. Codec hint from --codec (if provided and available)
  2. Configured compressor from config file (auto → first available)
  3. First available tool found on PATH
  4. Skip compression (leave original unchanged)

All options

FlagDefaultDescription
FILE.lp (positional)—LP file(s) to compress
--init-configoffRun interactive setup wizard
--list-toolsoffShow available compression tools
--quietoffNon-interactive, never-fail mode
--codec CODEC—Codec suggestion: gzip, zstd, lz4, etc.
--compressor TOOL—Override configured compressor
--config PATH~/.gtopt_compress_lp.confConfig file path
--color {auto,always,never}autoTerminal color output
--version—Show version and exit

gtopt_check_fingerprint

Computes, verifies, and compares LP structural fingerprints — a SHA-256 hash of the sorted set of (class, variable, context_type) triples that captures which types of LP variables and constraints exist, independent of element counts. See LP Fingerprint for full details.

Basic usage

# Compute fingerprint from an LP file
gtopt_check_fingerprint compute problem.lp -o fingerprint.json

# Verify an LP file against a golden fingerprint
gtopt_check_fingerprint verify --lp-file problem.lp --golden golden.json

# Compare two fingerprint JSON files (structural only, ignores stats)
gtopt_check_fingerprint compare --actual actual.json --expected golden.json

Subcommands

SubcommandPurpose
computeParse an LP file and write a fingerprint JSON
verifyParse an LP file and compare against a golden JSON
compareCompare two fingerprint JSON files

Compute options

FlagDefaultDescription
LP_FILE (positional)—LP file to parse (.lp format)
-o, --outputstdoutOutput fingerprint JSON path

Verify options

FlagDefaultDescription
--lp-file—LP file to parse
--golden—Golden fingerprint JSON to compare against

Compare options

FlagDefaultDescription
--actual—Actual fingerprint JSON
--expected—Expected (golden) fingerprint JSON

Exit code 0 = match, 1 = structural mismatch. The stats section (element counts) is always ignored — only structural template and hash are compared.


gtopt_config

Unified configuration management library used by all GTOpt Python scripts. Reads and writes a single INI-format configuration file shared across tools.

gtopt_config is a library module, not a standalone command. It is used by gtopt_check_json, gtopt_check_lp, gtopt_check_output, run_gtopt, and gtopt_compress_lp.

Configuration file

Default location: ~/.gtopt.conf. The file uses INI format with a [global] section for shared settings, per-tool sections, and a [gtopt] section for the C++ binary:

[global]
ai_enabled  = false
ai_provider = claude
ai_model    =
color       = auto

[gtopt]
solver              = highs
algorithm           = barrier
threads             = 4
output-format       = parquet
output-compression  = zstd

[gtopt_check_json]
check_uid_uniqueness = true

[gtopt_check_output]
congestion_top_n = 10

[run_gtopt]
default_threads = 0

The [gtopt] section provides default values for the C++ binary's command-line options. CLI flags always take precedence. See Usage Guide for the full list of supported keys.

Initializing configuration

Each tool that uses gtopt_config provides an --init-config flag that runs an interactive setup wizard to create or update its section:

gtopt_check_json --init-config
gtopt_check_lp --init-config
gtopt_check_output --init-config
run_gtopt --init-config     # via run_gtopt --list-checks / --init-config

gtopt_monitor

Interactive solver monitoring dashboard for GTOpt. Polls the JSON status file written by the GTOpt solver (SDDP or monolithic) and displays live charts in two figure windows:

  • Figure 1 – Real-time charts: CPU load (%) and active worker threads vs wall-clock seconds.
  • Figure 2 – Iteration-indexed charts: objective upper/lower bounds per scene and convergence gap vs iteration number.
# Monitor the default output/solver_status.json
gtopt_monitor

# Specify a custom status file and polling interval
gtopt_monitor --status-file /path/to/solver_status.json --poll 2.0

# Headless mode (print to stdout, no GUI window)
gtopt_monitor --no-gui

# Query a planning option value
gtopt_monitor --get method --case-dir ./mycase
gtopt_monitor --get sddp_options.max_iterations --case-dir ./mycase

The tool exits when the solver reports "converged" or when you press Ctrl-C.

Text mode output

In headless mode (--no-gui), the tool prints a summary table to stdout:

[Time]  [Iter]  [LB]           [UB]           [Gap]      [Status]
  7.1s   45     12345.1234   12450.5678     0.008765   running

All options

FlagDefaultDescription
--status-file PATHoutput/solver_status.jsonPath to solver status file
--poll SECONDS1.0Polling interval
--no-guioffPrint to stdout instead of GUI windows

gtopt_field_extractor

Extracts field metadata from GTOpt C++ headers and generates Markdown or HTML documentation tables. Parses ///< Description [units] comments on struct member declarations and produces a table with columns: Field, C++ Type, JSON Type, Units, Required, Description.

Developer tool: it reads include/gtopt/ from a source checkout, so it is not installed as a command. Run it from scripts/:

# Dump all element tables to stdout as Markdown
python -m gtopt_field_extractor

# Write full HTML reference to a file
python -m gtopt_field_extractor --format html --output INPUT_DATA_API.html

# Extract only Generator and Demand elements
python -m gtopt_field_extractor --elements Generator Demand

Using with gtopt_guisrv and gtopt_websrv

Both services accept a ZIP archive containing the JSON configuration file and its associated Parquet/CSV data files. Use plp2gtopt -z to produce a ZIP that is ready to upload without any extra packaging step.

gtopt_guisrv (browser GUI)

  1. Start the GUI service:

    gtopt_guisrv
    # Open http://localhost:5001
  2. Click Upload case and select the .zip file produced by plp2gtopt -z.
  3. Edit the case if needed, then click Solve to submit it to the webservice.

The GUI answers only requests addressed to a loopback name or to its bind address (GTOPT_GUI_HOST). To reach it under another name (a reverse proxy or a LAN host name), list that name in GTOPT_GUI_ALLOWED_HOSTS (host or host:port, comma-separated). Scripted write requests must send the header X-GTOpt-GUI: 1 (the bundled web pages do).

For installation and service setup, see guiservice/INSTALL.md.

gtopt_websrv (REST API)

Submit a ZIP directly to the REST API:

curl -X POST http://localhost:3000/api/solve \
  -F "file=@my_case.zip"

The server runs the gtopt solver and returns a results ZIP containing the solution files.

For full API reference and deployment instructions, see webservice/INSTALL.md.

gtopt_check_pampl

Validates PAMPL (GTOpt constraint expression language) syntax and verifies that all LP column references resolve correctly for a given JSON planning file.

# Check all user constraints in a planning file
gtopt_check_pampl cases/mycase/mycase.json

# Verbose output showing each constraint and its resolution
gtopt_check_pampl cases/mycase/mycase.json --verbose

# Check only a specific constraint file
gtopt_check_pampl --constraint-file constraints.json cases/mycase/mycase.json

Common use cases

  • Verify new user constraints before running the solver
  • Diagnose resolution errors (unknown elements, bad expression syntax)
  • Confirm LP column names in constraint expressions match the actual LP

gtopt_check_cases

Checks every case of a case collection — a directory with a catalog.json, such as a checkout of the public gtopt-cases repository — against the catalog. Each case is built with gtopt --lp-only (case JSON + its application profile, run from a work directory outside the collection with input_directory pinned to the case) and its rows / cols / nnz are compared with size.lp. A match confirms that the gtopt build reads the inputs as intended.

gtopt_check_cases --repo ~/gtopt-cases -j 2 --threads 8
gtopt_check_cases --repo ~/gtopt-cases --only pcp_2025-10-19 --solve \
    --out ~/gtopt-cases-out                  # never inside the collection
gtopt_check_cases --repo ~/gtopt-cases --update   # refresh size.lp

--solve also solves the selected cases (output under --out/<case id>/output) and, with --results FILE ({"cases": [{"id": ..., "reference": {"objective": ...}}]}), compares the objective with relative tolerance --rtol. --cpus/--cpus-base pin jobs with taskset; core dumps are enabled for every gtopt run.

A solved case that sheds load is always flagged: the report line gets WARNING: unserved energy <MWh> in <N> block(s), peak <MW> (from Demand/fail_sol, weighted by the case's block durations), and the summary lists the cases with unserved energy. It is an ERROR (exit code 1) with --fail-on-unserved, or for a catalog entry with "serves_all_load": true (cases whose README says all load is served).

plp_compress_case

Compresses a PLP case directory for archival or transport, using xz compression on the data files.

# Compress a PLP case directory
plp_compress_case /path/to/plp/case

# Decompress
plp_compress_case --decompress /path/to/plp/case.tar.xz

# List contents
plp_compress_case --list /path/to/plp/case.tar.xz

A Bash variant plp_compress_case.sh is also available in the scripts/ directory for environments without Python.