-
Notifications
You must be signed in to change notification settings - Fork 8
feature(RAO Result): convert to operator strategy #1633
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
Draft
bqth29
wants to merge
10
commits into
main
Choose a base branch
from
experiment/rao-result-to-operator-strategy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
502b1b4
convert RAO result to operator strategies (lzay)
bqth29 3994c6f
group actions with common contingencies
bqth29 3778a48
delegate toActions to range actions
bqth29 7b22722
fix POM
bqth29 60e03e5
Merge branch 'main' into experiment/rao-result-to-operator-strategy
bqth29 7ef4f6e
use operator strategy list
bqth29 11b2d39
Update data/rao-result/rao-result-api/src/main/java/com/powsybl/openr…
bqth29 0fd98a0
Merge branch 'main' into experiment/rao-result-to-operator-strategy
bqth29 75f294a
remove useless files
bqth29 fce40cb
test on operator strategy converter
bqth29 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
74 changes: 74 additions & 0 deletions
74
...t-api/src/main/java/com/powsybl/openrao/data/raoresult/api/OperatorStrategyConverter.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| package com.powsybl.openrao.data.raoresult.api; | ||
|
|
||
| import com.powsybl.action.Action; | ||
| import com.powsybl.action.ActionList; | ||
| import com.powsybl.contingency.Contingency; | ||
| import com.powsybl.contingency.ContingencyContext; | ||
| import com.powsybl.iidm.network.Network; | ||
| import com.powsybl.openrao.data.crac.api.Crac; | ||
| import com.powsybl.openrao.data.crac.api.Instant; | ||
| import com.powsybl.openrao.data.crac.api.State; | ||
| import com.powsybl.security.condition.Condition; | ||
| import com.powsybl.security.condition.TrueCondition; | ||
| import com.powsybl.security.strategy.ConditionalActions; | ||
| import com.powsybl.security.strategy.OperatorStrategy; | ||
| import com.powsybl.security.strategy.OperatorStrategyList; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** | ||
| * @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>} | ||
| */ | ||
| final class OperatorStrategyConverter { | ||
| private static final Condition TRUE = new TrueCondition(); | ||
|
|
||
| private OperatorStrategyConverter() { | ||
| } | ||
|
|
||
| static StrategiesAndActions getOperatorStrategies(RaoResult raoResult, Crac crac, Network network) { | ||
| List<OperatorStrategy> operatorStrategies = new ArrayList<>(); | ||
| Set<Action> actions = new HashSet<>(); | ||
|
|
||
| // preventive strategy | ||
| ConditionalActions preventiveConditionalActions = getConditionalActionsForStateAndAddActionsToPool(crac.getPreventiveState(), raoResult, network, actions); | ||
| operatorStrategies.add(new OperatorStrategy(crac.getPreventiveState().getInstant().getId(), ContingencyContext.none(), List.of(preventiveConditionalActions))); | ||
|
|
||
| // post-contingency strategies | ||
| List<Instant> postOutageInstants = crac.getSortedInstants().stream().filter(instant -> instant.isAuto() || instant.isCurative()).toList(); | ||
| for (Contingency contingency : crac.getContingencies()) { | ||
| List<ConditionalActions> conditionalActions = new ArrayList<>(); | ||
| postOutageInstants.forEach(postOutageInstant -> conditionalActions.add(getConditionalActionsForStateAndAddActionsToPool(crac.getState(contingency.getId(), postOutageInstant), raoResult, network, actions))); | ||
| operatorStrategies.add(new OperatorStrategy(contingency.getId(), ContingencyContext.specificContingency(contingency.getId()), conditionalActions)); | ||
| } | ||
|
|
||
| return new StrategiesAndActions(new OperatorStrategyList(operatorStrategies), new ActionList(actions.stream().toList())); | ||
| } | ||
|
|
||
| private static ConditionalActions getConditionalActionsForStateAndAddActionsToPool(State state, RaoResult raoResult, Network network, Set<Action> actionsPool) { | ||
| Set<Action> stateActions = getActivatedActionsForState(raoResult, state, network); | ||
| actionsPool.addAll(stateActions); | ||
| return new ConditionalActions(state.getId(), TRUE, getActionsIds(stateActions)); | ||
| } | ||
|
|
||
| private static Set<Action> getActivatedActionsForState(RaoResult raoResult, State state, Network network) { | ||
| Set<Action> actions = new HashSet<>(); | ||
| raoResult.getActivatedNetworkActionsDuringState(state).forEach(networkAction -> actions.addAll(networkAction.getElementaryActions())); | ||
| raoResult.getActivatedRangeActionsDuringState(state).forEach(rangeAction -> actions.addAll(rangeAction.toActions(raoResult.getOptimizedSetPointOnState(state, rangeAction), network))); | ||
| return actions; | ||
| } | ||
|
|
||
| private static List<String> getActionsIds(Set<Action> actions) { | ||
| return actions.stream().map(Action::getId).collect(Collectors.toList()); | ||
| } | ||
| } |
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
17 changes: 17 additions & 0 deletions
17
...result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/StrategiesAndActions.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| package com.powsybl.openrao.data.raoresult.api; | ||
|
|
||
| import com.powsybl.action.ActionList; | ||
| import com.powsybl.security.strategy.OperatorStrategyList; | ||
|
|
||
| /** | ||
| * @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>} | ||
| */ | ||
| public record StrategiesAndActions(OperatorStrategyList operatorStrategyList, ActionList actionList) { | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe let's accept once and for all that a RaoResult depends on a Crac (thus we can add a RaoResult.getCrac() method) and that a Crac depends on a Network (Crac.getNetwork())
@phiedw @Godelaine thoughts ?