Skip to content

Commit

Permalink
checkstyle
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Mitri <[email protected]>
  • Loading branch information
pet-mit committed Dec 6, 2024
1 parent b21def0 commit 5486287
Showing 1 changed file with 1 addition and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,71 +104,7 @@ void smallRaoWithout2P() throws IOException {
}

@Test
void smallRaoWith2P() throws IOException {
// Same RAO as before but activating 2P => results should be better

network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct"));
crac = Crac.read("small-crac-2P.json", getClass().getResourceAsStream("/crac/small-crac-2P.json"), network);
RaoInput raoInput = RaoInput.build(network, crac).build();
RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json"));

// Activate 2P
raoParameters.getSecondPreventiveRaoParameters().setExecutionCondition(SecondPreventiveRaoParameters.ExecutionCondition.POSSIBLE_CURATIVE_IMPROVEMENT);

// Run RAO
RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join();
/*ArrayList<Instant> instants = new ArrayList<>();
instants.add(null);
instants.addAll(crac.getSortedInstants());
for (Instant instant : instants) {
for (FlowCnec cnec : crac.getFlowCnecs()) {
if (instant == null || !cnec.getState().getInstant().comesBefore(instant)) {
double flow = raoResult.getFlow(instant, cnec, TwoSides.TWO, Unit.AMPERE);
String instantId = (instant == null) ? "null" : String.format("crac.getInstant(\"%s\")", instant.getId());
System.out.println(String.format(Locale.ENGLISH, "() -> assertEquals(%.2f, raoResult.getFlow(%s, crac.getFlowCnec(\"%s\"), TwoSides.TWO, Unit.AMPERE), 0.01),", flow, instantId, cnec.getId()));
}
}
}*/
assertAll(
() -> assertEquals(451.09, raoResult.getFlow(null, crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-1886.06, raoResult.getFlow(null, crac.getFlowCnec("NNL2AA1 BBE3AA1 1 - preventive"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(451.09, raoResult.getFlow(null, crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - outage"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-294.36, raoResult.getFlow(null, crac.getFlowCnec("FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-294.36, raoResult.getFlow(null, crac.getFlowCnec("FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - outage"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(474.54, raoResult.getFlow(null, crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - preventive"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(2371.88, raoResult.getFlow(null, crac.getFlowCnec("FFR1AA1 FFR4AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(484.19, raoResult.getFlow(crac.getInstant("preventive"), crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-1897.99, raoResult.getFlow(crac.getInstant("preventive"), crac.getFlowCnec("NNL2AA1 BBE3AA1 1 - preventive"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(484.19, raoResult.getFlow(crac.getInstant("preventive"), crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - outage"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-278.10, raoResult.getFlow(crac.getInstant("preventive"), crac.getFlowCnec("FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-278.10, raoResult.getFlow(crac.getInstant("preventive"), crac.getFlowCnec("FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - outage"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(485.38, raoResult.getFlow(crac.getInstant("preventive"), crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - preventive"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(2674.61, raoResult.getFlow(crac.getInstant("preventive"), crac.getFlowCnec("FFR1AA1 FFR4AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(484.19, raoResult.getFlow(crac.getInstant("outage"), crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(484.19, raoResult.getFlow(crac.getInstant("outage"), crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - outage"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-278.10, raoResult.getFlow(crac.getInstant("outage"), crac.getFlowCnec("FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-278.10, raoResult.getFlow(crac.getInstant("outage"), crac.getFlowCnec("FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - outage"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(2674.61, raoResult.getFlow(crac.getInstant("outage"), crac.getFlowCnec("FFR1AA1 FFR4AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(484.19, raoResult.getFlow(crac.getInstant("auto"), crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-278.10, raoResult.getFlow(crac.getInstant("auto"), crac.getFlowCnec("FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(2674.61, raoResult.getFlow(crac.getInstant("auto"), crac.getFlowCnec("FFR1AA1 FFR4AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(221.10, raoResult.getFlow(crac.getInstant("curative"), crac.getFlowCnec("FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(-134.98, raoResult.getFlow(crac.getInstant("curative"), crac.getFlowCnec("FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(1444.08, raoResult.getFlow(crac.getInstant("curative"), crac.getFlowCnec("FFR1AA1 FFR4AA1 1 - co1_fr2_fr3_1 - curative"), TwoSides.TWO, Unit.AMPERE), 0.01),
() -> assertEquals(371.88, raoResult.getFunctionalCost(null), 0.01),
() -> assertEquals(674.6, raoResult.getFunctionalCost(preventiveInstant), 0.01),
() -> assertEquals(-555.91, raoResult.getFunctionalCost(curativeInstant), 0.01),
() -> assertEquals(Set.of(crac.getNetworkAction("close_de3_de4"), crac.getNetworkAction("open_fr1_fr2")), raoResult.getActivatedNetworkActionsDuringState(crac.getPreventiveState())),
() -> assertEquals(Set.of(crac.getNetworkAction("open_fr1_fr3")), raoResult.getActivatedNetworkActionsDuringState(crac.getState(crac.getContingency("co1_fr2_fr3_1"), curativeInstant))),
() -> assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST, raoResult.getOptimizationStepsExecuted())
);

OpenRaoException exception = assertThrows(OpenRaoException.class, () -> raoResult.setOptimizationStepsExecuted(FIRST_PREVENTIVE_ONLY));
assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage());
}

@Test
void smallRaoWith2P_optimalPRAsAlreadyApplied() throws IOException {
void smallRaoWith2POptimalPRAsAlreadyApplied() throws IOException {
// Same RAO as before but activating 2P => results should be better

network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct"));
Expand Down

0 comments on commit 5486287

Please sign in to comment.