Skip to content

test: integration test dc solver fitness versus validation fitness#507

Merged
spetznick-elia merged 75 commits into
mainfrom
copilot/start-implementation
May 28, 2026
Merged

test: integration test dc solver fitness versus validation fitness#507
spetznick-elia merged 75 commits into
mainfrom
copilot/start-implementation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

This PR adds PST-focused integration coverage that cross-checks DC-solver fitness metrics against Powsybl-based validation, and introduces a new “parallel PST” example grid plus supporting fixture updates across packages.

Changes:

  • Add new AC/DC integration tests comparing overload_energy_n_1 between DC solver aggregation and Powsybl runner validation for multiple PST scenarios.
  • Introduce a new Powsybl example grid (parallel_pst_example) and corresponding preprocessed data-folder helper in dc_solver_pkg.
  • Refactor/update test fixtures to rely on centralized example-grid preprocessing helpers (and rename a DC-solver test fixture).

Checklist

Please check if the PR fulfills these requirements:

  • PR Title follows conventional commit messages
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • All commits in this PR are DCO signed-off (see CONTRIBUTING.md)

Does this PR already have an issue describing the problem?

Tracked by existing issue context in this PR flow.

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change?

  • Yes
  • No
Original prompt

Start implementation

The user has attached the following file paths as relevant context:

  • .github/copilot-instructions.md
[Chronological Review: The conversation began with the user reporting a failure in the test case `test_dc_optimizer_fitness_ac_validation_fitness_parallel_pst` due to discrepancies in the computation of N-1 overload energy between validation and the DC solver. The user requested to investigate the differences despite equal computations of N-1 loadflows. The user then indicated to start the implementation phase.]

[Intent Mapping:

  • User reported a test failure: "This test case fails, due to a difference in the computation of N-1 overload energy..."
  • User requested to investigate the discrepancy: "Figure out why there is a difference in the computation of metrics..."
  • User indicated readiness to proceed with implementation: "Start implementation."]

[Technical Inventory:

  • Technologies mentioned: pytest for testing, pypowsybl for network loading and DC load flow computations, and fsspec for file system operations.
  • Key functions: parallel_pst_data_folder, load_grid, pypowsybl.network.load, pypowsybl.loadflow.run_dc, and net.save.
  • Concepts: N-1 overload energy computation, validation metrics, and DC solver metrics.]

[Code Archaeology:

  • File discussed: test_ac_dc_integration.py.
  • Key function: test_dc_optimizer_fitness_ac_validation_fitness_parallel_pst, which sets up a test environment using a fixture and runs a DC load flow analysis.
  • Recent code excerpt: fixture_name = "three_node_pst_example_data_folder" indicates the use of a specific data folder for testing.]

[Progress Assessment:

  • Completed: User has identified a test case that fails due to metric discrepancies.
  • Pending: Investigation into the differences in metric computations and implementation of solutions.]

[Context Validation: All necessary context for continuing the investigation into the test failure and the implementation of solutions is captured.]

[Recent Commands Analysis:

  • Last Agent Commands: User requested to start implementation after identifying a test failure.
  • Tool Results Summary: No specific tool results were returned as the focus was on the user's request to investigate and implement.
  • Pre-Summary State: The agent was preparing to assist with the implementation phase after the user indicated readiness to proceed.
  • Operation Context: The commands were executed in the context of addressing a test failure and preparing for implementation.]
1. Conversation Overview: - Primary Objectives: User aims to resolve a test failure in `test_dc_optimizer_fitness_ac_validation_fitness_parallel_pst` due to discrepancies in N-1 overload energy computations. User requested to investigate the differences and indicated readiness to start implementation. - Session Context: The conversation transitioned from identifying a test failure to preparing for implementation. - User Intent Evolution: Initially focused on troubleshooting the test failure, the user shifted to readiness for implementation.
  1. Technical Foundation:
  • pytest: Used for testing framework.
  • pypowsybl: Library for network loading and DC load flow computations.
  • fsspec: Used for file system operations.
  1. Codebase Status:
  • File Name: test_ac_dc_integration.py
  • Purpose: Contains tests for DC optimizer fitness validation.
  • Current State: User is investigating a failure in the test case.
  • Key Code Segments:
    • def test_dc_optimizer_fitness_ac_validation_fitness_parallel_pst(tmp_path_factory: pytest.TempPathFactory) -> None: sets up the test environment.
    • fixture_name = "three_node_pst_example_data_folder" indicates the data folder used for testing.
  • Dependencies: Relies on pypowsybl for network operations and fsspec for file handling.
  1. Problem Resolution:
  • Issues Encountered: Discrepancy in N-1 overload energy computations between validation and DC solver.
  • Solutions Implemented: None yet, as the user is in the investigation phase.
  • Debugging Context: Ongoing analysis of metric computation differences.
  • Lessons Learned: Understanding of how different metrics can yield discrepancies despite similar loadflow computations.
  1. Progress Tracking:
  • Completed Tasks: Identification of the test failure.
  • Partially Complete Work: Investigation into metric discrepancies is ongoing.
  • Validated Outcomes: None confirmed yet as the investigation is still in progress.
  1. Active Work State:
  • Current Focus: Investigating the differences in metric computations related to the test failure.
  • Recent Context: User indicated readiness to start implementation after identifying the issue.
  • Working Code: The test function test_dc_optimizer_fitness_ac_validation_fitness_parallel_pst is the focus of the investigation.
  • Immediate Context: User is looking to understand why the metrics differ despite equal computations.
  1. Recent Operations:
  • Last Agent Commands: User requested to sta...

