From b4859b0ceba0db05a9632ac23116b7572b84c45a Mon Sep 17 00:00:00 2001 From: Pauline Jean-Marie Date: Thu, 21 Nov 2024 15:44:28 +0100 Subject: [PATCH] To have same behavior than before change on extensions: create default values in extension if exist in rao-parameters and vive-versa Signed-off-by: Pauline Jean-Marie --- docs/parameters.md | 138 ++++++++++-------- .../json/RaoParametersDeserializer.java | 2 + .../raoapi/parameters/RaoParameters.java | 45 +++++- .../RaoParametersYamlConfigTest.java | 6 +- ...rameters_config_withPartialExtensions.json | 3 + .../PrePerimeterSensitivityAnalysis.java | 4 +- .../searchtreerao/commons/RaoUtil.java | 4 +- .../PrePerimeterSensitivityAnalysisTest.java | 21 +-- .../openrao/tests/utils/CneHelper.java | 2 +- .../powsybl/openrao/tests/utils/RaoUtils.java | 2 +- 10 files changed, 142 insertions(+), 85 deletions(-) diff --git a/docs/parameters.md b/docs/parameters.md index 04217f705b..618c50a04b 100644 --- a/docs/parameters.md +++ b/docs/parameters.md @@ -124,6 +124,68 @@ optimisation of specific CNECs in specific conditions. This parameter has no effect on the preventive RAO. This parameter should be set to true for CORE CC. +### Loop-flow optional parameter +Adding a LoopFlowParameters to RaoParameters will activate [loop-flow constraints](/castor/special-features/loop-flows.md). +(The RAO will monitor the loop-flows on CNECs that have a LoopFlowThreshold extension.) +The following parameters tune some of these constraints, the one which are not implementation specific. +See also: [Modelling loop-flows and their virtual cost](/castor/linear-problem/max-loop-flow-filler.md) + +#### acceptable-increase +- **Expected value**: numeric values, in MEGAWATT unit +- **Default value**: 0.0 MW +- **Usage**: the increase of the initial loop-flow that is allowed by the optimisation. That is to say, the optimisation + bounds the loop-flow on CNECs by: + *LFcnec ≤ max(MaxLFcnec , InitLFcnec + acceptableAugmentation)* + With *LFcnec* the loop-flow on the CNEC after optimisation, *MaxLFcnec* is the CNEC loop-flow threshold, *InitLFcnec* + the initial loop-flow on the cnec, and *acceptableAugmentation* the so-called "loop-flow-acceptable-augmentation" + coefficient. + If this constraint cannot be respected and the loop-flow exceeds the aforementioned threshold, the objective function + associated to this situation will be penalized (see also [violation-cost](#violation-cost)) + +#### countries +- **Expected value**: array of country codes "XX" +- **Default value**: all countries encountered +- **Usage**: list of countries for which loop-flows should be limited accordingly to the specified constraints. If not + present, all countries encountered in the input files will be considered. Note that a cross-border line will have its + loop-flows monitored if at least one of its two sides is in a country from this list. + Example of this parameter : [ "BE", "NL" ] if you want to monitor loop-flows in and out of Belgium and the + Netherlands. + +### MNEC optional parameter +Adding a MnecParameters to RaoParameters will activate [MNEC constraints](/castor/linear-problem/mnec-filler.md). +(The RAO will only monitor CNECs that are only ["monitored"](/input-data/crac/json.md#cnecs)). +The following parameters tune some of these constraints, the one which are not implementation specific. +See also: [Modelling MNECs and their virtual cost](/castor/linear-problem/mnec-filler.md) + +#### acceptable-margin-decrease +- **Expected value**: numeric values, in MEGAWATT unit +- **Default value**: 50 MW (required by CORE CC methodology) +- **Usage**: the decrease of the initial margin that is allowed by the optimisation on MNECs. + In other words, it defines the bounds for the margins on the MNECs by + *Mcnec ≥ max(0, m0cnec − acceptableDiminution)* + With *Mcnec* the margin on the cnec after optimisation, *m0cnec* the initial margin on the cnec, and + *acceptableDiminution* the so-called "acceptable-margin-decrease" coefficient. + For the CORE CC calculation, the ACER methodology fixes this coefficient at 50 MW. + For CSE CC calculation, setting this parameter to -99999 allows the MNEC constraints to consider + the thresholds in the CRAC only. + +### Relative margins optioanl parameter +Adding a RelativeMarginsParameters is mandatory when [objective function is relative](#type). +The following parameters tune some constraints, the one which are not implementation specific. +See also: [Modelling the maximum minimum relative margin objective function](/castor/linear-problem/max-min-relative-margin-filler.md) + +#### ptdf-boundaries +- **Expected value**: array of zone-to-zone PTDF computation definition, expressed as an equation. + Zones are defined by their 2-character code or their 16-character EICode, inside **{ }** characters. + Zones are seperated by + or -. + All combinations are allowed: country codes, EIC, a mix. +- **Default value**: empty array +- **Usage**: contains the boundaries on which the PTDF absolute sums should be computed (and added to the denominator of + the relative RAM). + For example, in the SWE case, it should be equal to [ "{FR}-{ES}", "{ES}-{PT}" ]. + For CORE, we should use all the CORE region boundaries (all countries seperated by a - sign) plus Alegro's special + equation: "{BE}-{22Y201903144---9}-{DE}+{22Y201903145---4}" + ## Extensions The following extensions can be added to RaoParameters: - to configure implementation specific parameters @@ -405,25 +467,13 @@ These parameters (multi-threading) allow you to run a RAO making the most out of *Note that the more available cpus is configured, the more RAM is required by the RAO, and that the performance of the RAO might significantly decrease on a machine with limited memory resources.* -### Loop-flow extension -Adding a LoopFlowParameters extension to RaoParameters will activate [loop-flow constraints](/castor/special-features/loop-flows.md). +#### Loop-flow optional parameter +Adding a LoopFlowParameters to OpenRaoSearchTreeParameters will activate [loop-flow constraints](/castor/special-features/loop-flows.md). (The RAO will monitor the loop-flows on CNECs that have a LoopFlowThreshold extension.) -The following parameters tune these constraints. +The following parameters tune some of these constraints, the one which are implementation specific. See also: [Modelling loop-flows and their virtual cost](/castor/linear-problem/max-loop-flow-filler.md) -#### acceptable-increase -- **Expected value**: numeric values, in MEGAWATT unit -- **Default value**: 0.0 MW -- **Usage**: the increase of the initial loop-flow that is allowed by the optimisation. That is to say, the optimisation - bounds the loop-flow on CNECs by: - *LFcnec ≤ max(MaxLFcnec , InitLFcnec + acceptableAugmentation)* - With *LFcnec* the loop-flow on the CNEC after optimisation, *MaxLFcnec* is the CNEC loop-flow threshold, *InitLFcnec* - the initial loop-flow on the cnec, and *acceptableAugmentation* the so-called "loop-flow-acceptable-augmentation" - coefficient. - If this constraint cannot be respected and the loop-flow exceeds the aforementioned threshold, the objective function - associated to this situation will be penalized (see also [violation-cost](#violation-cost)) - -#### ptdf-approximation +##### ptdf-approximation - **Expected value**: one of the following: - "FIXED_PTDF" - "UPDATE_PTDF_WITH_TOPO" @@ -439,7 +489,7 @@ See also: [Modelling loop-flows and their virtual cost](/castor/linear-problem/m each new combination of PST taps (i.e. for each iteration of the linear optimisation). *Note that this option is only relevant in AC-loadflow mode, as the UPDATE_PTDF_WITH_TOPO already maximizes accuracy in DC.* -#### constraint-adjustment-coefficient +##### constraint-adjustment-coefficient - **Expected value**: numeric values, in MEGAWATT unit - **Default value**: 0.0 MW - **Usage**: this parameter acts as a margin which tightens, in the linear optimisation problem of RAO, the bounds of the @@ -450,41 +500,20 @@ See also: [Modelling loop-flows and their virtual cost](/castor/linear-problem/m therefore increase the probability that the loop-flow constraints which are respected in the linear optimisation problem, remain respected once the loop-flows are re-computed without the linear approximations. -#### violation-cost +##### violation-cost - **Expected value**: numeric values, unit = unit of the objective function per MEGAWATT - **Default value**: 10.0 - **Usage**: this parameter is the cost of each excess of loop-flow. That is to say, if the loop-flows on one or several CNECs exceed the loop-flow threshold, a penalty will be added in the objective function of the RAO equal to: *violation-cost x sum{cnec} excess-loop-flow(cnec)* -#### countries -- **Expected value**: array of country codes "XX" -- **Default value**: all countries encountered -- **Usage**: list of countries for which loop-flows should be limited accordingly to the specified constraints. If not - present, all countries encountered in the input files will be considered. Note that a cross-border line will have its - loop-flows monitored if at least one of its two sides is in a country from this list. - Example of this parameter : [ "BE", "NL" ] if you want to monitor loop-flows in and out of Belgium and the - Netherlands. - -### MNEC extension -Adding a MnecParameters extension to RaoParameters will activate [MNEC constraints](/castor/linear-problem/mnec-filler.md). +#### MNEC optional parameter +Adding a MnecParameters to OpenRaoSearchTreeParameters will activate [MNEC constraints](/castor/linear-problem/mnec-filler.md). (The RAO will only monitor CNECs that are only ["monitored"](/input-data/crac/json.md#cnecs)). -The following parameters tune these constraints. +The following parameters tune some of these constraints, the one which are implementation specific. See also: [Modelling MNECs and their virtual cost](/castor/linear-problem/mnec-filler.md) -#### acceptable-margin-decrease -- **Expected value**: numeric values, in MEGAWATT unit -- **Default value**: 50 MW (required by CORE CC methodology) -- **Usage**: the decrease of the initial margin that is allowed by the optimisation on MNECs. - In other words, it defines the bounds for the margins on the MNECs by - *Mcnec ≥ max(0, m0cnec − acceptableDiminution)* - With *Mcnec* the margin on the cnec after optimisation, *m0cnec* the initial margin on the cnec, and - *acceptableDiminution* the so-called "acceptable-margin-decrease" coefficient. - For the CORE CC calculation, the ACER methodology fixes this coefficient at 50 MW. - For CSE CC calculation, setting this parameter to -99999 allows the MNEC constraints to consider - the thresholds in the CRAC only. - -#### violation-cost +##### violation-cost - **Expected value**: numeric values, no unit (it applies as a multiplier for the constraint violation inside the objective function) - **Default value**: 10.0 (same as [loop-flow violation cost](#violation-cost)) @@ -494,7 +523,7 @@ See also: [Modelling MNECs and their virtual cost](/castor/linear-problem/mnec-f MNECs' constraints are respected. The penalty injected in the objective function is equal to the violation (difference between actual margin and least acceptable margin) multiplied by this parameter. -#### constraint-adjustment-coefficient +##### constraint-adjustment-coefficient - **Expected value**: numeric values, in MEGAWATT unit - **Default value**: 0.0 - **Usage**: this coefficient is here to mitigate the approximation made by the linear optimisation (approximation = use @@ -504,23 +533,12 @@ See also: [Modelling MNECs and their virtual cost](/castor/linear-problem/mnec-f It tightens the MNEC constraint, in order to take some margin for that constraint to stay respected once the approximations are removed (i.e. taps have been rounded and real flow calculated) -### Relative margins extension -Adding a RelativeMarginsParameters extension is mandatory when [objective function is relative](#type). +#### Relative margins optional parameter +Adding a RelativeMarginsParameters is mandatory when [objective function is relative](#type). +The following parameters tune the constraints which are implementation specific. See also: [Modelling the maximum minimum relative margin objective function](/castor/linear-problem/max-min-relative-margin-filler.md) -#### ptdf-boundaries -- **Expected value**: array of zone-to-zone PTDF computation definition, expressed as an equation. -Zones are defined by their 2-character code or their 16-character EICode, inside **{ }** characters. -Zones are seperated by + or -. - All combinations are allowed: country codes, EIC, a mix. -- **Default value**: empty array -- **Usage**: contains the boundaries on which the PTDF absolute sums should be computed (and added to the denominator of - the relative RAM). - For example, in the SWE case, it should be equal to [ "{FR}-{ES}", "{ES}-{PT}" ]. - For CORE, we should use all the CORE region boundaries (all countries seperated by a - sign) plus Alegro's special - equation: "{BE}-{22Y201903144---9}-{DE}+{22Y201903145---4}" - -#### ptdf-approximation +##### ptdf-approximation - **Expected value**: one of the following: - "FIXED_PTDF" - "UPDATE_PTDF_WITH_TOPO" @@ -536,7 +554,7 @@ Zones are seperated by + or -. each new combination of PST taps (i.e. for each iteration of the linear optimisation). *Note that this option is only relevant in AC-loadflow mode, as the UPDATE_PTDF_WITH_TOPO already maximizes accuracy in DC.* -#### ptdf-sum-lower-bound +##### ptdf-sum-lower-bound - **Expected value**: numeric value, no unit (homogeneous to PTDFs) - **Default value**: 0.01 - **Usage**: PTDF absolute sums are used as a denominator in the objective function. In order to prevent the objective diff --git a/ra-optimisation/rao-api/src/main/java/com/powsybl/openrao/raoapi/json/RaoParametersDeserializer.java b/ra-optimisation/rao-api/src/main/java/com/powsybl/openrao/raoapi/json/RaoParametersDeserializer.java index 15e4cb09b2..b942bd20cb 100644 --- a/ra-optimisation/rao-api/src/main/java/com/powsybl/openrao/raoapi/json/RaoParametersDeserializer.java +++ b/ra-optimisation/rao-api/src/main/java/com/powsybl/openrao/raoapi/json/RaoParametersDeserializer.java @@ -20,6 +20,7 @@ import java.util.List; import static com.powsybl.openrao.raoapi.RaoParametersCommons.*; +import static com.powsybl.openrao.raoapi.parameters.RaoParameters.addOptionalExtensionsDefaultValuesIfExist; /** * @author Baptiste Seguinot {@literal } @@ -84,6 +85,7 @@ public RaoParameters deserialize(JsonParser parser, DeserializationContext deser } } extensions.forEach(extension -> parameters.addExtension((Class) extension.getClass(), extension)); + addOptionalExtensionsDefaultValuesIfExist(parameters); return parameters; } } diff --git a/ra-optimisation/rao-api/src/main/java/com/powsybl/openrao/raoapi/parameters/RaoParameters.java b/ra-optimisation/rao-api/src/main/java/com/powsybl/openrao/raoapi/parameters/RaoParameters.java index 83e10f85ef..0aedf0f127 100644 --- a/ra-optimisation/rao-api/src/main/java/com/powsybl/openrao/raoapi/parameters/RaoParameters.java +++ b/ra-optimisation/rao-api/src/main/java/com/powsybl/openrao/raoapi/parameters/RaoParameters.java @@ -121,6 +121,7 @@ public static RaoParameters load(PlatformConfig platformConfig) { RaoParameters parameters = new RaoParameters(); load(parameters, platformConfig); parameters.loadExtensions(platformConfig); + addOptionalExtensionsDefaultValuesIfExist(parameters); return parameters; } @@ -145,7 +146,47 @@ private void loadExtensions(PlatformConfig platformConfig) { } } - public boolean hasLoopFlowParameters() { - return this.getLoopFlowParameters().isPresent() || this.hasExtension(OpenRaoSearchTreeParameters.class) && this.getExtension(OpenRaoSearchTreeParameters.class).getLoopFlowParameters().isPresent(); + public static void addOptionalExtensionsDefaultValuesIfExist(RaoParameters parameters) { + OpenRaoSearchTreeParameters extension = parameters.getExtension(OpenRaoSearchTreeParameters.class); + boolean hasExtension = !Objects.isNull(extension); + if (parameters.getMnecParameters().isPresent()) { + if (!hasExtension) { + parameters.addExtension(OpenRaoSearchTreeParameters.class, new OpenRaoSearchTreeParameters()); + } + extension = parameters.getExtension(OpenRaoSearchTreeParameters.class); + if (extension.getMnecParameters().isEmpty()) { + extension.setMnecParameters(new com.powsybl.openrao.raoapi.parameters.extensions.MnecParameters()); + } + } else { + if (hasExtension && extension.getMnecParameters().isPresent()) { + parameters.setMnecParameters(new com.powsybl.openrao.raoapi.parameters.MnecParameters()); + } + } + if (parameters.getRelativeMarginsParameters().isPresent()) { + if (!hasExtension) { + parameters.addExtension(OpenRaoSearchTreeParameters.class, new OpenRaoSearchTreeParameters()); + } + extension = parameters.getExtension(OpenRaoSearchTreeParameters.class); + if (extension.getRelativeMarginsParameters().isEmpty()) { + extension.setRelativeMarginsParameters(new com.powsybl.openrao.raoapi.parameters.extensions.RelativeMarginsParameters()); + } + } else { + if (hasExtension && extension.getRelativeMarginsParameters().isPresent()) { + parameters.setRelativeMarginsParameters(new com.powsybl.openrao.raoapi.parameters.RelativeMarginsParameters()); + } + } + if (parameters.getLoopFlowParameters().isPresent()) { + if (!hasExtension) { + parameters.addExtension(OpenRaoSearchTreeParameters.class, new OpenRaoSearchTreeParameters()); + } + extension = parameters.getExtension(OpenRaoSearchTreeParameters.class); + if (extension.getLoopFlowParameters().isEmpty()) { + extension.setLoopFlowParameters(new com.powsybl.openrao.raoapi.parameters.extensions.LoopFlowParameters()); + } + } else { + if (hasExtension && extension.getLoopFlowParameters().isPresent()) { + parameters.setLoopFlowParameters(new com.powsybl.openrao.raoapi.parameters.LoopFlowParameters()); + } + } } } diff --git a/ra-optimisation/rao-api/src/test/java/com/powsybl/openrao/raoapi/parameters/RaoParametersYamlConfigTest.java b/ra-optimisation/rao-api/src/test/java/com/powsybl/openrao/raoapi/parameters/RaoParametersYamlConfigTest.java index f07d77fb1d..1d6275aa0b 100644 --- a/ra-optimisation/rao-api/src/test/java/com/powsybl/openrao/raoapi/parameters/RaoParametersYamlConfigTest.java +++ b/ra-optimisation/rao-api/src/test/java/com/powsybl/openrao/raoapi/parameters/RaoParametersYamlConfigTest.java @@ -222,11 +222,15 @@ void testConfigWithPartialExtensions() throws IOException { assertTrue(parameters.getMnecParameters().isEmpty()); assertTrue(searchTreeParameters.getMnecParameters().isEmpty()); - assertTrue(parameters.getRelativeMarginsParameters().isEmpty()); assertTrue(searchTreeParameters.getRelativeMarginsParameters().isPresent()); assertEquals(PtdfApproximation.UPDATE_PTDF_WITH_TOPO_AND_PST, searchTreeParameters.getRelativeMarginsParameters().get().getPtdfApproximation()); assertEquals(0.02, searchTreeParameters.getRelativeMarginsParameters().get().getPtdfSumLowerBound(), DOUBLE_TOLERANCE); + // If RelativeMarginsParameters is present on extension it should be created on rao-parameters, + // if it exists on rao-parameters it should be created on extension. + // The same rule exist for MnecParameters and LoopFlowParameters + assertTrue(parameters.getRelativeMarginsParameters().isPresent()); + // Compare to json roundTripTest(parameters, JsonRaoParameters::write, JsonRaoParameters::read, "/RaoParameters_config_withPartialExtensions.json"); } diff --git a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withPartialExtensions.json b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withPartialExtensions.json index 1a451b42de..d608033052 100644 --- a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withPartialExtensions.json +++ b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withPartialExtensions.json @@ -17,6 +17,9 @@ "not-optimized-cnecs" : { "do-not-optimize-curative-cnecs-for-tsos-without-cras" : false }, + "relative-margins-parameters" : { + "ptdf-boundaries" : [ ] + }, "loop-flow-parameters" : { "acceptable-increase" : 0.0, "countries" : [ "ES", "FR", "PT" ] diff --git a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/PrePerimeterSensitivityAnalysis.java b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/PrePerimeterSensitivityAnalysis.java index 7281fb6817..9227f9f794 100644 --- a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/PrePerimeterSensitivityAnalysis.java +++ b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/PrePerimeterSensitivityAnalysis.java @@ -55,7 +55,7 @@ public PrePerimeterSensitivityAnalysis(Set flowCnecs, public PrePerimeterResult runInitialSensitivityAnalysis(Network network, Crac crac) { SensitivityComputer.SensitivityComputerBuilder sensitivityComputerBuilder = buildSensiBuilder() .withOutageInstant(crac.getOutageInstant()); - if (raoParameters.hasLoopFlowParameters()) { + if (raoParameters.getLoopFlowParameters().isPresent()) { sensitivityComputerBuilder.withCommercialFlowsResults(toolProvider.getLoopFlowComputation(), toolProvider.getLoopFlowCnecs(flowCnecs)); } if (raoParameters.getObjectiveFunctionParameters().getType().relativePositiveMargins()) { @@ -86,7 +86,7 @@ public PrePerimeterResult runBasedOnInitialResults(Network network, } }); } - if (raoParameters.getObjectiveFunctionParameters().getType().relativePositiveMargins()) { // TODO if null + if (raoParameters.getObjectiveFunctionParameters().getType().relativePositiveMargins()) { if (searchTreeParameters.getRelativeMarginsParameters().orElseThrow().getPtdfApproximation().shouldUpdatePtdfWithTopologicalChange()) { sensitivityComputerBuilder.withPtdfsResults(toolProvider.getAbsolutePtdfSumsComputation(), flowCnecs); } else { diff --git a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoUtil.java b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoUtil.java index 074f8bdfb1..2a31f73529 100644 --- a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoUtil.java +++ b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoUtil.java @@ -68,14 +68,14 @@ && getSensitivityWithLoadFlowParameters(raoParameters).getLoadFlowParameters().i } } - if ((raoParameters.hasLoopFlowParameters() + if ((raoParameters.getLoopFlowParameters().isPresent() || raoParameters.getObjectiveFunctionParameters().getType().relativePositiveMargins()) && (Objects.isNull(raoInput.getReferenceProgram()))) { OpenRaoLoggerProvider.BUSINESS_WARNS.warn("No ReferenceProgram provided. A ReferenceProgram will be generated using information in the network file."); raoInput.setReferenceProgram(ReferenceProgramBuilder.buildReferenceProgram(raoInput.getNetwork(), getLoadFlowProvider(raoParameters), getSensitivityWithLoadFlowParameters(raoParameters).getLoadFlowParameters())); } - if (raoParameters.hasLoopFlowParameters() && (Objects.isNull(raoInput.getReferenceProgram()) || Objects.isNull(raoInput.getGlskProvider()))) { + if (raoParameters.getLoopFlowParameters().isPresent() && (Objects.isNull(raoInput.getReferenceProgram()) || Objects.isNull(raoInput.getGlskProvider()))) { String msg = format( "Loopflow computation cannot be performed on CRAC %s because it lacks a ReferenceProgram or a GlskProvider", raoInput.getCrac().getId()); diff --git a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/castor/algorithm/PrePerimeterSensitivityAnalysisTest.java b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/castor/algorithm/PrePerimeterSensitivityAnalysisTest.java index e5bc6b2844..8942c7afd6 100644 --- a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/castor/algorithm/PrePerimeterSensitivityAnalysisTest.java +++ b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/castor/algorithm/PrePerimeterSensitivityAnalysisTest.java @@ -17,7 +17,7 @@ import com.powsybl.openrao.loopflowcomputation.LoopFlowResult; import com.powsybl.openrao.raoapi.parameters.ObjectiveFunctionParameters; import com.powsybl.openrao.raoapi.parameters.RaoParameters; -import com.powsybl.openrao.raoapi.parameters.extensions.LoopFlowParameters; +import com.powsybl.openrao.raoapi.parameters.LoopFlowParameters; import com.powsybl.openrao.raoapi.parameters.extensions.OpenRaoSearchTreeParameters; import com.powsybl.openrao.raoapi.parameters.extensions.PtdfApproximation; import com.powsybl.openrao.raoapi.parameters.extensions.RelativeMarginsParameters; @@ -113,13 +113,7 @@ void testRunWithPtdf() { @Test void testRunWithLf() { - OpenRaoSearchTreeParameters searchTreeParameters = new OpenRaoSearchTreeParameters(); - raoParameters.addExtension(OpenRaoSearchTreeParameters.class, searchTreeParameters); - LoopFlowParameters loopFlowParameters = new LoopFlowParameters(); - searchTreeParameters.setLoopFlowParameters(loopFlowParameters); - loopFlowParameters.setPtdfApproximation(PtdfApproximation.FIXED_PTDF); - raoParameters.getObjectiveFunctionParameters().setType(ObjectiveFunctionParameters.ObjectiveFunctionType.MAX_MIN_MARGIN); - raoParameters.getObjectiveFunctionParameters().setUnit(Unit.AMPERE); + raoParameters.setLoopFlowParameters(new LoopFlowParameters()); mockSystematicSensitivityInterface(false, true); PrePerimeterResult result = prePerimeterSensitivityAnalysis.runInitialSensitivityAnalysis(network, crac); @@ -128,13 +122,8 @@ void testRunWithLf() { @Test void testRunWithPtdfAndLf() { - OpenRaoSearchTreeParameters searchTreeParameters = new OpenRaoSearchTreeParameters(); - raoParameters.addExtension(OpenRaoSearchTreeParameters.class, searchTreeParameters); - LoopFlowParameters loopFlowParameters = new LoopFlowParameters(); - searchTreeParameters.setLoopFlowParameters(loopFlowParameters); - loopFlowParameters.setPtdfApproximation(PtdfApproximation.FIXED_PTDF); + raoParameters.setLoopFlowParameters(new LoopFlowParameters()); raoParameters.getObjectiveFunctionParameters().setType(ObjectiveFunctionParameters.ObjectiveFunctionType.MAX_MIN_RELATIVE_MARGIN); - raoParameters.getObjectiveFunctionParameters().setUnit(Unit.AMPERE); mockSystematicSensitivityInterface(true, true); PrePerimeterResult result = prePerimeterSensitivityAnalysis.runInitialSensitivityAnalysis(network, crac); @@ -145,7 +134,7 @@ void testRunWithPtdfAndLf() { void testRunWithFixedPtdfAndLf() { OpenRaoSearchTreeParameters searchTreeParameters = new OpenRaoSearchTreeParameters(); raoParameters.addExtension(OpenRaoSearchTreeParameters.class, searchTreeParameters); - LoopFlowParameters loopFlowParameters = new LoopFlowParameters(); + com.powsybl.openrao.raoapi.parameters.extensions.LoopFlowParameters loopFlowParameters = new com.powsybl.openrao.raoapi.parameters.extensions.LoopFlowParameters(); searchTreeParameters.setLoopFlowParameters(loopFlowParameters); loopFlowParameters.setPtdfApproximation(PtdfApproximation.FIXED_PTDF); RelativeMarginsParameters relativeMarginsParameters = new RelativeMarginsParameters(); @@ -165,7 +154,7 @@ void testRunWithFixedPtdfAndLf() { void testRunAndRecomputePtdf() { OpenRaoSearchTreeParameters searchTreeParameters = new OpenRaoSearchTreeParameters(); raoParameters.addExtension(OpenRaoSearchTreeParameters.class, searchTreeParameters); - LoopFlowParameters loopFlowParameters = new LoopFlowParameters(); + com.powsybl.openrao.raoapi.parameters.extensions.LoopFlowParameters loopFlowParameters = new com.powsybl.openrao.raoapi.parameters.extensions.LoopFlowParameters(); searchTreeParameters.setLoopFlowParameters(loopFlowParameters); loopFlowParameters.setPtdfApproximation(PtdfApproximation.UPDATE_PTDF_WITH_TOPO); RelativeMarginsParameters relativeMarginsParameters = new RelativeMarginsParameters(); diff --git a/tests/src/test/java/com/powsybl/openrao/tests/utils/CneHelper.java b/tests/src/test/java/com/powsybl/openrao/tests/utils/CneHelper.java index 3bc7ac28b8..714fc16445 100644 --- a/tests/src/test/java/com/powsybl/openrao/tests/utils/CneHelper.java +++ b/tests/src/test/java/com/powsybl/openrao/tests/utils/CneHelper.java @@ -77,7 +77,7 @@ private static void fillPropertiesWithRaoParameters(Properties properties, RaoPa case MAX_MIN_RELATIVE_MARGIN -> properties.setProperty("rao-result.export.core-cne.relative-positive-margins", "true"); case MAX_MIN_MARGIN -> properties.setProperty("rao-result.export.core-cne.relative-positive-margins", "false"); } - if (raoParameters.hasLoopFlowParameters()) { + if (raoParameters.getLoopFlowParameters().isPresent()) { properties.setProperty("rao-result.export.core-cne.with-loop-flows", "true"); } if (raoParameters.getMnecParameters().isPresent()) { diff --git a/tests/src/test/java/com/powsybl/openrao/tests/utils/RaoUtils.java b/tests/src/test/java/com/powsybl/openrao/tests/utils/RaoUtils.java index 8642bd2190..b74ba65eba 100644 --- a/tests/src/test/java/com/powsybl/openrao/tests/utils/RaoUtils.java +++ b/tests/src/test/java/com/powsybl/openrao/tests/utils/RaoUtils.java @@ -63,7 +63,7 @@ public static RaoResult runRao(String contingencyId, InstantKind instantKind, St RaoParameters raoParameters = CommonTestData.getRaoParameters(); ZonalData glsks = CommonTestData.getLoopflowGlsks(); // Rao with loop-flows - if (raoParameters.hasLoopFlowParameters() && glsks != null) { + if (raoParameters.getLoopFlowParameters().isPresent() && glsks != null) { double effectiveLfPercentage = loopflowAsPmaxPercentage == null ? 0.0 : loopflowAsPmaxPercentage; buildLoopFlowExtensions(CommonTestData.getCrac(), CommonTestData.getNetwork(), effectiveLfPercentage); }