Skip to content

Replace go with gridops#11

Open
keremakdemir wants to merge 6 commits into
mainfrom
gridops
Open

Replace go with gridops#11
keremakdemir wants to merge 6 commits into
mainfrom
gridops

Conversation

@keremakdemir

Copy link
Copy Markdown
Collaborator

Overview

This PR replaces the go package with gridops, a ground-up refactor of the production cost model focused on solver performance, warm-start support, and a cleaner API. The package is renamed from go to gridops.

Core Architecture Change: AbstractModel → ConcreteModel

  • go used Pyomo's AbstractModel, requiring a preprocessor step to generate a large .dat file from multiple CSV/NPY files before each simulation.
  • gridops uses Pyomo's ConcreteModel, built directly from Python data structures. All CSV/NPY files are loaded once into a dictionary. The model is constructed once and reused across all 365 horizons — only mutable parameters (demand, renewables, fuel prices, outages, etc.) are updated between solves.

Performance Improvements

  • Variable bounds replace explicit constraint rowsFlow, SoC, Charge, and Discharge variables now carry their bounds directly instead of through separate constraint rows, reducing LP size.
  • Pre-computed sparse lookup dicts (_gens_at_bus, _lines_at_bus, _storage_at_bus, etc.) eliminate Cartesian product iteration in constraint and objective construction.
  • Default solver parameters for HiGHS and Gurobi — automatically set when warmstart=False for both HiGHS and Gurobi interfaces to speed up the convergence.
  • Named constants replace static numbers (SLACK_PENALTY, RENEWABLE_GEN_COST, PU_BASE_MVA, etc.).

New: Warm-Start Support

  • New warmstart parameter on Model (default False), overridable per run() call.
  • _resolve_warmstart() enforces solver-specific policies:
    • appsi_highs: warm-start uses simplex with crossover off (persistent basis reuse); cold-start defaults to IPM + crossover.
    • appsi_gurobi: warm-start sets LPWarmStart=1; cold-start sets LPWarmStart=0 + PreDual=1.
    • gurobi: warm-start auto-switches to appsi_gurobi with a warning.
  • Cold-start horizons call clearSolver() on the APPSI persistent interface to force fresh presolve.

API Changes

  • complexity parameter removed — was always "multi", no longer needed.
  • CPLEX removed, appsi_gurobi added as a supported solver interface.
  • highspy>=1.10.0 added as a required dependency.
  • numpy upper bound (<2) removed.

Retry Logic

  • Retry configuration centralized in a module-level HIGHS_RETRY_DEFAULTS dict, overridable via retry_options parameter on run() (replaces long positional argument lists).
  • Gurobi retry now sweeps random seeds only (with a separate MAX_RANDOM_SEED_GUROBI cap).
  • New fresh_start and clear_restart parameters for restart file lifecycle management.

Build System & Tests

  • setup.py + requirements.txt → single pyproject.toml (Hatchling backend).
  • New tests: test_configuration.py, test_solvers.py, test_west_integration.py (ConcreteModel construction validation). Expanded test_utilities.py coverage (restart file versioning, backoff, cleanup).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant