Repository navigation
Conversation
…t-only relief (#134) - Study area from substation tiers (transformers join buses, lines are hops, default depth 3) instead of k nearest buses; five affected-element lists; new set_shunt command; mutation-driven contingency sweep. - Verdict line and table of every failed contingency; per-element failure counts for N-2; studies over 500 contingencies are reported as not completable instead of being shrunk. - Agent's full findings kept in the journal, CSV and saved session. - Relief: tap change, line switching out or in, tiered load shedding capped at 10% per bus; added load never shed; generator_redispatch removed; relief only when the goal asks; relief in the sweep cache key. - Objective extraction no longer invents objectives or limits. - Prompt templates moved to prompts/exago/; restored identical-sweep rule. - Live opflow test no longer overwrites tests/fixtures/sample_opflow_output.txt; test_solve_time matches the committed sample. Co-authored-by: tsybinae <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
First build of the GridKit side of AgentiGrid (--tool gridkit). The LLM picks a fault screen; AgentiGrid adds bus faults to a copy of the GridKit case, runs DynamicSimulation, applies PJM M-14B stability checks and returns a verdict. PJM tests that need elements GridKit does not have are reported as SKIPPED. New: gridkit_parsers/, gridkit_engine/, prompts/gridkit/, tests/gridkit/. Changed: cli.py (--tool flag), README.md and the GridKit folder READMEs, tests/README.md. No ExaGO code changed. Co-authored-by: tsybinae <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After #135 GridKit ran only from the operating point stored in its own case files. If something was solved by ExaGO, it would not be transferred to GridKit. This PR completes the folder strucutre and adds a GridKit fault screen start from the most recent ExaGO steady state. A transient study can run on top of the latest ExaGO result. A screen can also run all of its faults in one GridKit
ContingencyAnalysisprocess.Old approach
New approach
Changes
ExaGO folders and output
engine/→exago_engine/,parsers/→exago_parsers/(files unchanged). Imports,patch("agentigrid.engine...")strings in tests and logger names updated in 76 files; logger names followagentigrid.exago_engine..., as GridKit's do. Docs updated:README.md,tests/README.md,agentigrid_architecture.md,launcher/ARCHITECTURE.md.cli.py:exago_output()puts ExaGO runs inworkdir/exago/and logs inlogs/exago/(GridKit already usedgridkit/subfolders). The steeringsavecommand (was hard-coded toworkdir/) andregenerate-reportfollow it.exago_engine/executor.py: OPFLOW and PFLOW run with-save_output, which writes the solved case (opflowout.m/pflowout.m) into the run folder. Other applications are unchanged.One config for both tools (
config.py,configs/*.template)gridkit:section:binary_dir,dynamicsimulation_binary,timeout;study:(tmax,dt_monitor,rel_tol,abs_tol,dt_fixed,max_steps,max_order), written one-to-one into each run's solver.json;fault: start. LLM, iteration limit, worker count and output folders stay shared.tmax15 s,timeout600 s, fault start 1 s), so behaviour and the LLM prompt text are unchanged with defaults.gridkit_engine/criteria.pywith their sources.max_orderis outside 1-5,dt_monitor <= 0, or the fault starts at or aftertmax.gridkit_engine/settings.py,executor.py,agent_loop.py,commands.py,schema_description.pyread the configured values.Start from the latest ExaGO steady state (new
gridkit_engine/from_exago.py)find_latest_steady_state: newestjournal_*.jsoninworkdir/exago/, its last simulation, the run folder from the recorded-netfile. Error if that simulation did not converge, was a sweep, was not OPFLOW/PFLOW, or has no saved solution.apply_steady_statematches the solved MATPOWER case to the GridKit case:init Vr, Vifrom the solvedVm, Vap0, q0from the solvedPg, Qg; machines of generators that are off in ExaGO are removed with every device on their signals (governor, exciter, stabilizer), and unused signals are removedLoadZIPper bus fromPd, Qd; shunts: a separate constant-impedanceLoadZIPfromGs, Bsconverged = 0(ExaGO writes the OPFLOW flag there), so convergence is read from the journal.commands.py: new fault-screen fieldstart_from("case"default,"latest_steady_state"). Each start is built once per session and must pass its own no-fault run first; the converted case is saved asfrom_exago.case.jsonin the session folder.agent_loop.py: if the goal asks for the most recent steady state and the LLM sends"start_from": "case", the screen is rejected and the LLM is told to set it. The journal, verdict line and final summary name the ExaGO iteration and file used.cli.py:--from-exagouses the ExaGO start for the whole session.ContingencyAnalysis (
gridkit_engine/executor.py,modifier.py,gridkit_parsers/status_parser.py)application:"DynamicSimulation"(default) or"ContingencyAnalysis".run_contingencyruns all faults of a screen in one process, writesoutput_<fault index>.csvper fault in the screen's folder, and splits the shared console output into a status per fault. Timeout = per-run timeout × number of faults.ContingencyAnalysisruns every fault device in the file, so its case copy keeps only the requested faults (fault devices shipped with the case, such as the demo fault at bus 149 in ACTIVSg200, are left out). WithDynamicSimulationthey stay in the copy but are never switched on.Complete in 1.91939s).Prompt (
prompts/gridkit/system_prompt.py)"buses": [<bus>]). The POI screen with neighbours ("poi","hops") is used only when the goal asks for nearby buses, a depth or the PJM POI screen.start_fromandapplicationare set only when the goal asks for them; the answer states the operating point used.Tests
tests/gridkit/:test_config.py(gridkit section, defaults, warnings, solver keys in the.json),test_from_exago.py(journal lookup, no fallback, conversion on ACTIVSg200, generator without model, bus mismatch,-save_outputonly for OPFLOW/PFLOW),test_screen_options.py(start_fromandapplication, live on IEEE39 and ACTIVSg200 when GridKit is linked).test_status_parser.pycovers the ContingencyAnalysis completion line.Testing
python -m pytest -m "not slow"). The 46 new GridKit tests pass, including the live runs.gpt-4o, OPFLOW with Ipopt/MUMPS, GridKit at cdb77263. Fault: bus short circuit to ground at 1 s, cleared after 6.25 cycles (0.104 s), 15 s simulated. The ExaGO study removed the generator at the bus; the GridKit study then faulted the same bus.RelWithDebInfo(as in GridKit's CI); the build is selected withgridkit.binary_dir.Known issues
final_voltagefails a bus that the OPF holds exactly at its 1.1 pu limit when GridKit ends 1e-6 pu above it (bus 100 in the ACTIVSg200 runs: 1.100000 → 1.100001 pu). This is a false failure; a small tolerance would fix it. Not changed here.BusFault(replaced byBus::setFault); AgentiGrid's fault runs useBusFaultdevices and need adapting before moving past cdb77263.Release(-O3):ReecbEnzyme.cppfails with Enzyme errors;RelWithDebInfo(-O2) builds and passesctest(70/70).configs/env_setup.sh; one SOPFLOW test needs output from a real EMPAR run; two backend tests needANTHROPIC_API_KEY/OPENAI_API_KEY.Produced with help of Claude Code, but not exclusively by Claude.