Skip to content

Draw evacuation antennas in the reduced overflow graph - #80

Merged
marota merged 2 commits into
masterfrom
claude/evacuation-antenna-layer
Nov 17, 2026
Merged

marota merged 2 commits into
masterfrom
claude/evacuation-antenna-layer

Conversation

@marota

@marota marota commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

An evacuation antenna is a part of the grid whose net production leaves through a single node of the constrained path, or through several when it is insensitive. Its report is insignificant, so its edges are gray. Yet it is a lever: curtailing or redispatching its production relieves the constraint.

The reduced overflow-graph view (plot(without_gray_edges=True), i.e. DRAW_ONLY_SIGNIFICANT_EDGES downstream) deletes gray edges and then isolated nodes, so the antenna disappears entirely.

Real case: Vendée full-France snapshot, contingency MERLAL62SOULL, overload on PALLUL41ZGARA. The Vent des Îles offshore park (234 MW, 7 substations, 14 branches) hangs off the constrained path at SOULLP4. The reduced view showed none of it, only SOULLP4.

expert_op4grid_recommender already detects these antennas and stamps in_evacuation_antenna on their nodes and branches (its "structural antennas" detection).

Change

  • OverflowGraphRenderer.prepare_for_plot builds the graph actually drawn; plot uses it.
    • The reduced view keeps the gray edges flagged in_evacuation_antenna, and therefore the antenna nodes.
    • These edges are drawn in ochre: EVACUATION_ANTENNA_COLOR = "darkgoldenrod".
    • Otherwise they follow the same conventions as every other edge: report label and arrow. The nodes keep their injection colours.
  • Drawing on a copy. The model's colours are analysis data: Structured_Overload_Distribution_Graph builds its blue / red views by deleting colours, and downstream discovery rebuilds those views after the drawing. Repainting the model would change the constrained path, loops and hubs.
    • A drawn antenna edge records base_color="gray", so edge_role_of still reads it as insignificant.
    • An antenna edge with a significant report keeps its colour.
    • Without any flagged edge, the full view still draws the graph itself, as before.
  • delete_color_edges(..., keep_flags=()). An edge carrying one of the given boolean flags survives; is_flag_set also accepts the "True" strings produced by DOT. The analysis views never pass it, so their behaviour is unchanged.
  • Interactive viewer. New semantic layer Evacuation antennas (in_evacuation_antenna, nodes and edges) in the Structural Paths section, with an ochre glyph. It lets the operator show the antenna alone or hide it.
  • Docs. CHANGELOG (Unreleased), CLAUDE.md, docs/ARCHITECTURE.rst (semantic flags, renderer, and the glyph a new semantic layer needs) and the model docstring.

Tests

  • test_overflow_renderer.py::TestEvacuationAntennas:
    • flagged gray edges are kept in the reduced view and restyled, while the other gray edges and isolated nodes are dropped;
    • the role stays insignificant, the report label stays and no arrow override is added;
    • a significant antenna edge keeps its colour;
    • the full view restyles on a copy, and without antennas it draws the graph itself;
    • the model graph is untouched.
  • TestPlotDrawsThePreparedGraph: plot hands the printer the prepared graph, and the layout of exactly the nodes it keeps, in their order.
  • test_graph_utils.py: keep_flags spares flagged edges and their nodes, including flags that went through DOT.
  • test_interactive_html.py:
    • the antenna layer is emitted in Structural Paths, and its colour does not become a flow-polarity layer;
    • every semantic layer's swatch has a glyph in viewer.js.
  • CI command (pytest --ignore=alphaDeesp/tests/pypownet/ --ignore=alphaDeesp/tests/test_cli.py --ignore=alphaDeesp/tests/test_expert_rules.py): 460 passed.
  • End to end with expert_op4grid_recommender on the snapshot above:
    • the reduced view goes from 26 nodes / 36 edges to 33 / 50, with the 7 antenna substations and 14 branches in ochre;
    • the viewer's Evacuation antennas layer holds 7 nodes and 14 edges.

Impact

Rendering only: no analysis output changes. Callers that never stamp in_evacuation_antenna get exactly the previous drawing.

expert_op4grid_recommender will raise its expertop4grid floor once this is released.

🤖 Generated with Claude Code

Antoine Marot and others added 2 commits November 17, 2026 19:01
An evacuation antenna is a part of the grid whose net production leaves
through a single node of the constrained path (or several, when
insensitive). Its report is insignificant, so its edges are gray, and
the reduced view (without_gray_edges) dropped it entirely, although it
is a lever. expert_op4grid_recommender detects these antennas and
stamps in_evacuation_antenna on their nodes and branches.

- OverflowGraphRenderer.prepare_for_plot builds the graph actually
  drawn. The reduced view keeps the flagged gray edges and the antenna
  nodes. The edges are drawn in ochre (EVACUATION_ANTENNA_COLOR,
  darkgoldenrod) and keep their report label and arrow like any other
  edge; the nodes keep their injection colours. It works on a copy:
  the model's colours are analysis data
  (Structured_Overload_Distribution_Graph builds its views from them).
  A drawn antenna edge keeps base_color="gray", and an antenna edge
  with a significant report keeps its colour.
