Skip to content

Commit

Permalink
Remove addAlgorithmParam (#44)
Browse files Browse the repository at this point in the history
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
  • Loading branch information
annetill authored Nov 17, 2023
1 parent 24606c7 commit f388d67
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,6 @@ public OpenReacParameters addVariableTwoWindingsTransformers(List<String> transf
return this;
}

/**
* Add a parameter to the optimization engine
*/
public OpenReacParameters addAlgorithmParam(List<OpenReacAlgoParam> 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<OpenReacAlgoParam> getAlgorithmParams() {
return algorithmParams;
}

/**
* The definition of the objective function for the optimization.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,10 +55,6 @@ public OpenReacParameters deserialize(JsonParser parser, DeserializationContext
parser.nextToken();
parameters.addVariableTwoWindingsTransformers(parser.readValueAs(new TypeReference<List<String>>() { }));
break;
case "algorithmParams":
parser.nextToken();
parameters.addAlgorithmParam(parser.readValueAs(new TypeReference<List<OpenReacAlgoParam>>() { }));
break;
case "objective":
parser.nextToken();
parameters.setObjective(OpenReacOptimisationObjective.valueOf(parser.getText()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
}
}
7 changes: 0 additions & 7 deletions open-reac/src/test/resources/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit f388d67

Please sign in to comment.