Skip to content

Commit

Permalink
Merge branch 'main' into coreCSA/remedial_action_compatibility
Browse files Browse the repository at this point in the history
# Conflicts:
#	ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/searchtree/algorithms/SearchTreeBloomer.java
#	ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/searchtree/algorithms/SearchTreeBloomerTest.java
  • Loading branch information
bqth29 committed Jun 17, 2024
2 parents 584bf31 + cebab11 commit 7a0cb1e
Show file tree
Hide file tree
Showing 363 changed files with 15,359 additions and 6,733 deletions.
46 changes: 46 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# How to contribute to PowSyBl OpenRAO

Welcome to the OpenRAO developers and users community!
Here is all the information you need to know before making your first contribution.

## Submitting your ideas
If you are an OpenRAO user, and you found a bug, or you would like a new feature, or
if you are an active OpenRAO developer, and have ideas to improve the code, please let us know!
We'll be more than happy to fix all bugs and discuss all improvement ideas.
- First, make sure that the bug/feature request/improvement idea has not been already reported under [Issues](https://github.com/powsybl/powsybl-open-rao/issues).
- If not, [open a new one](https://github.com/powsybl/powsybl-open-rao/issues/new). Provide us with as many details as possible,
so we can understand the issue and try to address it ASAP.
- Label[^1] your new issue as much as possible, this makes addressing it much more efficient.

Your ideas may be discussed by the OpenRAO developers and the [PowSyBl Technical Steering Committee](https://www.powsybl.org/pages/overview/governance#technical-steering-committee)
in order to reach a consensus.

## Development

### Getting started
The PowSyBl OpenRAO team is always pleased to welcome developers into the project.
The best way to get a quick start is to clone the project's main branch and try running the [functional tests](tests/README.md)
on your PC. If everything works, then you're good to make your first contribution to the code!

### Code formatting
OpenRAO uses a custom profile for JAVA code formatting.
You can download these rules for your IDE from this directory: [developer-resources](docs/_static/developer-resources).

### Pull Requests
The `main` branch is protected by a set of rules, and Pull Requests from your branch are mandatory.

Here is a set of rules your pull request must follow:
- your commits must be **signed-off**
- the description of the PR should be well detailed: it must be self-explanatory and detailed enough for developers and
users to understand **what** has changed, **why**, and **how**
- if the PR addresses an open issue, the **issue should be linked** in the description
- you can open a PR even if it's not ready to merge, but in that case you must set it as a **draft**
- the PR must be **reviewed** by at least one other developer before it can be merged
- you must add unit **tests** and/or [functional tests](tests/README.md) to your new features
- the PR must pass a few **automatic checks** before it can be merged: build & unit tests, functional tests, sonar quality, sign-off check, doc build check
- if the PR changes a part of the code that is [documented](https://powsybl.readthedocs.io/projects/openrao/en/latest),
then [**documentation**](docs) must be updated before it can be merged
- **label**[^1] the PR as much as possible, this makes addressing it much more efficient


[^1]: See OpenRAO's list of labels for Issues & Pull Requests [here](https://github.com/powsybl/powsybl-open-rao/issues/labels)
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ In order to build **powsybl-open-rao**, you need the following environment avail

### Installing

Before installing **powsybl-open-rao**, you need to install OR-Tools, a software suite for optimisation that is used by Open RAO.

Please refer to [OR-tools website](https://developers.google.com/optimization/install/download) for installation instructions.

Open RAO also needs a load flow implementation and a sensitivity analysis implementation at runtime, following the interfaces of **powsybl-core** which documentation is available in [PowSyBl website](https://www.powsybl.org/pages/documentation/). Note that for obvious reasons, included performances, reliability and transparency, Open RAO uses [Powsybl Open Load Flow](https://github.com/powsybl/powsybl-open-loadflow) by default, but you can prefer you own implementation.
Open RAO needs a load flow implementation and a sensitivity analysis implementation at runtime, following the interfaces of **powsybl-core** which documentation is available in [PowSyBl website](https://www.powsybl.org/pages/documentation/). Note that for obvious reasons, included performances, reliability and transparency, Open RAO uses [Powsybl Open Load Flow](https://github.com/powsybl/powsybl-open-loadflow) by default, but you can prefer you own implementation.

### Running

Expand Down Expand Up @@ -65,7 +61,13 @@ cd <install-prefix>/bin

For more information about *itools*, do not hesitate to visit [PowSyBl documentation](https://www.powsybl.org/docs/).

### Quick tutorial
If you prefer to get familiar with OpenRAO using a real example, take a look at this [tutorial](https://powsybl.readthedocs.io/projects/openrao/en/stable/tutorial.html).

## License

This project is licensed under the Mozilla Public License 2.0 - see the [LICENSE.txt](https://github.com/powsybl/powsybl-open-rao/blob/main/LICENSE.txt) file for details.

## Contributing

Please read the instructions [here](CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-open-rao</artifactId>
<version>5.5.0-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<artifactId>open-rao-commons</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion data/crac-creation/crac-creation-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>open-rao-crac-creation</artifactId>
<groupId>com.powsybl</groupId>
<version>5.5.0-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion data/crac-creation/crac-creator-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>open-rao-crac-creation</artifactId>
<groupId>com.powsybl</groupId>
<version>5.5.0-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion data/crac-creation/crac-creator-cim/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<artifactId>open-rao-crac-creation</artifactId>
<groupId>com.powsybl</groupId>
<version>5.5.0-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public AngleCnec createAndAddAdditionalConstraintSeries() {
.withMonitored()
.withOptimized(false)
.withReliabilityMargin(0.)
.newThreshold().withUnit(Unit.DEGREE).withMax(additionalConstraintSerie.getQuantityQuantity().doubleValue())
.withMin(-additionalConstraintSerie.getQuantityQuantity().doubleValue()).add()
.newThreshold().withUnit(Unit.DEGREE).withMax(additionalConstraintSerie.getQuantityQuantity().doubleValue()).add()
.withInstant(crac.getInstant(InstantKind.CURATIVE).getId())
.withContingency(contingencyId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,14 @@ private void checkRegisteredResource(RemedialActionRegisteredResource registered
}
}

// Return type :
// -- the boolean indicates whether the Hvdc line is inverted
/**
* @param networkElement - HVDC line name
* @param minCapacity
* @param maxCapacity
* @param inNode - The area of the related oriented border study where the energy flows INTO.
* @param outNode - The area of the related oriented border study where the energy comes FROM.
* @return - the boolean indicates whether the Hvdc line is inverted
*/
private boolean readHvdcRange(String networkElement, int minCapacity, int maxCapacity, String inNode, String outNode) {
HvdcLine hvdcLine = network.getHvdcLine(networkElement);
boolean isInverted;
Expand All @@ -245,11 +251,11 @@ private boolean readHvdcRange(String networkElement, int minCapacity, int maxCap
if (Objects.isNull(inNode) || Objects.isNull(outNode)) {
throw new OpenRaoImportException(ImportStatus.INCOMPLETE_DATA, "Missing HVDC in or out aggregate nodes");
}
if (inNode.equals(from) && outNode.equals(to)) {
if (inNode.equals(to) && outNode.equals(from)) {
isInverted = false;
min = minCapacity;
max = maxCapacity;
} else if (inNode.equals(to) && outNode.equals(from)) {
} else if (inNode.equals(from) && outNode.equals(to)) {
isInverted = true;
min = -maxCapacity;
max = -minCapacity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.powsybl.openrao.data.cracapi.*;
import com.powsybl.openrao.data.cracapi.cnec.AngleCnec;
import com.powsybl.openrao.data.cracapi.cnec.FlowCnec;
import com.powsybl.openrao.data.cracapi.usagerule.OnFlowConstraintInCountryAdder;
import com.powsybl.openrao.data.cracapi.usagerule.UsageMethod;
import com.powsybl.openrao.data.craccreation.creator.api.ImportStatus;
import com.powsybl.openrao.data.craccreation.creator.cim.craccreator.CimCracCreationContext;
Expand Down Expand Up @@ -98,7 +99,7 @@ public void createAndAddRemedialActionSeries() {
// Read and store Monitored Series
this.flowCnecs = getFlowCnecsFromMonitoredAndContingencySeries(cimSerie);
// Read and create / modify RA creators
boolean shouldReadSharedDomain = cimSerie.getContingencySeries().isEmpty() && cimSerie.getMonitoredSeries().isEmpty();
boolean shouldReadSharedDomain = cimSerie.getMonitoredSeries().isEmpty();
for (RemedialActionSeries remedialActionSeries : cimSerie.getRemedialActionSeries()) {
readRemedialAction(remedialActionSeries, shouldReadSharedDomain);
}
Expand Down Expand Up @@ -406,7 +407,7 @@ private static void addUsageRulesAtInstant(RemedialActionAdder<?> remedialAction
}
UsageMethod usageMethod = instant.isAuto() ? UsageMethod.FORCED : UsageMethod.AVAILABLE;
if (!Objects.isNull(sharedDomain)) {
remedialActionAdder.newOnFlowConstraintInCountryUsageRule().withInstant(instant.getId()).withCountry(sharedDomain).withUsageMethod(usageMethod).add();
addOnFlowConstraintInCountryUsageRule(remedialActionAdder, contingencies, sharedDomain, instant, usageMethod);
return;
}

Expand Down Expand Up @@ -470,21 +471,35 @@ private static void addOnFlowConstraintUsageRule(RemedialActionAdder<?> adder, F
if (flowCnec.getState().getInstant().comesBefore(instant)) {
return;
}
adder.newOnFlowConstraintUsageRule()
.withFlowCnec(flowCnec.getId())
adder.newOnConstraintUsageRule()
.withCnec(flowCnec.getId())
.withUsageMethod(instant.isAuto() ? UsageMethod.FORCED : UsageMethod.AVAILABLE)
.withInstant(instant.getId())
.add();
}

private static void addOnAngleConstraintUsageRule(RemedialActionAdder<?> adder, AngleCnec angleCnec, Instant instant) {
adder.newOnAngleConstraintUsageRule()
.withAngleCnec(angleCnec.getId())
adder.newOnConstraintUsageRule()
.withCnec(angleCnec.getId())
.withUsageMethod(instant.isAuto() ? UsageMethod.FORCED : UsageMethod.AVAILABLE)
.withInstant(instant.getId())
.add();
}

private static void addOnFlowConstraintInCountryUsageRule(RemedialActionAdder<?> remedialActionAdder, List<Contingency> contingencies, Country sharedDomain, Instant instant, UsageMethod usageMethod) {
OnFlowConstraintInCountryAdder<?> onFlowConstraintInCountryAdder = remedialActionAdder
.newOnFlowConstraintInCountryUsageRule()
.withInstant(instant.getId())
.withCountry(sharedDomain)
.withUsageMethod(usageMethod);
if (!Objects.isNull(contingencies) && !contingencies.isEmpty()) {
contingencies.forEach(
contingency -> onFlowConstraintInCountryAdder.withContingency(contingency.getId()).add());
} else {
onFlowConstraintInCountryAdder.add();
}
}

/*-------------- SERIES CHECKS ------------------------------*/
private boolean checkRemedialActionSeries(Series cimSerie) {
// --- Check optimizationStatus
Expand Down
Loading

0 comments on commit 7a0cb1e

Please sign in to comment.