Skip to content

Commit

Permalink
changes new limits computations ( ref #40 )
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Biasuzzi committed Aug 30, 2016
1 parent b62e6f3 commit 0b3d67b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
Expand Up @@ -268,27 +268,15 @@ private void setNewLowVoltageLimit(String stateId, LimitViolation violation, flo
private float getNewUpperLimit(LimitViolation violation, float margin) {
float newLimit = 9999;
if ( config.isInAreaOfInterest(violation, network) ) {
float increment = (float) ((violation.getLimit() == 0)
? Math.ceil(violation.getValue()*100)
: Math.ceil((violation.getValue()-violation.getLimit())*100/violation.getLimit()));
increment += margin;
newLimit = (violation.getLimit() == 0)
? (increment/100)
: (violation.getLimit()+(violation.getLimit()*increment/100));
newLimit = violation.getValue() * (1.0f + margin/100.0f);
}
return newLimit;
}

private float getNewLowerLimit(LimitViolation violation, float margin) {
float newLimit = -9999;
if ( config.isInAreaOfInterest(violation, network) ) {
float increment = (float) ((violation.getLimit() == 0)
? Math.ceil(-violation.getValue()*100)
: Math.ceil((violation.getLimit()-violation.getValue())*100/violation.getLimit()));
increment += margin;
newLimit = (violation.getLimit() == 0)
? (increment/100)
: (violation.getLimit()-(violation.getLimit()*increment/100));
newLimit = violation.getValue() * (1.0f - margin/100.0f);
}
return newLimit;
}
Expand Down
Expand Up @@ -53,13 +53,13 @@ private void checkOriginalNetworkLimits() {

private void checkModifiedNetworkLimits(int margin) {
Line line = network.getLine(ConstraintsModifierTestUtils.LINE_ID);
float newCurrentLimit = ConstraintsModifierTestUtils.NEW_CURRENT_LIMIT + (ConstraintsModifierTestUtils.CURRENT_LIMIT * margin / 100);
float newCurrentLimit = ConstraintsModifierTestUtils.CURRENT_VALUE * (1.0f + margin / 100.0f);
assertEquals(newCurrentLimit, line.getCurrentLimits1().getPermanentLimit(), 0);
VoltageLevel voltageLevel1 = network.getVoltageLevel(ConstraintsModifierTestUtils.VOLTAGE_LEVEL_1_ID);
float newHighVoltageLimit = ConstraintsModifierTestUtils.NEW_HIGH_VOLTAGE_LIMIT + (ConstraintsModifierTestUtils.HIGH_VOLTAGE_LIMIT * margin / 100);
float newHighVoltageLimit = ConstraintsModifierTestUtils.V * (1.0f + margin / 100.0f);
assertEquals(newHighVoltageLimit, voltageLevel1.getHighVoltageLimit(), 0);
VoltageLevel voltageLevel2 = network.getVoltageLevel(ConstraintsModifierTestUtils.VOLTAGE_LEVEL_2_ID);
float newLowVoltageLimit = ConstraintsModifierTestUtils.NEW_LOW_VOLTAGE_LIMIT - (ConstraintsModifierTestUtils.LOW_VOLTAGE_LIMIT * margin / 100);
float newLowVoltageLimit = ConstraintsModifierTestUtils.V * (1.0f - margin / 100.0f);
assertEquals(newLowVoltageLimit, voltageLevel2.getLowVoltageLimit(), 0);
}

Expand Down
Expand Up @@ -28,15 +28,12 @@ public class ConstraintsModifierTestUtils {

public static final String VOLTAGE_LEVEL_1_ID = "vl1";
public static final float HIGH_VOLTAGE_LIMIT = 300f;
public static final float NEW_HIGH_VOLTAGE_LIMIT = 381f;
public static final String VOLTAGE_LEVEL_2_ID = "vl2";
public static final float LOW_VOLTAGE_LIMIT = 420f;
public static final float NEW_LOW_VOLTAGE_LIMIT = 378f;
public static final String LINE_ID = "line1";
public static final float CURRENT_LIMIT = 100f;
public static final float NEW_CURRENT_LIMIT = 120f;
private static final float CURRENT_VALUE = 119.25632f;
private static final float V = 380f;
public static final float CURRENT_VALUE = 119.25632f;
public static final float V = 380f;
private static final float Q = 55f;
private static final float P = 56f;
private static final Country COUNTRY = Country.FR;
Expand Down

0 comments on commit 0b3d67b

Please sign in to comment.