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

Rao Parameters: separate business from implementation specific #1101

Open
wants to merge 4 commits into
base: rao_parameters_merge_type_and_preventive_stop_criterion
Choose a base branch
from

Conversation

pjeanmarie
Copy link
Member

@pjeanmarie pjeanmarie commented Jul 31, 2024

… acceptable)

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?

#1084

What kind of change does this PR introduce?

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)

    move_to_extension(data, "objective-function", ["curative-min-obj-improvement"])
    move_to_extension(data, "range-actions-optimization",
                      ["max-mip-iterations", "pst-sensitivity-threshold", "pst-model",
                       "hvdc-sensitivity-threshold", "injection-ra-sensitivity-threshold",
                       "ra-range-shrinking", "linear-optimization-solver"])
    move_to_extension(data, "topological-actions-optimization",
                      ["max-preventive-search-tree-depth", "max-auto-search-tree-depth",
                       "max-curative-search-tree-depth", "predefined-combinations",
                       "skip-actions-far-from-most-limiting-element",
                       "max-number-of-boundaries-for-skipping-actions"])
    move_to_extension(data, "second-preventive-rao")
    move_to_extension(data, "load-flow-and-sensitivity-computation")
    if "range-actions-optimization" in data:
        new_names = {"pst-penalty-cost": "pst-ra-min-impact-threshold",
                     "hvdc-penalty-cost": "hvdc-ra-min-impact-threshold",
                     "injection-ra-penalty-cost": "injection-ra-min-impact-threshold"}
        data["range-actions-optimization"] = {new_names[k] if k in new_names else k: v for k, v in
                                              data["range-actions-optimization"].items()}
    if "multi-threading" in data and any(data["multi-threading"]):
        data["multi-threading"] = {"available-cpus": max(v for k, v in data["multi-threading"].items() if k in ("contingency-scenarios-in-parallel", "preventive-leaves-in-parallel"))}
    move_to_extension(data, "multi-threading")

Other information:

@pjeanmarie pjeanmarie changed the title Rao Parameters: separate business from implementation specific WIP: Rao Parameters: separate business from implementation specific Jul 31, 2024
@pjeanmarie pjeanmarie linked an issue Aug 5, 2024 that may be closed by this pull request
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch from 23e045e to f307d78 Compare August 5, 2024 16:31
@pjeanmarie pjeanmarie marked this pull request as draft August 9, 2024 15:57
@pjeanmarie pjeanmarie changed the title WIP: Rao Parameters: separate business from implementation specific [WIP] Rao Parameters: separate business from implementation specific Aug 9, 2024
@pjeanmarie pjeanmarie linked an issue Sep 23, 2024 that may be closed by this pull request
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch 2 times, most recently from 27fdbce to 06d212b Compare September 25, 2024 13:29
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch 3 times, most recently from f7a70a8 to 01ec4ab Compare October 8, 2024 14:35
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch 4 times, most recently from 63fc61f to a24cff9 Compare October 15, 2024 13:27
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch 4 times, most recently from 5bee729 to 9a19a7c Compare October 23, 2024 16:26
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch 3 times, most recently from b84b8ce to 66dc9dc Compare October 28, 2024 16:10
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch from 66dc9dc to c760e7a Compare November 4, 2024 10:01
@pjeanmarie pjeanmarie changed the base branch from main to rao_parameters_merge_type_and_preventive_stop_criterion November 5, 2024 09:18
@pjeanmarie pjeanmarie changed the title [WIP] Rao Parameters: separate business from implementation specific Rao Parameters: separate business from implementation specific Nov 5, 2024
@pjeanmarie pjeanmarie added breaking-change Changes could break users' code PR : dont-merge-before-other PR mustn't be merged before another (referenced in the description or in the comments) labels Nov 5, 2024
@pjeanmarie pjeanmarie marked this pull request as ready for review November 5, 2024 09:19
@pjeanmarie pjeanmarie force-pushed the rao_parameters_merge_type_and_preventive_stop_criterion branch from 8810fed to 4e59f6b Compare November 19, 2024 11:20
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch from c760e7a to 65aabf0 Compare November 21, 2024 09:48
@pjeanmarie pjeanmarie requested a review from obrix November 21, 2024 11:26
@pjeanmarie pjeanmarie added the PR: waiting-for-review This PR is waiting to be reviewed label Nov 21, 2024
@pjeanmarie pjeanmarie force-pushed the rao_parameters_merge_type_and_preventive_stop_criterion branch from 4e59f6b to 68f03a1 Compare November 29, 2024 09:12
jsonGenerator.writeEndObject();
}

