diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/OpenReacAmplIOFiles.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/OpenReacAmplIOFiles.java index ed36a6ad..ee3aace5 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/OpenReacAmplIOFiles.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/OpenReacAmplIOFiles.java @@ -38,7 +38,7 @@ public class OpenReacAmplIOFiles implements AmplParameters { private final AlgorithmInput algorithmParams; private final ReactiveSlackOutput reactiveSlackOutput; private final VoltageLevelLimitsOverrideInput voltageLimitsOverride; - private final ConfiguredBusesWithReactiveSlack configuredBusesWithReactiveSlack; + private final ConfiguredBusesWithReactiveSlack configuredReactiveSlackBuses; private final NetworkModifications networkModifications; private final boolean debug; @@ -49,7 +49,7 @@ public OpenReacAmplIOFiles(OpenReacParameters params, Network network, boolean d this.variableTwoWindingsTransformers = new VariableTwoWindingsTransformers(params.getVariableTwoWindingsTransformers()); this.algorithmParams = new AlgorithmInput(params.getAllAlgorithmParams()); this.voltageLimitsOverride = new VoltageLevelLimitsOverrideInput(params.getSpecificVoltageLimits(), network); - this.configuredBusesWithReactiveSlack = new ConfiguredBusesWithReactiveSlack(params.getConfiguredBusesWithReactiveSlacks()); + this.configuredReactiveSlackBuses = new ConfiguredBusesWithReactiveSlack(params.getConfiguredReactiveSlackBuses()); //outputs this.reactiveSlackOutput = new ReactiveSlackOutput(); @@ -69,7 +69,7 @@ public NetworkModifications getNetworkModifications() { @Override public Collection getInputParameters() { return List.of(constantQGenerators, variableShuntCompensators, variableTwoWindingsTransformers, - algorithmParams, voltageLimitsOverride, configuredBusesWithReactiveSlack); + algorithmParams, voltageLimitsOverride, configuredReactiveSlackBuses); } @Override 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 c367d713..222d8401 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 @@ -34,7 +34,7 @@ public class OpenReacParameters { private final List variableTwoWindingsTransformers = new ArrayList<>(); - private final List busesWithReactiveSlack = new ArrayList<>(); + private final List configuredReactiveSlackBuses = new ArrayList<>(); // Algo parameters @@ -56,7 +56,7 @@ public class OpenReacParameters { private double maxPlausibleHighVoltageLimit = 1.5; // in pu - private OpenReacBusesWithReactiveSlackConfig busesWithReactiveSlackConfig = OpenReacBusesWithReactiveSlackConfig.NO_GENERATION; + private ReactiveSlackBusesMode reactiveSlackBusesMode = ReactiveSlackBusesMode.NO_GENERATION; /** * Override some voltage level limits in the network. This will NOT modify the network object. @@ -94,8 +94,8 @@ public OpenReacParameters addVariableTwoWindingsTransformers(List transf return this; } - public OpenReacParameters addBusesWithReactiveSlack(List busesIds) { - this.busesWithReactiveSlack.addAll(busesIds); + public OpenReacParameters addConfiguredReactiveSlackBuses(List busesIds) { + this.configuredReactiveSlackBuses.addAll(busesIds); return this; } @@ -200,12 +200,12 @@ public OpenReacParameters setMaxPlausibleHighVoltageLimit(double maxPlausibleHig return this; } - public OpenReacBusesWithReactiveSlackConfig getBusesWithReactiveSlackConfig() { - return busesWithReactiveSlackConfig; + public ReactiveSlackBusesMode getReactiveSlackBusesMode() { + return reactiveSlackBusesMode; } - public OpenReacParameters setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig busesWithReactiveSlackConfig) { - this.busesWithReactiveSlackConfig = Objects.requireNonNull(busesWithReactiveSlackConfig); + public OpenReacParameters setReactiveSlackBusesMode(ReactiveSlackBusesMode reactiveSlackBusesMode) { + this.reactiveSlackBusesMode = Objects.requireNonNull(reactiveSlackBusesMode); return this; } @@ -225,8 +225,8 @@ public List getVariableTwoWindingsTransformers() { return variableTwoWindingsTransformers; } - public List getConfiguredBusesWithReactiveSlacks() { - return busesWithReactiveSlack; + public List getConfiguredReactiveSlackBuses() { + return configuredReactiveSlackBuses; } public List getAllAlgorithmParams() { @@ -239,7 +239,7 @@ public List getAllAlgorithmParams() { allAlgoParams.add(this.logLevelSolver.toParam()); allAlgoParams.add(new OpenReacAlgoParamImpl(MIN_PLAUSIBLE_LOW_VOLTAGE_LIMIT_KEY, Double.toString(minPlausibleLowVoltageLimit))); allAlgoParams.add(new OpenReacAlgoParamImpl(MAX_PLAUSIBLE_HIGH_VOLTAGE_LIMIT_KEY, Double.toString(maxPlausibleHighVoltageLimit))); - allAlgoParams.add(busesWithReactiveSlackConfig.toParam()); + allAlgoParams.add(reactiveSlackBusesMode.toParam()); return allAlgoParams; } @@ -265,7 +265,7 @@ public void checkIntegrity(Network network) throws InvalidParametersException { throw new InvalidParametersException("Two windings transformer " + transformerId + " not found in the network."); } } - for (String busId : getConfiguredBusesWithReactiveSlacks()) { + for (String busId : getConfiguredReactiveSlackBuses()) { if (network.getBusView().getBus(busId) == null) { throw new InvalidParametersException("Bus " + busId + " not found in the network."); } diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/OpenReacBusesWithReactiveSlackConfig.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/ReactiveSlackBusesMode.java similarity index 68% rename from open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/OpenReacBusesWithReactiveSlackConfig.java rename to open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/ReactiveSlackBusesMode.java index c9863c14..20ada48e 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/OpenReacBusesWithReactiveSlackConfig.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/ReactiveSlackBusesMode.java @@ -9,25 +9,24 @@ /** * @author Pierre Arvy */ -public enum OpenReacBusesWithReactiveSlackConfig { - SPECIFIED("SPECIFIED"), +public enum ReactiveSlackBusesMode { + CONFIGURED("CONFIGURED"), NO_GENERATION("NO_GENERATION"), - ALL("ALL"); - private static final String BUSES_REACTIVE_SLACKS_KEY = "buses_with_reactive_slacks"; + private static final String REACTIVE_SLACK_BUSES_KEY = "buses_with_reactive_slacks"; private final String amplKey; /** * @param amplKey value used in param_algo.txt to define the slacks repartition. */ - OpenReacBusesWithReactiveSlackConfig(String amplKey) { + ReactiveSlackBusesMode(String amplKey) { this.amplKey = amplKey; } public OpenReacAlgoParam toParam() { - return new OpenReacAlgoParamImpl(BUSES_REACTIVE_SLACKS_KEY, amplKey); + return new OpenReacAlgoParamImpl(REACTIVE_SLACK_BUSES_KEY, amplKey); } } 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 c7868e27..433a934b 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 @@ -14,7 +14,7 @@ import com.powsybl.openreac.parameters.input.OpenReacParameters; import com.powsybl.openreac.parameters.input.VoltageLimitOverride; import com.powsybl.openreac.parameters.input.algo.OpenReacAmplLogLevel; -import com.powsybl.openreac.parameters.input.algo.OpenReacBusesWithReactiveSlackConfig; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import com.powsybl.openreac.parameters.input.algo.OpenReacOptimisationObjective; import com.powsybl.openreac.parameters.input.algo.OpenReacSolverLogLevel; @@ -58,9 +58,9 @@ public OpenReacParameters deserialize(JsonParser parser, DeserializationContext parser.nextToken(); parameters.addVariableTwoWindingsTransformers(parser.readValueAs(new TypeReference>() { })); break; - case "busesWithReactiveSlack": + case "configuredReactiveSlackBuses": parser.nextToken(); - parameters.addBusesWithReactiveSlack(parser.readValueAs(new TypeReference>() { })); + parameters.addConfiguredReactiveSlackBuses(parser.readValueAs(new TypeReference>() { })); break; case "objective": parser.nextToken(); @@ -86,9 +86,9 @@ public OpenReacParameters deserialize(JsonParser parser, DeserializationContext parser.nextToken(); parameters.setMaxPlausibleHighVoltageLimit(parser.readValueAs(Double.class)); break; - case "busesWithReactiveSlackConfig": + case "reactiveSlackBusesMode": parser.nextToken(); - parameters.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.valueOf(parser.getText())); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.valueOf(parser.getText())); break; default: throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); 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 9461a463..5aa24e56 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 @@ -10,7 +10,7 @@ import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import com.powsybl.openreac.parameters.input.OpenReacParameters; -import com.powsybl.openreac.parameters.input.algo.OpenReacBusesWithReactiveSlackConfig; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import java.io.IOException; @@ -35,8 +35,8 @@ 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); - if (openReacParameters.getBusesWithReactiveSlackConfig() == OpenReacBusesWithReactiveSlackConfig.SPECIFIED) { - serializerProvider.defaultSerializeField("busesWithReactiveSlack", openReacParameters.getConfiguredBusesWithReactiveSlacks(), jsonGenerator); + if (openReacParameters.getReactiveSlackBusesMode() == ReactiveSlackBusesMode.CONFIGURED) { + serializerProvider.defaultSerializeField("configuredReactiveSlackBuses", openReacParameters.getConfiguredReactiveSlackBuses(), jsonGenerator); } serializerProvider.defaultSerializeField("objective", openReacParameters.getObjective().name(), jsonGenerator); if (openReacParameters.getObjectiveDistance() != null) { @@ -46,7 +46,7 @@ public void serialize(OpenReacParameters openReacParameters, JsonGenerator jsonG serializerProvider.defaultSerializeField("logLevelSolver", openReacParameters.getLogLevelSolver(), jsonGenerator); serializerProvider.defaultSerializeField("minPlausibleLowVoltageLimit", openReacParameters.getMinPlausibleLowVoltageLimit(), jsonGenerator); serializerProvider.defaultSerializeField("maxPlausibleHighVoltageLimit", openReacParameters.getMaxPlausibleHighVoltageLimit(), jsonGenerator); - serializerProvider.defaultSerializeField("busesWithReactiveSlackConfig", openReacParameters.getBusesWithReactiveSlackConfig().name(), jsonGenerator); + serializerProvider.defaultSerializeField("reactiveSlackBusesMode", openReacParameters.getReactiveSlackBusesMode().name(), jsonGenerator); jsonGenerator.writeEndObject(); } } diff --git a/open-reac/src/main/resources/openreac/reactiveopf.run b/open-reac/src/main/resources/openreac/reactiveopf.run index 923aee00..a7109f6d 100644 --- a/open-reac/src/main/resources/openreac/reactiveopf.run +++ b/open-reac/src/main/resources/openreac/reactiveopf.run @@ -228,11 +228,11 @@ display PARAM_ALGO_VALUES; # Log level of ampl printing set LOG_LEVELS ordered = {"ERROR", "WARNING", "INFO", "DEBUG"}; # different values of log level for ampl exec -param log_level_ampl symbolic default "INFO"; # default value of log level +param log_level_ampl symbolic default "INFO"; # default value of log level if "log_level_ampl" in PARAM_ALGO_KEYS then let log_level_ampl := PARAM_ALGO_VALUES["log_level_ampl"]; # Sets used to print or not. A void set avoid printing -param log_index := ord0(log_level_ampl, LOG_LEVELS); +param log_index := ord0(log_level_ampl, LOG_LEVELS); set LOG_DEBUG := if log_index >= 4 then{1} else {}; set LOG_INFO := if log_index >= 3 then{1} else {}; set LOG_WARNING := if log_index >= 2 then{1} else {}; @@ -320,8 +320,8 @@ if "buses_with_reactive_slacks" in PARAM_ALGO_KEYS then let buses_with_reactive_ printf{LOG_INFO} "Parameter: choice for buses with reactive slacks in ACOPF := %Q (%s)\n", buses_with_reactive_slacks, if buses_with_reactive_slacks == "ALL" then "every bus in connex component." else if buses_with_reactive_slacks == "NO_GENERATION" then "buses without generation (no generator, svc or vsc)" - else if buses_with_reactive_slacks == "SPECIFIED" then "buses given as parameters in param_buses_with_reactive_slack.txt"; -check buses_with_reactive_slacks in {"SPECIFIED", "NO_GENERATION", "ALL"}; + else if buses_with_reactive_slacks == "CONFIGURED" then "buses given as parameters in param_buses_with_reactive_slack.txt"; +check buses_with_reactive_slacks in {"CONFIGURED", "NO_GENERATION", "ALL"}; # Consistency maximal value for P and Q # Any Pmax Pmin Qmax Qmin of generating unit with abolute value larger than PQmax is discarded @@ -1083,7 +1083,7 @@ for {(qq,m,n) in BRANCHCC: (teta[m]-teta[n])>temp1*0.99 or (teta[m]-teta[n]) Pnull then { - + if 1 in LOG_INFO then display sum{n in BUSCC_SLACK} slack1_balance_Q[n], @@ -1111,7 +1111,7 @@ include reactiveopfoutput.run; # Write voltage information in debug file let fileOut := "debug_bus.csv"; printf{LOG_DEBUG} "#bus_id;Vnom;V;Vlb;Vub;Vmin_mod;Vmax_mod;Vmin_OK;Vmax_OK;Vmin_ori;Vmax_ori;sQ1;sQ2;\n" > (fileOut); -for {n in BUSCC} +for {n in BUSCC} printf{LOG_DEBUG} "%Q;%i;%.4f;%.4f;%.4f;%.4f;%.4f;%s;%s;%.4f;%.4f;%.2f;%.2f;\n", bus_id[1,n],substation_Vnomi[1,bus_substation[1,n]], V[n],V[n].lb,V[n].ub, @@ -1128,7 +1128,7 @@ close (fileOut); # Write units which are not in uniton (debug only) let fileOut := "reactiveopf_results_generators_Pnull.csv"; printf{LOG_DEBUG} "#variant;num;bus;vRegul;V(pu);targetP(MW);targetQ(Mvar);P(MW);Q(MW);id;bus_id;\n" > (fileOut); -for {(g,n) in UNITCC diff UNITON} +for {(g,n) in UNITCC diff UNITON} printf{LOG_DEBUG} "%i;%i;%i;%Q;%.3f;%.3f;%.3f;%.3f;%.3f;%Q;%Q;\n", 1,g,n, unit_vregul[1,g,n], diff --git a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java index 30863c40..f0d8c99d 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java @@ -14,7 +14,7 @@ import com.powsybl.openreac.parameters.input.algo.OpenReacAmplLogLevel; import com.powsybl.openreac.parameters.input.algo.OpenReacOptimisationObjective; import com.powsybl.openreac.parameters.input.algo.OpenReacSolverLogLevel; -import com.powsybl.openreac.parameters.input.algo.OpenReacBusesWithReactiveSlackConfig; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import org.junit.jupiter.api.Test; import java.util.List; @@ -124,7 +124,7 @@ void testAlgorithmParams() { parameters.setLogLevelSolver(OpenReacSolverLogLevel.NOTHING); parameters.setMinPlausibleLowVoltageLimit(0.8); parameters.setMaxPlausibleHighVoltageLimit(1.2); - parameters.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.ALL); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.ALL); List algoParams = parameters.getAllAlgorithmParams(); assertEquals(7, algoParams.size()); @@ -141,14 +141,14 @@ void testAlgorithmParams() { void testBusesWithReactiveSlackConfigIntegrity() { OpenReacParameters parameters = new OpenReacParameters(); - assertEquals(OpenReacBusesWithReactiveSlackConfig.NO_GENERATION, parameters.getBusesWithReactiveSlackConfig()); // default value - assertThrows(NullPointerException.class, () -> parameters.setBusesWithReactiveSlackConfig(null)); - parameters.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.SPECIFIED); - assertEquals("SPECIFIED", parameters.getBusesWithReactiveSlackConfig().toParam().getValue()); - parameters.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.NO_GENERATION); - assertEquals("NO_GENERATION", parameters.getBusesWithReactiveSlackConfig().toParam().getValue()); - parameters.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.ALL); - assertEquals("ALL", parameters.getBusesWithReactiveSlackConfig().toParam().getValue()); + assertEquals(ReactiveSlackBusesMode.NO_GENERATION, parameters.getReactiveSlackBusesMode()); // default value + assertThrows(NullPointerException.class, () -> parameters.setReactiveSlackBusesMode(null)); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.CONFIGURED); + assertEquals("CONFIGURED", parameters.getReactiveSlackBusesMode().toParam().getValue()); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.NO_GENERATION); + assertEquals("NO_GENERATION", parameters.getReactiveSlackBusesMode().toParam().getValue()); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.ALL); + assertEquals("ALL", parameters.getReactiveSlackBusesMode().toParam().getValue()); } @Test @@ -159,7 +159,7 @@ void testDefaultListsOfParametersIntegrity() { assertEquals(0, parameters.getSpecificVoltageLimits().size(), "SpecificVoltageLimits should be empty when using default OpenReacParameter constructor."); assertEquals(0, parameters.getConstantQGenerators().size(), "ConstantQGenerators should be empty when using default OpenReacParameter constructor."); assertEquals(0, parameters.getVariableShuntCompensators().size(), "VariableShuntCompensators should be empty when using default OpenReacParameter constructor."); - assertEquals(0, parameters.getConfiguredBusesWithReactiveSlacks().size(), "ConfiguredBusesWithReactiveSlack should be empty when using default OpenREacParameter constructor."); + assertEquals(0, parameters.getConfiguredReactiveSlackBuses().size(), "ConfiguredReactiveSlackBuses should be empty when using default OpenREacParameter constructor."); assertEquals(6, parameters.getAllAlgorithmParams().size()); } @@ -207,9 +207,9 @@ void testConstantQGeneratorsParametersIntegrity(Network network, String wrongId) void testBusesWithReactiveSlacksParametersIntegrity(Network network, String wrongId) { OpenReacParameters parameters = new OpenReacParameters(); - parameters.addBusesWithReactiveSlack(network.getBusView().getBusStream().map(Bus::getId).collect(Collectors.toList())); + parameters.addConfiguredReactiveSlackBuses(network.getBusView().getBusStream().map(Bus::getId).collect(Collectors.toList())); assertDoesNotThrow(() -> parameters.checkIntegrity(network), "Adding Buses network IDs should not throw."); - parameters.addBusesWithReactiveSlack(List.of(wrongId)); + parameters.addConfiguredReactiveSlackBuses(List.of(wrongId)); assertNull(network.getBusView().getBus(wrongId), "Please change wrong ID so it does not match any any element in the network."); InvalidParametersException e = assertThrows(InvalidParametersException.class, () -> parameters.checkIntegrity(network)); assertEquals("Bus " + wrongId + " not found in the network.", e.getMessage()); diff --git a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java index 11f7d16c..b16d5993 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java @@ -21,7 +21,7 @@ import com.powsybl.openreac.network.VoltageControlNetworkFactory; import com.powsybl.openreac.parameters.input.OpenReacParameters; import com.powsybl.openreac.parameters.input.algo.OpenReacAmplLogLevel; -import com.powsybl.openreac.parameters.input.algo.OpenReacBusesWithReactiveSlackConfig; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import com.powsybl.openreac.parameters.input.algo.OpenReacOptimisationObjective; import com.powsybl.openreac.parameters.input.algo.OpenReacSolverLogLevel; import com.powsybl.openreac.parameters.output.OpenReacResult; @@ -104,7 +104,7 @@ void testParamAlgoExport() throws IOException { .setLogLevelSolver(OpenReacSolverLogLevel.ONLY_RESULTS) .setMinPlausibleLowVoltageLimit(0.7888) .setMaxPlausibleHighVoltageLimit(1.3455) - .setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.ALL); + .setReactiveSlackBusesMode(ReactiveSlackBusesMode.ALL); LocalCommandExecutor localCommandExecutor = new TestLocalCommandExecutor( List.of("empty_case/reactiveopf_results_indic.txt")); @@ -125,7 +125,7 @@ void testInputFile() throws IOException { OpenReacParameters parameters = new OpenReacParameters().setObjective( OpenReacOptimisationObjective.BETWEEN_HIGH_AND_LOW_VOLTAGE_LIMIT) .setObjectiveDistance(70) - .setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.SPECIFIED) + .setReactiveSlackBusesMode(ReactiveSlackBusesMode.CONFIGURED) .addVariableTwoWindingsTransformers(network.getTwoWindingsTransformerStream() .limit(1) .map(TwoWindingsTransformer::getId) @@ -134,7 +134,7 @@ void testInputFile() throws IOException { network.getGeneratorStream().limit(1).map(Generator::getId).collect(Collectors.toList())) .addVariableShuntCompensators( network.getShuntCompensatorStream().limit(1).map(ShuntCompensator::getId).collect(Collectors.toList())) - .addBusesWithReactiveSlack( + .addConfiguredReactiveSlackBuses( network.getBusView().getBusStream().limit(1).map(Bus::getId).collect(Collectors.toList())); LocalCommandExecutor localCommandExecutor = new TestLocalCommandExecutor( 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 190f8c63..3823348c 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 @@ -13,7 +13,7 @@ import com.powsybl.openreac.parameters.input.VoltageLimitOverride; import com.powsybl.openreac.parameters.input.algo.OpenReacAmplLogLevel; import com.powsybl.openreac.parameters.input.algo.OpenReacSolverLogLevel; -import com.powsybl.openreac.parameters.input.algo.OpenReacBusesWithReactiveSlackConfig; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -50,8 +50,8 @@ void test() throws IOException { parameters.setLogLevelSolver(OpenReacSolverLogLevel.NOTHING); parameters.setMinPlausibleLowVoltageLimit(0.755); parameters.setMaxPlausibleHighVoltageLimit(1.236); - parameters.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.SPECIFIED); - parameters.addBusesWithReactiveSlack(List.of("bus1", "bus2")); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.CONFIGURED); + parameters.addConfiguredReactiveSlackBuses(List.of("bus1", "bus2")); String json = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(parameters); ComparisonUtils.compareTxt(Objects.requireNonNull(getClass().getResourceAsStream("/parameters.json")), json); @@ -71,7 +71,7 @@ void test() throws IOException { assertEquals(OpenReacSolverLogLevel.NOTHING, parameters2.getLogLevelSolver()); assertEquals(0.755, parameters2.getMinPlausibleLowVoltageLimit()); assertEquals(1.236, parameters2.getMaxPlausibleHighVoltageLimit()); - assertEquals(OpenReacBusesWithReactiveSlackConfig.SPECIFIED, parameters2.getBusesWithReactiveSlackConfig()); - assertEquals(List.of("bus1", "bus2"), parameters2.getConfiguredBusesWithReactiveSlacks()); + assertEquals(ReactiveSlackBusesMode.CONFIGURED, parameters2.getReactiveSlackBusesMode()); + assertEquals(List.of("bus1", "bus2"), parameters2.getConfiguredReactiveSlackBuses()); } } diff --git a/open-reac/src/test/resources/expected_inputs/param_algo.txt b/open-reac/src/test/resources/expected_inputs/param_algo.txt index abc66ef0..6a5ddad4 100644 --- a/open-reac/src/test/resources/expected_inputs/param_algo.txt +++ b/open-reac/src/test/resources/expected_inputs/param_algo.txt @@ -4,5 +4,5 @@ log_level_ampl INFO log_level_knitro 2 min_plausible_low_voltage_limit 0.5 max_plausible_high_voltage_limit 1.5 -buses_with_reactive_slacks SPECIFIED +buses_with_reactive_slacks CONFIGURED diff --git a/open-reac/src/test/resources/parameters.json b/open-reac/src/test/resources/parameters.json index cda3ecae..7e58d075 100644 --- a/open-reac/src/test/resources/parameters.json +++ b/open-reac/src/test/resources/parameters.json @@ -24,12 +24,12 @@ "constantQGenerators" : [ "g1", "g2" ], "variableTwoWindingsTransformers" : [ "tr1" ], "variableShuntCompensators" : [ "sc1", "sc2" ], - "busesWithReactiveSlack" : [ "bus1", "bus2" ], + "configuredReactiveSlackBuses" : [ "bus1", "bus2" ], "objective" : "MIN_GENERATION", "objectiveDistance" : 5.0, "logLevelAmpl" : "WARNING", "logLevelSolver" : "NOTHING", "minPlausibleLowVoltageLimit" : 0.755, "maxPlausibleHighVoltageLimit" : 1.236, - "busesWithReactiveSlackConfig" : "SPECIFIED" + "reactiveSlackBusesMode" : "CONFIGURED" } \ No newline at end of file