MainOptions struct
#include <gtopt/gtopt_main.hpp>
Forward declaration; full type in gtopt/planning.hpp.
All command-line options consumed by gtopt_main().
Every field is optional so that callers only set what they need and can use designated-initializer syntax:
gtopt_main(MainOptions{ .planning_files = files, .use_single_bus = true, .print_stats = true, });
Public variables
- std::optional<LPAlgo> algorithm
- LP solution algorithm override. Mapped to solver_options.algorithm by apply_cli_options.
- std::optional<bool> allow_oversupply
- Relax the per-bus power balance from
=to≥(generation ≥ demand, free disposal of surplus). Bound to--allow-oversupply; shorthand for--set model_options.allow_oversupply=true. - std::optional<bool> async_logger
- Enable/disable the spdlog async logger wrapper.
- std::optional<std::string> build_mode
- LP build parallelism mode: "serial", "scene-parallel", or "full-parallel" (default). Routed to
planning.options.build_modebyapply_cli_options. SeeBuildModeinplanning_enums.hppfor the full contract. - std::shared_ptr<const MainOptions> config_defaults
- Planning-level defaults read from
.gtopt.conf[gtopt]. - std::optional<std::string> constraint_mode
- UserConstraint resolver strictness: "strict" (default — abort on any unresolved element reference), "normal" (drop a constraint when ALL terms are unresolved; emit a warning), "debug" (drop unresolved terms silently and continue). Pair "debug" with
plexos2gtopt --lax-uc-refsfor the matching converter-side leniency. - std::optional<double> cpu_quota
- CPU budget as a percentage of physical cores.
- std::optional<std::string> cut_directory
- Directory for Benders cut files (default: "cuts").
- bool dirs_auto_resolved
- True when input/output/log/cut directories were auto-resolved from a directory argument (not explicitly set by the user). Suppresses deprecation warnings in apply_cli_options.
- std::optional<bool> fcut_log
- Write the PLP-style feasibility-cut debug log.
- bool from_config_file
- True for a MainOptions loaded from a config file: suppresses the "--flag is deprecated" warnings (they name CLI flags).
- std::optional<std::string> input_directory
- Override for the input data directory.
- std::optional<std::string> input_format
- Input format override ("parquet", "csv", …).
- std::optional<std::string> json_file
- Path stem for writing the merged planning JSON.
- std::optional<std::string> log_directory
- Directory for log and trace files (default: "logs").
- std::optional<double> lp_coeff_ratio_threshold
- LP coefficient ratio threshold for numerical conditioning diagnostics. When the global max/min |coefficient| ratio exceeds this value, a per-scene/phase breakdown is printed. (default: 1e7).
- std::optional<std::string> lp_compression
- Compression codec for LP debug files.
""= auto (let gtopt_compress_lp decide);"none"= no compression;"gzip","zstd","lz4","bzip2","xz"= specific codec. - std::optional<bool> lp_debug
- Save debug LP files to the log directory (monolithic: one per scene/phase; SDDP: one per iteration/scene/phase).
- std::optional<std::string> lp_dump_backward
- Directory to dump backward-pass tgt LPs (one .lp file per
(iter, scene, phase)) immediately before eachtgt_li.resolve(opts). - std::optional<bool> lp_error
- Write an error LP file when a cell is infeasible (keeps the col/row name metadata needed for it; independent of lp_debug).
- std::optional<std::string> lp_file
- Path stem for writing the LP model file.
- std::optional<std::string> lp_format
- Format of the
lp_filedump: "lp" (default) or "mps". A.mpsextension onlp_filealso selects MPS. - std::optional<bool> lp_only
- Build all scene/phase LP matrices but skip solving entirely.
- std::optional<bool> lp_reduction
- Enable SOURCE zero-column/row elimination (default OFF). Bound to the CLI flag
--lp-reduction; shorthand for--set model_options.lp_reduction=true. For weak-presolve backends (CLP / CBC / HiGHS); CPLEX/Gurobi presolve reduces the un-reduced LP equivalently so they gain nothing. - std::optional<std::string> lp_scales
- Also write
<lp-file stem>.scales.json, a JSON sidecar with the objective scale, block weights and scaled columns/rows of every written LP file (see docs/lp-scales.md). - std::optional<double> matrix_eps
- Epsilon tolerance for LP matrix coefficients.
- std::optional<std::string> memory_limit
- Process memory limit for work pool throttling. Accepts an absolute value in MB, or a string with suffix: "300M" (megabytes), "5G" (gigabytes). 0 = no limit (default). Mutually exclusive with
memory_quota— when both are set,memory_quotawins (it is the higher-level convenience flag). - std::optional<double> memory_quota
- Memory budget as a percentage of total host RAM.
- std::optional<std::string> memory_saving
- Global memory-saving mode:
off/compress. - std::optional<double> mip_gap
- Target relative MIP optimality gap (CLI shortcut).
- std::optional<bool> mip_start_enable
- Enable the initial-MIP-solution (warm-start) pipeline (CLI flag).
- std::optional<std::string> naming_dialect
- Naming dialect enforced on input + output (CLI shortcut).
- std::optional<bool> no_lp_reduction
- Force-disable the SOURCE zero-column/row elimination (the default behaviour). Bound to
--no-lp-reduction; shorthand for--set model_options.lp_reduction=false. Useful to override a JSON file that setslp_reduction=true. - std::optional<bool> no_mip
- LP-relax every phase (
continuous_phases = "all"). - std::optional<bool> no_scale
- Disable every automatic scaling / equilibration mechanism.
- std::optional<std::string> output_compression
- Compression codec for parquet output ("gzip", "zstd", …).
- std::optional<std::string> output_directory
- Override for the output directory.
- std::optional<std::string> output_format
- Output format ("parquet", "csv").
- std::vector<std::string> planning_files
- Paths to planning JSON files (
planning.json). - std::optional<std::string> pricing_mode
- Post-MIP pricing method (CLI shortcut).
- std::optional<bool> print_stats
- Print pre- and post-solve system statistics.
- std::optional<bool> recover
- Enable recovery from a previous SDDP run.
- std::optional<std::string> root_basis_cache_file
- Cache/reuse the root LP basis across warm-start runs (CLI flag).
- std::optional<std::string> sddp_aperture_chunk_mode
- Backward-pass aperture grouping by name (
--aperture-chunk-mode): "per_scene" (default), "per_aperture" or "chunked". Validated viarequire_enum<ApertureChunkMode>when applied. - std::optional<int> sddp_aperture_chunk_size
- Apertures per task K for
chunked(--aperture-chunk-size; "auto"/0 = formula). Legacy mode selector when no mode is given (deprecated): -1 → per_scene, 1 → per_aperture, K > 1 → chunked K. - std::optional<double> sddp_convergence_tol
- SDDP relative convergence tolerance (default: 1e-4).
- std::optional<double> sddp_cpu_factor
- SDDP work pool CPU over-commit factor. Multiplied by hardware_concurrency to set max pool threads. Default 4.0 — extra threads compensate for clone mutex blocking.
- std::optional<std::string> sddp_elastic_mode
- SDDP elastic filter mode: "chinneck" (default), "single_cut", "multi_cut". Aliases: "iis" → chinneck, "cut" → single_cut.
- std::optional<double> sddp_elastic_penalty
- Penalty coefficient for SDDP elastic slack variables (default: 1000).
- std::optional<bool> sddp_hot_start
- Enable SDDP hot-start from previously saved cuts.
- std::optional<int> sddp_max_iterations
- Maximum SDDP forward/backward iterations (default: 100).
- std::optional<int> sddp_min_iterations
- Minimum SDDP iterations before convergence (default: 2).
- std::optional<int> sddp_num_apertures
- Number of SDDP backward-pass apertures (0=disabled, -1=all).
- std::vector<std::string> set_options
- Repeatable
--set key=valueoverrides. - std::optional<std::string> solver
- LP solver backend name ("clp", "cbc", "cplex", "highs"). When empty, auto-detects from available plugins.
- std::map<std::string, SolverOptions> solver_configs
- Per-solver default SolverOptions loaded from
.gtopt.conf. - std::optional<std::string> swap_growth
- VmSwap growth per 5 s window that counts as active swapping. Same size syntax as
memory_limit. Maps tosddp_options.pool_swap_growth_mb. Bound to--swap-growth. - std::optional<std::string> swap_limit
- Work-pool swap gate limit (process VmSwap). Same size syntax as
memory_limit("2048", "300M", "5G"); "0" disables the gate. Dispatch is throttled only while VmSwap is at/above this AND still growing (seeswap_growth). Maps tosddp_options.pool_max_process_swap_mb. Bound to--swap-limit. - std::optional<int> threads
- Number of solver threads override (0=automatic). Mapped to solver_options.threads by apply_cli_options.
- std::optional<double> time_limit
- Per-solve time limit in seconds (CLI shortcut).
- std::optional<std::string> trace_log
- Path to a file for SPDLOG_TRACE output (enables trace-level logging). When set, a dedicated file sink is added to spdlog so that all trace-level messages are captured for later review.
- std::optional<bool> use_kirchhoff
- Enable Kirchhoff voltage-law constraints.
- std::optional<bool> use_single_bus
- Enable single-bus (copper-plate) mode.
- std::optional<std::string> write_out
- Comma-separated list of output fields to emit (
solution,dual,reduced_cost, or aliasessol,cost,rcost,rc; alsoallandnone). Default (unset) emits every field. Routed toplanning.options.write_outbyapply_cli_options.
Variable documentation
std::optional<bool> gtopt:: MainOptions:: async_logger
Enable/disable the spdlog async logger wrapper.
Default (true / unset): the default logger is wrapped in an async_logger with bounded queue + overrun_oldest overflow policy + 2 worker threads. This isolates the solver's hot threads from sink I/O and prevents the queue-full deadlock that previously fired during cascade level transitions on the large hydrothermal case.
Set to false (--no-async-logger) to keep the synchronous default logger. Useful as a debug fallback when a future workload exposes a different async-logger pathology (e.g. silent drops under trace storms, drain stalls during signal handling). Costs a sink mutex on every log call from every solver thread, so expect a measurable slowdown on cascade transitions and parallel LP build — use only for diagnosis.
std::shared_ptr<const MainOptions> gtopt:: MainOptions:: config_defaults
Planning-level defaults read from .gtopt.conf [gtopt].
Precedence is "the more explicit, the closer to the run, wins": CLI flag > --set > planning JSON (last -s file wins) > .gtopt.conf > built-in default. The config-file values that have a planning-JSON counterpart are therefore NOT merged into the CLI fields above (that would let them beat the JSON and --set); they are kept here and applied by configure_planning only to the options the JSON left unset, before --set and the CLI flags (solver fills the planning pin lp_matrix_options.solver_name). Runtime-only keys with no JSON counterpart (lp-file, matrix-eps, stats, …) and the [solver.<name>] sections are merged into the fields above directly. Null when no config file was loaded.
std::optional<double> gtopt:: MainOptions:: cpu_quota
CPU budget as a percentage of physical cores.
When set during apply_cli_options, calls set_cpu_quota_pct(pct). This shrinks the value reported by physical_concurrency() for the rest of the process to ceil(detected × pct / 100) — every work-pool factory then sizes itself against the smaller base, so a cpu_factor=2.0 pool on a 9-core box with cpu_quota=30 ends up at max_threads=6 instead of 18. Values outside (0, 100) are treated as "unset" (no clamp).
Does not affect the LP solver's internal thread count — use --threads / per-solver settings for that.
Bound to --cpu-quota.
std::optional<bool> gtopt:: MainOptions:: fcut_log
Write the PLP-style feasibility-cut debug log.
Bound to the CLI flag --fcut-log; shorthand for --set sddp_options.fcut_log=true. When enabled, the SDDP forward pass appends one record per infeasibility event (detection line, emitted cut coefficients + RHS in physical units, install / HOLGURAS / FAIL outcome, rollback events) to gtopt_fcut.log in the resolved log directory — the gtopt analogue of PLP's plpfact.log (FactDBL ≥ 1), for cross-tool cut comparison. See docs/methods/sddp.md §5.4.
std::optional<std::string> gtopt:: MainOptions:: lp_dump_backward
Directory to dump backward-pass tgt LPs (one .lp file per (iter, scene, phase)) immediately before each tgt_li.resolve(opts).
When set, captures the LP exactly as the solver sees it (post-update_lp_for_phase, post-apply_post_load_replay under compress). Diff'ing the off and compress dumps for the same (iter, scene, phase) localises any non-replayed mutation that survives off but is dropped by compress's reconstruct. Zero overhead when unset.
Translation shim over the unified LP-debug mechanism: setting this flag is equivalent to passing --lp-debug --set sddp_options.lp_debug_passes=backward --log-directory <dir> (any pre-existing lp_debug_passes is preserved when it already mentions backward or all). The GTOPT_DUMP_BACKWARD_LP=<dir> env var is honoured as a fallback for scripts that pre-date the flag. Used during the off↔compress symmetry investigation to confirm LP byte-identity (50/50 phases md5-equal at iter 1 post-fix).
std::optional<double> gtopt:: MainOptions:: memory_quota
Memory budget as a percentage of total host RAM.
Sugar for memory_limit: when set, apply_cli_options reads MemTotal from /proc/meminfo and assigns pool_memory_limit_mb = total_mb × pct / 100. Values outside (0, 100) are treated as "unset".
Bound to --memory-quota.
std::optional<std::string> gtopt:: MainOptions:: memory_saving
Global memory-saving mode: off / compress.
Generalises the older --low-memory flag: when set, the CLI applies a coordinated set of memory-saving defaults across the whole run:
sddp_options.low_memory_mode=
(off / compress release policy for the flat-LP snapshot)
solver_options.memory_emphasis= true (solver-native hint; CPLEX'sCPX_PARAM_MEMORYEMPHASIS=1, ignored by backends that have no equivalent).
Users who want finer control can still set low_memory_mode or memory_emphasis directly in the planning JSON — the CLI is just the shortcut "turn everything on sensibly".
Implicit value (flag with no argument) is compress, which is the best balance: releases the solver backend between phases (big RAM win) while keeping the compressed flat LP so the next solve reconstructs in ~50 ms instead of a full re-flatten. The legacy rebuild value is accepted as a back-compat alias for compress (the dedicated rebuild mode was removed 2026-05-13 — see LowMemoryMode).
Bound to --memory-saving; --low-memory remains as a hidden deprecated alias for one release.
std::optional<double> gtopt:: MainOptions:: mip_gap
Target relative MIP optimality gap (CLI shortcut).
Bound to the CLI flag --mip-gap <value>. Forwards to solver_options.mip_gap; see the docstring there for backend mapping (CPLEX EPGAP, HiGHS mip_rel_gap, Gurobi MIPGap).
std::optional<bool> gtopt:: MainOptions:: mip_start_enable
Enable the initial-MIP-solution (warm-start) pipeline (CLI flag).
Bound to the CLI flag --mip-start (a bool toggle, default true when given without a value). Forwards to monolithic_options.mip_start.enabled. The staged controls (relax.*, round.threshold, dive.*, domain_rules.*, scip_repair.*, inject.effort, from_file, dump_file) are set via --set monolithic_options.mip_start.<stage>.<field>=<value>.
std::optional<std::string> gtopt:: MainOptions:: naming_dialect
Naming dialect enforced on input + output (CLI shortcut).
Bound to the CLI flag --naming-dialect <name>. Forwards to model_options.naming_dialect; see the docstring there for the full semantics (input warn + output JSON rename).
std::optional<bool> gtopt:: MainOptions:: no_mip
LP-relax every phase (continuous_phases = "all").
Bound to the CLI flag --no-mip. When set, every integer / binary variable becomes continuous regardless of phase configuration — useful for quick LP smoke tests on cases that would otherwise solve a MIP (commitment, segment-based costs, etc.). Equivalent to --set model_options.continuous_phases=all.
std::optional<bool> gtopt:: MainOptions:: no_scale
Disable every automatic scaling / equilibration mechanism.
When true, the CLI forces:
model_options.scale_objective = 1.0(no obj divisor)model_options.scale_theta = 1.0(no Kirchhoff angle scale)lp_matrix_options.equilibration_method = none
Intended for debug / physical-unit validation runs where you want the LP coefficients in their raw data-layer units, at the cost of potentially much higher solver kappa. Bound to the CLI flag --no-scale. A user-explicit JSON setting of any of the three fields takes precedence (the override only fills in what the JSON leaves unset).
std::vector<std::string> gtopt:: MainOptions:: planning_files
Paths to planning JSON files (planning.json).
At least one file is required. When multiple files are given they are merged in order (later files override earlier ones). Each file may be:
- a full path to a
.jsonfile, - a stem without extension (the
.jsonsuffix is appended), or - a directory name (resolved to
dir/dir.json).
std::optional<std::string> gtopt:: MainOptions:: pricing_mode
Post-MIP pricing method (CLI shortcut).
Bound to the CLI flag --pricing-mode <fixed|relaxed|fast_start>. Forwards to model_options.pricing_mode; see the docstring there.
std::optional<bool> gtopt:: MainOptions:: recover
Enable recovery from a previous SDDP run.
When true, the JSON recovery_mode setting takes effect (default "full"). When false or unset, recovery_mode is forced to "none" regardless of the JSON configuration — i.e. recovery only happens when the user explicitly passes --recover on the command line.
std::optional<std::string> gtopt:: MainOptions:: root_basis_cache_file
Cache/reuse the root LP basis across warm-start runs (CLI flag).
Bound to --root-basis-cache <path>. Forwards to monolithic_options.mip_start.root_basis_cache_file. On the FIRST run the file is absent → solve cold, then persist the root LP basis; on LATER runs the file is loaded and installed before the MIP solve so CPLEX enters the root at the optimal vertex (primal simplex, ≈0 iterations), skipping the cold barrier+crossover.
std::vector<std::string> gtopt:: MainOptions:: set_options
Repeatable --set key=value overrides.
Each entry is a dotted.path=value string that maps to a field in the Planning options JSON structure. Values are auto-typed: true/false → bool, integers → int, decimals → double, otherwise → string. Applied as a JSON overlay merged into Planning after file parsing but before specific CLI flags.
Example: --set sddp_options.forward_solver_options.threads=8
std::map<std::string, SolverOptions> gtopt:: MainOptions:: solver_configs
Per-solver default SolverOptions loaded from .gtopt.conf.
Keys are solver names ("cplex", "highs", "clp"). Populated from [solver.cplex], [solver.highs], etc. sections in the config file. The matching entry is overlaid on top of the backend's optimal_options() before applying user-explicit solver_options.
std::optional<double> gtopt:: MainOptions:: time_limit
Per-solve time limit in seconds (CLI shortcut).
Bound to the CLI flag --time-limit <seconds>. Forwards to solver_options.time_limit. Applied to every LP / MIP solve as a wall-clock budget shared by its fallback retries and MIP-start stages; the solver aborts when the budget is exhausted.