static void deserialize(JsonParser jsonParser, OpenRaoSearchTreeParameters searchTreeParameters) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

A general comment for all serialization / deserialization. I think it would be better to fully use jackson and StdSerializer / StdDeserializer. Maybe some work for another PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed. It may also be worth discussing this at an organization level, since I noticed some discrepancies between at least OLF and powsybl core on how parameters are serialized / deserialized (using objectMapper vs explicitely defining the serializers / deserializers)

@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch from adbcbb2 to 8f911c7 Compare November 29, 2024 09:32
@pjeanmarie pjeanmarie force-pushed the rao_parameters_merge_type_and_preventive_stop_criterion branch from 68f03a1 to 448cd9e Compare November 29, 2024 10:19
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch from 8f911c7 to f000bd9 Compare November 29, 2024 10:20
@pjeanmarie pjeanmarie force-pushed the rao_parameters_merge_type_and_preventive_stop_criterion branch from 448cd9e to f3fd6b2 Compare December 9, 2024 10:48
Pauline Jean-Marie added 3 commits December 9, 2024 11:50
…one extension (to have a flat yml for platform config)

Signed-off-by: Pauline Jean-Marie <[email protected]>
@pjeanmarie pjeanmarie force-pushed the rao_parameters_separate_business_and_implem_specific branch from f000bd9 to b9b4fc3 Compare December 9, 2024 13:04
Comment on lines +67 to +72
- **Usage**: the pst-penalty-cost represents the cost of changing the PST set-points, it is used within the linear
optimisation problem of the RAO, where, for each PST, the following term is added to the objective function:
*pst-penalty-cost $$\times |\alpha - \alpha_{0}|$$*, where *$$\alpha$$* is the optimized angle of the PST, and
*$$\alpha_{0}$$* the angle in its initial position.
If several solutions are equivalent (e.g. with the same min margin), a strictly positive pst penalty cost will favour
the ones with the PST taps the closest to the initial situation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are issues with the formatting on this part (you can check the readme in the docs folder to see how to build the page locally, or check the details of the github action on the pull request to see how the page is rendered)

Copy link
Collaborator

Choose a reason for hiding this comment

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

also the parameter is pst-ra-min-impact-threshold and in the description it is still pst-penalty-cost

Comment on lines +74 to +82
#### hvdc-ra-min-impact-threshold
- **Expected value**: numeric value, unit: unit of the objective function / MW
- **Default value**: 0.001
- **Usage**: the hvdc-penalty-cost represents the cost of changing the HVDC set-points, it is used within the linear
optimisation problem of the RAO, where, for each HVDC, the following term is added to the objective function:
*hvdc-penalty-cost x |P - P0|*, where *P* is the optimized target power of the HVDC, and *P0* the initial target
power.
If several solutions are equivalent (e.g. with the same min margin), a strictly positive hvdc penalty cost will favour
the ones with the HVDC set-points the closest to the initial situation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

same issue hvdc-ra-min-impact-threshold vs hvdc-penalty-cost

Comment on lines +84 to +88
#### injection-ra-min-impact-threshold
- **Expected value**: numeric value, unit: unit of the objective function / MW
- **Default value**: 0.001
- **Usage**: the injection-ra-penalty-cost represents the cost of changing the injection set-points, it is used within the linear
optimisation problem of the RAO, in the same way as the two types of RangeAction above.
Copy link
Collaborator

