Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor objective function evaluators API and add cost-wise Search-Tree #1186

Merged
merged 79 commits into from
Dec 10, 2024

Conversation

bqth29
Copy link
Collaborator

@bqth29 bqth29 commented Oct 30, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
Fixes #1053

What kind of change does this PR introduce?

Refactoring of objective function evaluators and results

evaluators

Previously, ObjectiveFunctionResultImpl was a non final object that had its ObjectiveFunction as an attribute so it could be recomputed when contingencies need to be filtered out (in case curative perimeters fail for instance). This was quite ambiguous for a result object that should only hold immutable data.

In the new version, the results are decomposed based on the states and can be filtered in case contingencies need to be excluded.

results

Finally, the objective function builder was becoming useless with this refactoring and was thus replaced by creators as follows:

creator

What is the current behavior?

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

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:

@bqth29 bqth29 added the feature New feature or request label Oct 30, 2024
@bqth29 bqth29 linked an issue Oct 30, 2024 that may be closed by this pull request
@bqth29
Copy link
Collaborator Author

bqth29 commented Nov 7, 2024

@phiedw what do you think about including the min margin overload in virtual cost?

@bqth29 bqth29 marked this pull request as ready for review November 8, 2024 12:39
@bqth29 bqth29 requested review from pet-mit and phiedw November 8, 2024 12:40
@bqth29 bqth29 changed the base branch from feature/activation-cost to main November 8, 2024 12:40
Copy link
Collaborator

@pet-mit pet-mit left a comment

Choose a reason for hiding this comment

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

I feel that you haven't finished this, let me know when you do

@bqth29
Copy link
Collaborator Author

bqth29 commented Nov 14, 2024

I feel that you haven't finished this, let me know when you do

This PR only focuses on costly network actions, range actions will come in another PR later
I may have unintentionally forgotten features but I believe this PR is ready

@bqth29 bqth29 requested a review from pet-mit November 14, 2024 12:54
@bqth29 bqth29 added PR: waiting-for-review This PR is waiting to be reviewed PR : dont-merge-before-other PR mustn't be merged before another (referenced in the description or in the comments) labels Nov 18, 2024
@bqth29 bqth29 added PR: waiting-for-correction This PR is waiting to be corrected by its author PR: waiting-for-review This PR is waiting to be reviewed and removed PR: waiting-for-review This PR is waiting to be reviewed PR : dont-merge-before-other PR mustn't be merged before another (referenced in the description or in the comments) labels Nov 20, 2024
pet-mit and others added 11 commits November 26, 2024 13:14
Signed-off-by: Peter Mitri <peter.mitri@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
…se of violation (#1154)

* Round angle value with more decimals in case of violation

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* linter

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Create static method computeNumberOfRelevantDecimals in SweCneUtil

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Sonar

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Export flow as double

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Round double flow value with relevant decimals

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* define rounding noise as class constant

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Move decimals computation to commons

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Round flows, angles and voltages more properly in RaoResult

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Round flows, angles and voltages more properly in RaoResult

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Mutualize rounding using margin value

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* use default decimals in decimals computing

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* use default decimals in decimals computing

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* add docstring

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* simplify angle margin computation

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* round flow value in logs

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* round swe cne export values with 1 default decimal

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* round swe cne export values with 1 default decimal

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* rollback to bigdecimals in rounding tests

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* adapt logging

Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>

* MR comments

Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>

* generate getters for MonitoringResult

Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>

* add cucumber step

Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>

* MR comments 2

Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>

---------

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>
Co-authored-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
* Generify CSA CRAC Creation Parameters

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Add curative instants in parameters

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Create curative instants from crac creation parameters

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* add TODO

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Merge main

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

* Replace list of pair by map

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>

---------

Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Co-authored-by: benrejebmoh <48012306+benrejebmoh@users.noreply.github.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
@bqth29 bqth29 removed the PR: waiting-for-correction This PR is waiting to be corrected by its author label Nov 26, 2024
# Conflicts:
#	data/crac/crac-io/crac-io-json/src/main/resources/schemas/network-action/network-action-v1.8.json
#	data/crac/crac-io/crac-io-json/src/main/resources/schemas/network-action/network-action-v2.5.json
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimization.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoLogger.java
@bqth29 bqth29 requested review from pet-mit and phiedw November 26, 2024 12:26
@bqth29 bqth29 changed the title Cost-wise Search-Tree Refactor objective function evaluators API and add cost-wise Search-Tree Nov 26, 2024
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
@bqth29 bqth29 requested a review from phiedw November 28, 2024 14:48
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
# Conflicts:
#	data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/crac/impl/AbstractStandardRangeActionAdder.java
#	data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/crac/impl/CounterTradeRangeActionAdderImplTest.java
#	data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/crac/impl/HvdcRangeActionAdderImplTest.java
#	data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/crac/impl/InjectionRangeActionAdderImplTest.java
#	data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/crac/impl/PstRangeActionAdderImplTest.java
#	data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/crac/impl/utils/ExhaustiveCracCreation.java
#	data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/crac/io/json/JsonSerializationConstants.java
#	data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/crac/io/json/serializers/NetworkActionSerializer.java
#	data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/crac/io/json/serializers/PstRangeActionSerializer.java
#	data/crac/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/crac/io/json/serializers/StandardRangeActionSerializer.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/PrePerimeterSensitivityAnalysis.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoLogger.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/CostEvaluator.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/LoopFlowViolationCostEvaluator.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/MinMarginEvaluator.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/MnecViolationCostEvaluator.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/ObjectiveFunction.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/ObjectiveFunctionResultImpl.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/SensitivityFailureOvercostEvaluator.java
#	ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/MinMarginEvaluatorTest.java
#	ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/ObjectiveFunctionTest.java
#	ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/SensitivityFailureOvercostEvaluatorTest.java
#	ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/RangeActionActivationResultImplTest.java
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
bqth29 and others added 3 commits December 2, 2024 15:14
# Conflicts:
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/objectivefunctionevaluator/SensitivityFailureOvercostEvaluator.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/AutomatonPerimeterResultImpl.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/CurativeWithSecondPraoResult.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/IteratingLinearOptimizationResultImpl.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/OptimizationResultImpl.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/PrePerimeterSensitivityResultImpl.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImpl.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/SkippedOptimizationResultImpl.java
#	ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/OptimizationResultImplTest.java
#	ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImplTest.java
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
phiedw
phiedw previously approved these changes Dec 2, 2024
@bqth29 bqth29 added the new-crac-version This pull request introduces a new version of the JSON CRAC format label Dec 2, 2024
@bqth29 bqth29 removed the request for review from pet-mit December 9, 2024 13:37
# Conflicts:
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimization.java
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImpl.java
#	ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimizationTest.java
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
@phiedw phiedw dismissed pet-mit’s stale review December 10, 2024 09:00

lack of time

@phiedw phiedw merged commit 8ad6dfc into main Dec 10, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request new-crac-version This pull request introduces a new version of the JSON CRAC format PR: waiting-for-review This PR is waiting to be reviewed
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Cost minimization mode Add the concept of cost in all remedial actions
4 participants