Skip to content

Commit

Permalink
Power Gradient Constraint (#1229)
Browse files Browse the repository at this point in the history
* Power Gradient Constraint

Signed-off-by: Thomas Bouquet <[email protected]>

* JUnit

Signed-off-by: Thomas Bouquet <[email protected]>

* typo in test name

Signed-off-by: Thomas Bouquet <[email protected]>

* extract VariationDirection from RangeAction

Signed-off-by: Thomas Bouquet <[email protected]>

* replace record by class

Signed-off-by: Thomas Bouquet <[email protected]>

* update pom

Signed-off-by: Thomas Bouquet <[email protected]>

* add module to jacoco

Signed-off-by: Thomas Bouquet <[email protected]>

* add pgcs to RAO inputs

Signed-off-by: Thomas Bouquet <[email protected]>

* fix poms

Signed-off-by: Godelaine de Montmorillon <[email protected]>

* udate new POM tp 6.3.0-SNAPSHOT

Signed-off-by: Thomas Bouquet <[email protected]>

---------

Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Godelaine de Montmorillon <[email protected]>
Co-authored-by: Godelaine de Montmorillon <[email protected]>
  • Loading branch information
bqth29 and Godelaine authored Dec 19, 2024
1 parent b322ed5 commit da19936
Show file tree
Hide file tree
Showing 29 changed files with 236 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface PstRangeActionAdder extends RemedialActionAdder<PstRangeActionA

PstRangeActionAdder withTapToAngleConversionMap(Map<Integer, Double> tapToAngleConversionMap);

PstRangeActionAdder withVariationCost(Double variationCost, RangeAction.VariationDirection variationDirection);
PstRangeActionAdder withVariationCost(Double variationCost, VariationDirection variationDirection);

TapRangeAdder newTapRange();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,4 @@ public interface RangeAction<T extends RangeAction<T>> extends RemedialAction<T>
Optional<String> getGroupId();

Optional<Double> getVariationCost(VariationDirection variationDirection);

enum VariationDirection {
UP, DOWN
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public interface StandardRangeActionAdder<T extends StandardRangeActionAdder<T>>

T withInitialSetpoint(double initialSetpoint);

T withVariationCost(Double variationCost, RangeAction.VariationDirection variationDirection);
T withVariationCost(Double variationCost, VariationDirection variationDirection);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2024, 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.crac.api.rangeaction;

/**
* @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>}
*/
public enum VariationDirection {
UP, DOWN
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.powsybl.openrao.data.crac.impl;

import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageRule;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.powsybl.openrao.commons.OpenRaoException;
import com.powsybl.openrao.data.crac.api.range.StandardRange;
import com.powsybl.openrao.data.crac.api.range.StandardRangeAdder;
import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.StandardRangeActionAdder;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -26,7 +26,7 @@ public abstract class AbstractStandardRangeActionAdder<T extends StandardRangeAc
protected String groupId;
protected double initialSetpoint;
protected List<StandardRange> ranges;
protected Map<RangeAction.VariationDirection, Double> variationCosts;
protected Map<VariationDirection, Double> variationCosts;

AbstractStandardRangeActionAdder(CracImpl crac) {
super(crac);
Expand All @@ -47,7 +47,7 @@ public T withInitialSetpoint(double initialSetpoint) {
}

@Override
public T withVariationCost(Double variationCost, RangeAction.VariationDirection variationDirection) {
public T withVariationCost(Double variationCost, VariationDirection variationDirection) {
this.variationCosts.put(variationDirection, variationCost);
return (T) this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.powsybl.openrao.data.crac.api.NetworkElement;
import com.powsybl.openrao.data.crac.api.range.StandardRange;
import com.powsybl.openrao.data.crac.api.rangeaction.CounterTradeRangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageRule;
import com.powsybl.iidm.network.Country;
import com.powsybl.iidm.network.Network;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.powsybl.openrao.data.crac.api.NetworkElement;
import com.powsybl.openrao.data.crac.api.range.StandardRange;
import com.powsybl.openrao.data.crac.api.rangeaction.HvdcRangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageRule;
import com.powsybl.iidm.network.HvdcLine;
import com.powsybl.iidm.network.Network;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.powsybl.openrao.data.crac.api.NetworkElement;
import com.powsybl.openrao.data.crac.api.range.StandardRange;
import com.powsybl.openrao.data.crac.api.rangeaction.InjectionRangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageRule;
import com.powsybl.iidm.network.Generator;
import com.powsybl.iidm.network.Load;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.powsybl.openrao.data.crac.api.range.RangeType;
import com.powsybl.openrao.data.crac.api.range.TapRange;
import com.powsybl.openrao.data.crac.api.range.TapRangeAdder;
import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageRule;

import java.util.*;
Expand All @@ -34,7 +34,7 @@ public class PstRangeActionAdderImpl extends AbstractRemedialActionAdder<PstRang
private String groupId = null;
private Integer initialTap = null;
private Map<Integer, Double> tapToAngleConversionMap;
private Map<RangeAction.VariationDirection, Double> variationCosts;
private Map<VariationDirection, Double> variationCosts;

@Override
protected String getTypeDescription() {
Expand Down Expand Up @@ -78,7 +78,7 @@ public PstRangeActionAdder withTapToAngleConversionMap(Map<Integer, Double> tapT
}

@Override
public PstRangeActionAdder withVariationCost(Double variationCost, RangeAction.VariationDirection variationDirection) {
public PstRangeActionAdder withVariationCost(Double variationCost, VariationDirection variationDirection) {
this.variationCosts.put(variationDirection, variationCost);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.powsybl.openrao.data.crac.api.rangeaction.PstRangeAction;
import com.powsybl.openrao.data.crac.api.range.RangeType;
import com.powsybl.openrao.data.crac.api.range.TapRange;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageRule;
import com.powsybl.iidm.network.*;
import org.apache.commons.lang3.tuple.Pair;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.powsybl.openrao.data.crac.api.InstantKind;
import com.powsybl.openrao.data.crac.api.rangeaction.CounterTradeRangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.CounterTradeRangeActionAdder;
import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageMethod;
import com.powsybl.iidm.network.Country;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -39,8 +39,8 @@ void testAdd() {
.withOperator("BE")
.withGroupId("groupId1")
.withActivationCost(1000d)
.withVariationCost(10000d, RangeAction.VariationDirection.UP)
.withVariationCost(20000d, RangeAction.VariationDirection.DOWN)
.withVariationCost(10000d, VariationDirection.UP)
.withVariationCost(20000d, VariationDirection.DOWN)
.newRange().withMin(-5).withMax(10).add()
.newOnInstantUsageRule().withInstant(PREVENTIVE_INSTANT_ID).withUsageMethod(UsageMethod.AVAILABLE).add()
.withExportingCountry(Country.FR)
Expand All @@ -51,8 +51,8 @@ void testAdd() {
assertEquals("id1", counterTradeRangeAction.getName());
assertEquals("BE", counterTradeRangeAction.getOperator());
assertEquals(Optional.of(1000d), counterTradeRangeAction.getActivationCost());
assertEquals(Optional.of(10000d), counterTradeRangeAction.getVariationCost(RangeAction.VariationDirection.UP));
assertEquals(Optional.of(20000d), counterTradeRangeAction.getVariationCost(RangeAction.VariationDirection.DOWN));
assertEquals(Optional.of(10000d), counterTradeRangeAction.getVariationCost(VariationDirection.UP));
assertEquals(Optional.of(20000d), counterTradeRangeAction.getVariationCost(VariationDirection.DOWN));
assertTrue(counterTradeRangeAction.getGroupId().isPresent());
assertEquals("groupId1", counterTradeRangeAction.getGroupId().get());
assertEquals(1, counterTradeRangeAction.getRanges().size());
Expand All @@ -78,8 +78,8 @@ void testAddWithoutGroupId() {
assertEquals("BE", counterTradeRangeAction.getOperator());
assertTrue(counterTradeRangeAction.getGroupId().isEmpty());
assertTrue(counterTradeRangeAction.getActivationCost().isEmpty());
assertTrue(counterTradeRangeAction.getVariationCost(RangeAction.VariationDirection.UP).isEmpty());
assertTrue(counterTradeRangeAction.getVariationCost(RangeAction.VariationDirection.DOWN).isEmpty());
assertTrue(counterTradeRangeAction.getVariationCost(VariationDirection.UP).isEmpty());
assertTrue(counterTradeRangeAction.getVariationCost(VariationDirection.DOWN).isEmpty());
assertEquals(1, counterTradeRangeAction.getRanges().size());
assertEquals(1, counterTradeRangeAction.getUsageRules().size());
assertEquals(Country.FR, counterTradeRangeAction.getExportingCountry());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.powsybl.openrao.data.crac.api.networkaction.ActionType;
import com.powsybl.openrao.data.crac.api.rangeaction.HvdcRangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.HvdcRangeActionAdder;
import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageMethod;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -49,8 +49,8 @@ void testAdd() {
.withNetworkElement(networkElementId)
.withGroupId("groupId1")
.withActivationCost(100d)
.withVariationCost(500d, RangeAction.VariationDirection.UP)
.withVariationCost(800d, RangeAction.VariationDirection.DOWN)
.withVariationCost(500d, VariationDirection.UP)
.withVariationCost(800d, VariationDirection.DOWN)
.newRange().withMin(-5).withMax(10).add()
.newOnInstantUsageRule()
.withInstant(PREVENTIVE_INSTANT_ID)
Expand All @@ -61,8 +61,8 @@ void testAdd() {
assertEquals(1, crac.getRangeActions().size());
assertEquals(networkElementId, hvdcRangeAction.getNetworkElement().getId());
assertEquals(Optional.of(100d), hvdcRangeAction.getActivationCost());
assertEquals(Optional.of(500d), hvdcRangeAction.getVariationCost(RangeAction.VariationDirection.UP));
assertEquals(Optional.of(800d), hvdcRangeAction.getVariationCost(RangeAction.VariationDirection.DOWN));
assertEquals(Optional.of(500d), hvdcRangeAction.getVariationCost(VariationDirection.UP));
assertEquals(Optional.of(800d), hvdcRangeAction.getVariationCost(VariationDirection.DOWN));
assertEquals("BE", hvdcRangeAction.getOperator());
assertEquals(1, hvdcRangeAction.getRanges().size());
assertEquals(1, hvdcRangeAction.getUsageRules().size());
Expand Down Expand Up @@ -90,8 +90,8 @@ void testAddAuto() {
assertEquals(networkElementId, hvdcRangeAction.getNetworkElement().getId());
assertEquals("BE", hvdcRangeAction.getOperator());
assertTrue(hvdcRangeAction.getActivationCost().isEmpty());
assertTrue(hvdcRangeAction.getVariationCost(RangeAction.VariationDirection.UP).isEmpty());
assertTrue(hvdcRangeAction.getVariationCost(RangeAction.VariationDirection.DOWN).isEmpty());
assertTrue(hvdcRangeAction.getVariationCost(VariationDirection.UP).isEmpty());
assertTrue(hvdcRangeAction.getVariationCost(VariationDirection.DOWN).isEmpty());
assertEquals(1, hvdcRangeAction.getRanges().size());
assertEquals(1, hvdcRangeAction.getUsageRules().size());
assertEquals(1, crac.getNetworkElements().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.powsybl.openrao.data.crac.api.InstantKind;
import com.powsybl.openrao.data.crac.api.rangeaction.InjectionRangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.InjectionRangeActionAdder;
import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageMethod;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -49,8 +49,8 @@ void testAdd() {
.withOperator("BE")
.withGroupId("groupId1")
.withActivationCost(200d)
.withVariationCost(700d, RangeAction.VariationDirection.UP)
.withVariationCost(1000d, RangeAction.VariationDirection.DOWN)
.withVariationCost(700d, VariationDirection.UP)
.withVariationCost(1000d, VariationDirection.DOWN)
.withNetworkElementAndKey(1., injectionId1)
.withNetworkElementAndKey(-1., injectionId2, injectionName2)
.newRange().withMin(-5).withMax(10).add()
Expand All @@ -61,8 +61,8 @@ void testAdd() {
assertEquals("id1", injectionRangeAction.getName());
assertEquals("BE", injectionRangeAction.getOperator());
assertEquals(Optional.of(200d), injectionRangeAction.getActivationCost());
assertEquals(Optional.of(700d), injectionRangeAction.getVariationCost(RangeAction.VariationDirection.UP));
assertEquals(Optional.of(1000d), injectionRangeAction.getVariationCost(RangeAction.VariationDirection.DOWN));
assertEquals(Optional.of(700d), injectionRangeAction.getVariationCost(VariationDirection.UP));
assertEquals(Optional.of(1000d), injectionRangeAction.getVariationCost(VariationDirection.DOWN));
assertTrue(injectionRangeAction.getGroupId().isPresent());
assertEquals("groupId1", injectionRangeAction.getGroupId().get());
assertEquals(1, injectionRangeAction.getRanges().size());
Expand Down Expand Up @@ -96,8 +96,8 @@ void testAddWithSumOnSameInjection() {
assertEquals("id1", injectionRangeAction.getName());
assertEquals("BE", injectionRangeAction.getOperator());
assertTrue(injectionRangeAction.getActivationCost().isEmpty());
assertTrue(injectionRangeAction.getVariationCost(RangeAction.VariationDirection.UP).isEmpty());
assertTrue(injectionRangeAction.getVariationCost(RangeAction.VariationDirection.DOWN).isEmpty());
assertTrue(injectionRangeAction.getVariationCost(VariationDirection.UP).isEmpty());
assertTrue(injectionRangeAction.getVariationCost(VariationDirection.DOWN).isEmpty());
assertTrue(injectionRangeAction.getGroupId().isPresent());
assertEquals("groupId1", injectionRangeAction.getGroupId().get());
assertEquals(1, injectionRangeAction.getRanges().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.powsybl.openrao.data.crac.api.rangeaction.PstRangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.PstRangeActionAdder;
import com.powsybl.openrao.data.crac.api.range.RangeType;
import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageMethod;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -55,8 +55,8 @@ void testAdd() {
.withNetworkElement(networkElementId)
.withGroupId("groupId1")
.withActivationCost(0d)
.withVariationCost(0d, RangeAction.VariationDirection.UP)
.withVariationCost(0d, RangeAction.VariationDirection.DOWN)
.withVariationCost(0d, VariationDirection.UP)
.withVariationCost(0d, VariationDirection.DOWN)
.newTapRange()
.withMinTap(-10)
.withMaxTap(10)
Expand All @@ -74,8 +74,8 @@ void testAdd() {
assertEquals(networkElementId, pstRangeAction.getNetworkElement().getId());
assertEquals("BE", pstRangeAction.getOperator());
assertEquals(Optional.of(0d), pstRangeAction.getActivationCost());
assertEquals(Optional.of(0d), pstRangeAction.getVariationCost(RangeAction.VariationDirection.UP));
assertEquals(Optional.of(0d), pstRangeAction.getVariationCost(RangeAction.VariationDirection.DOWN));
assertEquals(Optional.of(0d), pstRangeAction.getVariationCost(VariationDirection.UP));
assertEquals(Optional.of(0d), pstRangeAction.getVariationCost(VariationDirection.DOWN));
assertEquals(1, pstRangeAction.getRanges().size());
assertEquals(1, pstRangeAction.getUsageRules().size());
assertEquals(1, crac.getNetworkElements().size());
Expand Down Expand Up @@ -127,8 +127,8 @@ void testAddAutoWithSpeed() {

assertEquals(123, pstRangeAction.getSpeed().get().intValue());
assertTrue(pstRangeAction.getActivationCost().isEmpty());
assertTrue(pstRangeAction.getVariationCost(RangeAction.VariationDirection.UP).isEmpty());
assertTrue(pstRangeAction.getVariationCost(RangeAction.VariationDirection.DOWN).isEmpty());
assertTrue(pstRangeAction.getVariationCost(VariationDirection.UP).isEmpty());
assertTrue(pstRangeAction.getVariationCost(VariationDirection.DOWN).isEmpty());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.powsybl.openrao.data.crac.api.InstantKind;
import com.powsybl.openrao.data.crac.api.networkaction.ActionType;
import com.powsybl.openrao.data.crac.api.range.RangeType;
import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.VariationDirection;
import com.powsybl.openrao.data.crac.api.usagerule.UsageMethod;

import java.util.HashMap;
Expand Down Expand Up @@ -310,8 +310,8 @@ public static Crac create(CracFactory cracFactory) {
.withNetworkElementAndKey(1., "generator1Id")
.withNetworkElementAndKey(-1., "generator2Id", "generator2Name")
.withActivationCost(100d)
.withVariationCost(750d, RangeAction.VariationDirection.UP)
.withVariationCost(1000d, RangeAction.VariationDirection.DOWN)
.withVariationCost(750d, VariationDirection.UP)
.withVariationCost(1000d, VariationDirection.DOWN)
.newRange().withMin(-500).withMax(500).add()
.newRange().withMin(-1000).withMax(1000).add()
.newOnFlowConstraintInCountryUsageRule().withInstant(CURATIVE_INSTANT_ID).withContingency("contingency2Id").withCountry(Country.ES).withUsageMethod(UsageMethod.AVAILABLE).add()
Expand All @@ -322,8 +322,8 @@ public static Crac create(CracFactory cracFactory) {
.withName("counterTradeRange1Name")
.withExportingCountry(Country.FR)
.withImportingCountry(Country.DE)
.withVariationCost(2000d, RangeAction.VariationDirection.UP)
.withVariationCost(1000d, RangeAction.VariationDirection.DOWN)
.withVariationCost(2000d, VariationDirection.UP)
.withVariationCost(1000d, VariationDirection.DOWN)
.newRange().withMin(-500).withMax(500).add()
.newRange().withMin(-1000).withMax(1000).add()
.newOnFlowConstraintInCountryUsageRule().withInstant(CURATIVE_INSTANT_ID).withCountry(Country.ES).withUsageMethod(UsageMethod.AVAILABLE).add()
Expand Down
Loading

0 comments on commit da19936

Please sign in to comment.