Choose a reason for hiding this comment

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

same issue injection-ra-min-impact-threshold vs injection-ra-penalty-cost

- **Default value**: 0.0
- **Usage**: behaves like [absolute-minimum-impact-threshold](#absolute-minimum-impact-threshold), but the
threshold here is defined as a coefficient of the objective function value of the previous depth. In depth (n+1), if a
topological action improves the objective function by x, with x < solution(depth(n)) x relative-minimum-impact-threshold,
Copy link
Collaborator

Choose a reason for hiding this comment

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

use " * " instead of " x " for the multiplication in the equation

Comment on lines +143 to +144
- **Usage**: used as a minimum improvement of the preventive RAO objective value for the curative RAO stop criterion,
when it is set to PREVENTIVE_OBJECTIVE or PREVENTIVE_OBJECTIVE_AND_SECURE.
Copy link
Collaborator

Choose a reason for hiding this comment

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

the curative stop criterion no longer exists

import static com.powsybl.openrao.raoapi.RaoParametersCommons.*;

/**
* @author Godelaine de Montmorillon {@literal <godelaine.demontmorillon at rte-france.com>}
Copy link
Collaborator

Choose a reason for hiding this comment

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

add yourself as author

import static com.powsybl.openrao.raoapi.RaoParametersCommons.*;

/**
* @author Godelaine de Montmorillon {@literal <godelaine.demontmorillon at rte-france.com>}
Copy link
Collaborator

Choose a reason for hiding this comment

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

add yourself as author

@@ -87,14 +90,14 @@ public CastorSecondPreventive(Crac crac,
*/
boolean shouldRunSecondPreventiveRao(OptimizationResult firstPreventiveResult, Collection<OptimizationResult> curativeRaoResults, RaoResult postFirstRaoResult, long estimatedPreventiveRaoTimeInSeconds) {
Instant lastCurativeInstant = crac.getLastInstant();
if (raoParameters.getSecondPreventiveRaoParameters().getExecutionCondition().equals(SecondPreventiveRaoParameters.ExecutionCondition.DISABLED)) {
if (getExecutionCondition(raoParameters).equals(SecondPreventiveRaoParameters.ExecutionCondition.DISABLED)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be clearer here to explicitly call SecondPreventiveRaoParameters.getExecutionCondition, or rename the method to getSecondPreventiveExecutionCondition

@@ -160,7 +163,7 @@ RaoResult runSecondPreventiveAndAutoRao(CastorContingencyScenarios castorConting
// ------ appliedCras from secondPreventiveRaoResult
AppliedRemedialActions appliedArasAndCras = secondPreventiveRaoResult.appliedArasAndCras().copyCurative();
// ------ + curative range actions optimized during second preventive with global optimization
if (raoParameters.getSecondPreventiveRaoParameters().getReOptimizeCurativeRangeActions()) {
if (getReOptimizeCurativeRangeActions(raoParameters)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same remark here, it would be clearer if we knew this was relative to second preventive optimization

@@ -48,24 +51,28 @@ public class CoreProblemFiller implements ProblemFiller {
private final Set<FlowCnec> flowCnecs;
private final RangeActionSetpointResult prePerimeterRangeActionSetpoints;
private final RangeActionsOptimizationParameters rangeActionParameters;
private final com.powsybl.openrao.raoapi.parameters.extensions.RangeActionsOptimizationParameters rangeActionParametersExtension;
Copy link
Collaborator

@phiedw phiedw Jan 9, 2025

Choose a reason for hiding this comment

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

maybe we should rename the classes to have Extension or SearchTreeRao so it's easier to differentiate between them and avoid having to make the class path explicit every time

…' of https://github.com/powsybl/open-rao into rao_parameters_separate_business_and_implem_specific

Signed-off-by: Philippe Edwards <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Changes could break users' code PR : dont-merge-before-other PR mustn't be merged before another (referenced in the description or in the comments) PR: waiting-for-review This PR is waiting to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make RaoParameters generic
3 participants