- delete_color_edges gains keep_flags: an edge carrying one of these
  boolean flags survives. The analysis views never pass it.
- The interactive viewer gains an "Evacuation antennas" layer in the
  Structural Paths section, with its glyph.

Tests: flagged edges kept and restyled on a copy, the model left
untouched, the plain full view unchanged; keep_flags, including flags
that went through DOT; the antenna layer and its section; every
semantic layer swatch has a glyph in viewer.js. On a full-France
snapshot (contingency MERLAL62SOULL), the reduced view goes from 26 to
33 nodes with the 7 substations and 14 branches of the Vent des Îles
offshore park antenna.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
- test_overflow_renderer: plot hands the printer the graph that
  prepare_for_plot builds, and the layout of exactly the nodes it keeps,
  in their order, when the reduced view keeps an evacuation antenna.
  The printer is replaced in plot's own globals, because other tests
  reload the graphs modules.
- docs/ARCHITECTURE.rst: a new semantic layer also needs its swatch
  glyph in assets/viewer.js, which a test now checks.
- Import order in test_overflow_renderer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
@marota
marota merged commit 680adfb into master Nov 17, 2026
2 checks passed
@marota marota mentioned this pull request Nov 17, 2026
marota pushed a commit that referenced this pull request Nov 17, 2026
Bump version 0.3.3 -> 0.3.4 (setup.py, docs/conf.py, download_url) and
date the 0.3.4 CHANGELOG entry: evacuation antennas in the overflow
graph drawing (PR #80). The reduced view keeps them, in ochre with their
report; the interactive viewer gets an "Evacuation antennas" layer;
delete_color_edges gains keep_flags; plot is tested with a fake printer.
Rendering only: the analysis outputs are unchanged.

Checked: the CI command passes (460 tests), and `python -m build`
builds expertop4grid-0.3.4 (sdist and wheel) with the viewer assets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
marota pushed a commit to ainetus/Expert_op4grid_recommender that referenced this pull request Nov 17, 2026
Evacuation antennas were dropped from the reduced overflow graph: their
branches are gray and the drawing deletes gray edges. The rendering is
done in ExpertOp4Grid (ainetus/ExpertOp4Grid#80). The reduced view
keeps the branches flagged in_evacuation_antenna and draws them in
ochre with their report and arrow, like any other edge, and the
interactive viewer gets an "Evacuation antennas" layer. The drawing
works on a copy: alphaDeesp derives the analysis views from the edge
colours, and discovery rebuilds them after the drawing, so repainting
the analysis graph here would change the recommendations.

No code change here: tag_structural_antennas already stamps the flag
(its docstring now says who reads it). The plan, the CHANGELOG and the
docs index record phase 3. The expertop4grid floor will be bumped with
the release that ships it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
marota pushed a commit to ainetus/Expert_op4grid_recommender that referenced this pull request Nov 17, 2026
- test_injections: alphadeesp_node_injections gives one prod / load
  value per flagged substation, read the way alphaDeesp's build_nodes
  reads them (both observation flavours), sums the units of a
  substation, keeps a pump-only substation flagged with a negative
  production, and skips elements it cannot locate.
- test_structural_antennas: phase 3 contract with ExpertOp4Grid's
  renderer. The reduced view keeps the branches tagged
  in_evacuation_antenna, in the renderer's colour, and prunes a
  consumption antenna; the analysis graph keeps its colours. Skipped
  until the installed expertop4grid ships prepare_for_plot
  (ainetus/ExpertOp4Grid#80); passes against that branch.
- Docs: CLAUDE.md (injections helper, renderer contract, key-files
  rows, test list) and the islanded-pocket doc's _build_topo, which now
  emits alphaDeesp's compact node shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
marota pushed a commit to ainetus/Expert_op4grid_recommender that referenced this pull request Nov 17, 2026
expertop4grid 0.3.4 (ainetus/ExpertOp4Grid#80, release v0.3.4, now on
PyPI) ships the renderer that keeps the evacuation antennas in the
reduced overflow graph and the viewer's "Evacuation antennas" layer.
Phase 3 is therefore done.

- pyproject.toml: expertop4grid>=0.3.4 (was >=0.3.3); requirements.txt
  pins 0.3.4. CLAUDE.md and the README (still saying >=0.2.8) follow.
- Plan (phase 3 done), docs index, CHANGELOG (released, plus a Changed
  entry for the floor).
- The drawing contract test now says it needs 0.3.4 and is only skipped
  on an older, stale install.

Checked against the published package (installed in a scratch folder,
first on PYTHONPATH): 2119 passed, and the drawing contract test runs
and passes. The 5 failures are the known unrelated ones: 4 manoeuvre
goldens of local untracked scenarios, and the grid2op reproducibility
test, which fails the same way on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
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