Created from VS Code.

BenjPetr and others added 30 commits May 20, 2026 12:31
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
…near_only' into feat/integration-test-pst

Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
…near_only' into feat/integration-test-pst

Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
@spetznick-elia spetznick-elia changed the title fix: exclude basecase from N-1 metric aggregation in AC validation metrics test: integration test dc solver fitness versus validation fitness May 28, 2026
@spetznick-elia spetznick-elia mentioned this pull request May 28, 2026
6 tasks
@spetznick-elia spetznick-elia marked this pull request as ready for review May 28, 2026 09:35
Copilot AI review requested due to automatic review settings May 28, 2026 09:35
Copy link
Copy Markdown
Collaborator

@spetznick-elia spetznick-elia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

LeonHilf
LeonHilf previously approved these changes May 28, 2026
Copy link
Copy Markdown
Collaborator

@LeonHilf LeonHilf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds PST-focused integration coverage that cross-checks DC-solver fitness/overload metrics against Powsybl-based validation, and introduces a new “parallel PST” example grid plus supporting preprocessing helpers and fixture refactors across packages.

Changes:

  • Added new AC/DC integration tests comparing overload_energy_n_1 between DC-solver aggregation and Powsybl validation across multiple PST scenarios.
  • Introduced a new parallel_pst_example() Powsybl grid and new centralized “preprocessed data-folder” helper functions in dc_solver_pkg.
  • Updated/centralized fixtures and added targeted preprocessing tests (e.g., operational-limit side voltage handling).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/topology_optimizer_pkg/tests/test_ac_dc_integration.py Adds integration tests that compare DC-solver metric aggregation vs Powsybl validation across PST tap scenarios.
packages/topology_optimizer_pkg/tests/conftest.py Refactors grid-prep fixtures to rely on centralized preprocessing helpers.
packages/grid_helpers_pkg/src/toop_engine_grid_helpers/powsybl/example_grids.py Adds the new parallel_pst_example() grid definition used for PST integration coverage.
packages/dc_solver_pkg/tests/test_example_grids.py Extends example-grid tests, including coverage for complex-grid creation.
packages/dc_solver_pkg/tests/preprocessing/test_powsybl_helpers.py Adds a regression test ensuring operational-limit “side” drives voltage used in get_p_max.
packages/dc_solver_pkg/tests/preprocessing/test_powsybl_backend.py Updates fixture usage for complex-grid preprocessing/loadflow matching tests.
packages/dc_solver_pkg/tests/conftest.py Refactors complex-grid fixtures to reuse centralized preprocessing helpers and persist network_data.pkl.
packages/dc_solver_pkg/src/toop_engine_dc_solver/preprocess/powsybl/powsybl_helpers.py Updates get_p_max to use operational-limit side-specific voltage when converting current limits to MW.
packages/dc_solver_pkg/src/toop_engine_dc_solver/jax/nodal_inj_optim.py Updates a comment in PST tap application code path (and introduces a TODO about sign).
packages/dc_solver_pkg/src/toop_engine_dc_solver/example_grids.py Adds centralized helper(s) to generate preprocessed data folders for complex/parallel PST grids.

Comment thread packages/dc_solver_pkg/tests/test_example_grids.py Outdated
Comment thread packages/dc_solver_pkg/tests/preprocessing/test_powsybl_helpers.py
Comment thread packages/dc_solver_pkg/src/toop_engine_dc_solver/example_grids.py Outdated
Comment thread packages/topology_optimizer_pkg/tests/test_ac_dc_integration.py
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
LeonHilf
LeonHilf previously approved these changes May 28, 2026
Copy link
Copy Markdown
Collaborator

@LeonHilf LeonHilf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
@sonarqube-mccs
Copy link
Copy Markdown

@spetznick-elia spetznick-elia merged commit 2a172cb into main May 28, 2026
16 checks passed
@spetznick-elia spetznick-elia deleted the copilot/start-implementation branch May 28, 2026 12:53
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.

5 participants