From f388d6768ac240bb678b452fe96ccd55028c78bf Mon Sep 17 00:00:00 2001 From: Anne Tilloy <48123713+annetill@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:21:39 +0100 Subject: [PATCH] Remove addAlgorithmParam (#44) Signed-off-by: Anne Tilloy --- .../parameters/input/OpenReacParameters.java | 20 ------------------- .../json/OpenReacParametersDeserializer.java | 5 ----- .../json/OpenReacParametersSerializer.java | 1 - .../input/json/OpenReacJsonModuleTest.java | 7 ------- open-reac/src/test/resources/parameters.json | 7 ------- 5 files changed, 40 deletions(-) diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java index f46a6480..474ebcaa 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java @@ -79,26 +79,6 @@ public OpenReacParameters addVariableTwoWindingsTransformers(List transf return this; } - /** - * Add a parameter to the optimization engine - */ - public OpenReacParameters addAlgorithmParam(List algorithmParams) { - this.algorithmParams.addAll(algorithmParams); - return this; - } - - /** - * Add a parameter to the optimization engine - */ - public OpenReacParameters addAlgorithmParam(String name, String value) { - algorithmParams.add(new OpenReacAlgoParamImpl(name, value)); - return this; - } - - public List getAlgorithmParams() { - return algorithmParams; - } - /** * The definition of the objective function for the optimization. */ diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersDeserializer.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersDeserializer.java index 905d457b..330dea7a 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersDeserializer.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersDeserializer.java @@ -13,7 +13,6 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.powsybl.openreac.parameters.input.OpenReacParameters; import com.powsybl.openreac.parameters.input.VoltageLimitOverride; -import com.powsybl.openreac.parameters.input.algo.OpenReacAlgoParam; import com.powsybl.openreac.parameters.input.algo.OpenReacOptimisationObjective; import java.io.IOException; @@ -56,10 +55,6 @@ public OpenReacParameters deserialize(JsonParser parser, DeserializationContext parser.nextToken(); parameters.addVariableTwoWindingsTransformers(parser.readValueAs(new TypeReference>() { })); break; - case "algorithmParams": - parser.nextToken(); - parameters.addAlgorithmParam(parser.readValueAs(new TypeReference>() { })); - break; case "objective": parser.nextToken(); parameters.setObjective(OpenReacOptimisationObjective.valueOf(parser.getText())); diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersSerializer.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersSerializer.java index b15a5e98..b4dfcbd0 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersSerializer.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersSerializer.java @@ -34,7 +34,6 @@ public void serialize(OpenReacParameters openReacParameters, JsonGenerator jsonG serializerProvider.defaultSerializeField("constantQGenerators", openReacParameters.getConstantQGenerators(), jsonGenerator); serializerProvider.defaultSerializeField("variableTwoWindingsTransformers", openReacParameters.getVariableTwoWindingsTransformers(), jsonGenerator); serializerProvider.defaultSerializeField("variableShuntCompensators", openReacParameters.getVariableShuntCompensators(), jsonGenerator); - serializerProvider.defaultSerializeField("algorithmParams", openReacParameters.getAlgorithmParams(), jsonGenerator); serializerProvider.defaultSerializeField("objective", openReacParameters.getObjective().name(), jsonGenerator); if (openReacParameters.getObjectiveDistance() != null) { serializerProvider.defaultSerializeField("objectiveDistance", openReacParameters.getObjectiveDistance(), jsonGenerator); diff --git a/open-reac/src/test/java/com/powsybl/openreac/parameters/input/json/OpenReacJsonModuleTest.java b/open-reac/src/test/java/com/powsybl/openreac/parameters/input/json/OpenReacJsonModuleTest.java index 26c0c8ca..bf607fef 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/parameters/input/json/OpenReacJsonModuleTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/parameters/input/json/OpenReacJsonModuleTest.java @@ -42,8 +42,6 @@ void test() throws IOException { parameters.addConstantQGenerators(List.of("g1", "g2")); parameters.addVariableTwoWindingsTransformers(List.of("tr1")); parameters.addVariableShuntCompensators(List.of("sc1", "sc2")); - parameters.addAlgorithmParam("p1", "v1"); - parameters.addAlgorithmParam("p2", "v2"); parameters.setObjectiveDistance(5); String json = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(parameters); ComparisonUtils.compareTxt(Objects.requireNonNull(getClass().getResourceAsStream("/parameters.json")), json); @@ -59,11 +57,6 @@ void test() throws IOException { assertEquals(vloList2, parameters2.getSpecificVoltageLimits()); assertEquals(List.of("g1", "g2"), parameters2.getConstantQGenerators()); assertEquals(List.of("tr1"), parameters2.getVariableTwoWindingsTransformers()); - assertEquals(2, parameters2.getAlgorithmParams().size()); - assertEquals("p1", parameters2.getAlgorithmParams().get(0).getName()); - assertEquals("v1", parameters2.getAlgorithmParams().get(0).getValue()); - assertEquals("p2", parameters2.getAlgorithmParams().get(1).getName()); - assertEquals("v2", parameters2.getAlgorithmParams().get(1).getValue()); assertEquals(5, parameters2.getObjectiveDistance()); } } diff --git a/open-reac/src/test/resources/parameters.json b/open-reac/src/test/resources/parameters.json index 5aee589c..f3c92e0d 100644 --- a/open-reac/src/test/resources/parameters.json +++ b/open-reac/src/test/resources/parameters.json @@ -24,13 +24,6 @@ "constantQGenerators" : [ "g1", "g2" ], "variableTwoWindingsTransformers" : [ "tr1" ], "variableShuntCompensators" : [ "sc1", "sc2" ], - "algorithmParams" : [ { - "name" : "p1", - "value" : "v1" - }, { - "name" : "p2", - "value" : "v2" - } ], "objective" : "MIN_GENERATION", "objectiveDistance" : 5.0 } \ No newline at end of file