Skip to content

Commit

Permalink
Keep TU up to date.
Browse files Browse the repository at this point in the history
Signed-off-by: parvy <[email protected]>
  • Loading branch information
p-arvy committed Nov 24, 2023
1 parent 989cc86 commit 8ed0001
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* This class stores all inputs parameters specific to the OpenReac optimizer.
*
* @author Nicolas Pierre <nicolas.pierre at artelys.com>
* @author Pierre Arvy <pierre.arvy at artelys.com>
*/
public class OpenReacParameters {

Expand All @@ -35,7 +36,6 @@ public class OpenReacParameters {

private List<String> busesWithReactiveSlack = new ArrayList<>();

private final List<OpenReacAlgoParam> algorithmParams = new ArrayList<>();
// Algo parameters

private OpenReacOptimisationObjective objective = OpenReacOptimisationObjective.MIN_GENERATION;
Expand Down Expand Up @@ -239,9 +239,7 @@ public List<OpenReacAlgoParam> 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)));
if (busesWithReactiveSlackConfig != null) {
allAlgoParams.add(busesWithReactiveSlackConfig.toParam());
}
allAlgoParams.add(busesWithReactiveSlackConfig.toParam());
return allAlgoParams;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,25 @@ void testAlgorithmParams() {
parameters.setLogLevelSolver(OpenReacSolverLogLevel.NOTHING);
parameters.setMinPlausibleLowVoltageLimit(0.8);
parameters.setMaxPlausibleHighVoltageLimit(1.2);
List<OpenReacAlgoParam> algoParams = parameters.getAllAlgorithmParams();
parameters.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.ALL);

assertEquals(6, algoParams.size());
List<OpenReacAlgoParam> algoParams = parameters.getAllAlgorithmParams();
assertEquals(7, algoParams.size());
assertEquals("2", algoParams.get(0).getValue());
assertEquals("0.4", algoParams.get(1).getValue());
assertEquals("DEBUG", algoParams.get(2).getValue());
assertEquals("0", algoParams.get(3).getValue());
assertEquals("0.8", algoParams.get(4).getValue());
assertEquals("1.2", algoParams.get(5).getValue());
assertEquals("ALL", algoParams.get(6).getValue());
}

@Test
void testReactiveSlacksRepartitionIntegrity() {
void testBusesWithReactiveSlackConfigIntegrity() {
OpenReacParameters parameters = new OpenReacParameters();

assertEquals(OpenReacBusesWithReactiveSlackConfig.NO_GENERATION, parameters.getBusesWithReactiveSlackConfig()); // default value
assertThrows(NullPointerException.class, () -> parameters.setBusesWithReactiveSlackConfig(null), "Can't set null ampl log level.");
assertThrows(NullPointerException.class, () -> parameters.setBusesWithReactiveSlackConfig(null));
parameters.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.SPECIFIED);
assertEquals("SPECIFIED", parameters.getBusesWithReactiveSlackConfig().toParam().getValue());
parameters.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.NO_GENERATION);
Expand All @@ -162,7 +164,7 @@ void testParametersIntegrity() {
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(5, parameters.getAllAlgorithmParams().size());
assertEquals(6, parameters.getAllAlgorithmParams().size());

// testing TwoWindingsTransformer
parameters.addVariableTwoWindingsTransformers(network.getTwoWindingsTransformerStream().map(TwoWindingsTransformer::getId).collect(Collectors.toList()));
Expand Down Expand Up @@ -192,7 +194,6 @@ void testParametersIntegrity() {
assertNull(network.getGenerator(wrongId), "Please change wrong ID so it does not match any element in the network.");
InvalidParametersException e3 = assertThrows(InvalidParametersException.class, () -> lambdaParamsGenerators.checkIntegrity(network));
assertEquals("Generator " + wrongId + " not found in the network.", e3.getMessage());
assertThrows(InvalidParametersException.class, () -> lambdaParamsGenerators.checkIntegrity(network), "An Generator ID not present in the network should throw to the user.");

// testing Buses
parameters = new OpenReacParameters();
Expand All @@ -201,7 +202,8 @@ void testParametersIntegrity() {
assertDoesNotThrow(() -> lambdaParamsBuses.checkIntegrity(network), "Adding Buses network IDs should not throw.");
parameters.addBusesWithReactiveSlack(List.of(wrongId));
assertNull(network.getBusView().getBus(wrongId), "Please change wrong ID so it does not match any any element in the network.");
assertThrows(InvalidParametersException.class, () -> lambdaParamsBuses.checkIntegrity(network), "A Bus ID not present in the network should throw to the user.");
InvalidParametersException e4 = assertThrows(InvalidParametersException.class, () -> lambdaParamsBuses.checkIntegrity(network));
assertEquals("Bus " + wrongId + " not found in the network.", e4.getMessage());
}

void setDefaultVoltageLimits(Network network) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ void testParamAlgoExport() throws IOException {
.setLogLevelAmpl(OpenReacAmplLogLevel.WARNING)
.setLogLevelSolver(OpenReacSolverLogLevel.ONLY_RESULTS)
.setMinPlausibleLowVoltageLimit(0.7888)
.setMaxPlausibleHighVoltageLimit(1.3455);
.setMaxPlausibleHighVoltageLimit(1.3455)
.setBusesWithReactiveSlackConfig(OpenReacBusesWithReactiveSlackConfig.ALL);

LocalCommandExecutor localCommandExecutor = new TestLocalCommandExecutor(
List.of("empty_case/reactiveopf_results_indic.txt"));
Expand Down Expand Up @@ -211,7 +212,7 @@ public void testOutputFileParsing() throws IOException {
assertEquals(1, openReacResult.getSvcModifications().size());
assertEquals(1, openReacResult.getVscModifications().size());
assertEquals(7, openReacResult.getGeneratorModifications().size());
assertEquals(81, openReacResult.getIndicators().size());
assertEquals(82, openReacResult.getIndicators().size());
assertTrue(openReacResult.getReactiveSlacks().isEmpty());
}
}
Expand All @@ -225,7 +226,7 @@ private void testAllModifAndLoadFlow(Network network, String subFolder, OpenReac
subFolder + "/reactiveopf_results_static_var_compensators.csv",
subFolder + "/reactiveopf_results_vsc_converter_stations.csv"));
// To really run open reac, use the commentede line below. Be sure that open-reac/src/test/resources/com/powsybl/config/test/config.yml contains your ampl path
// try (ComputationManager computationManager = new LocalComputationManager()) {
// try (ComputationManager computationManager = new LocalComputationManager()) {
try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir),
localCommandExecutor, ForkJoinPool.commonPool())) {
OpenReacResult openReacResult = OpenReacRunner.run(network,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
final_status OK
dcopf_status OK

ctime_start 'Thu Nov 23 14:59:05 2023'
ctime_start 'Fri Nov 24 12:03:37 2023'
last_solve_result_num 0
nb_iter_last 7
nb_iter_total 7
_ampl_elapsed_time 0.047000
nb_iter_last 6
nb_iter_total 6
_ampl_elapsed_time 0.077000
_total_solve_time 0.046875
total_time 0

operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_7395805484686702830'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_14004834396321580705'

log_level_ampl INFO
log_level_knitro 2
Expand All @@ -25,6 +25,7 @@ epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks NO_GENERATION
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,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 NO_GENERATION

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ log_level_ampl WARNING
log_level_knitro 1
min_plausible_low_voltage_limit 0.7888
max_plausible_high_voltage_limit 1.3455
buses_with_reactive_slacks ALL

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
final_status OK
dcopf_status OK

ctime_start 'Thu Nov 23 14:53:50 2023'
ctime_start 'Fri Nov 24 11:59:34 2023'
last_solve_result_num 0
nb_iter_last 7
nb_iter_total 7
_ampl_elapsed_time 0.095000
nb_iter_last 6
nb_iter_total 6
_ampl_elapsed_time 0.125000
_total_solve_time 0.031250
total_time 0

operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_5579556502931529884'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_12583331805904096086'

log_level_ampl INFO
log_level_knitro 2
Expand All @@ -25,6 +25,7 @@ epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks NO_GENERATION
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
Expand Down Expand Up @@ -76,9 +77,9 @@ min_teta_dc -0.12
min_teta_ac -0.11
teta_min -3.12
max_delta_teta_dc 0.159330
max_delta_teta_ac 0.140548
max_delta_teta_ac 0.140571
min_delta_teta_dc -0.041368
min_delta_teta_ac -0.041532
min_delta_teta_ac -0.041534

nb_reactive_slacks 0
nb_slacks_condensator 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
final_status OK
dcopf_status OK

ctime_start 'Thu Nov 23 14:58:11 2023'
ctime_start 'Fri Nov 24 12:03:02 2023'
last_solve_result_num 0
nb_iter_last 7
nb_iter_total 7
_ampl_elapsed_time 0.077000
_total_solve_time 0.046875
_ampl_elapsed_time 0.110000
_total_solve_time 0.031250
total_time 0

operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_2760859736839254273'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_3114721600970297698'

log_level_ampl INFO
log_level_knitro 2
Expand All @@ -25,6 +25,7 @@ epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks NO_GENERATION
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
final_status OK
dcopf_status OK

ctime_start 'Thu Nov 23 14:56:52 2023'
ctime_start 'Fri Nov 24 12:01:56 2023'
last_solve_result_num 0
nb_iter_last 35
nb_iter_total 35
_ampl_elapsed_time 0.062000
_total_solve_time 0.062500
nb_iter_last 29
nb_iter_total 29
_ampl_elapsed_time 0.077000
_total_solve_time 0.031250
total_time 0

operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_12329044319369847398'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_12369045109419234150'

log_level_ampl INFO
log_level_knitro 2
Expand All @@ -25,6 +25,7 @@ epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks NO_GENERATION
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
final_status OK
dcopf_status OK

ctime_start 'Thu Nov 23 14:56:01 2023'
ctime_start 'Fri Nov 24 12:01:27 2023'
last_solve_result_num 0
nb_iter_last 6
nb_iter_total 6
Expand All @@ -12,7 +12,7 @@ total_time 0
operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_9796395416193655574'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_11598000998118468803'

log_level_ampl INFO
log_level_knitro 2
Expand All @@ -25,6 +25,7 @@ epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks NO_GENERATION
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
final_status OK
dcopf_status OK

ctime_start 'Thu Nov 23 14:57:46 2023'
ctime_start 'Fri Nov 24 12:02:34 2023'
last_solve_result_num 0
nb_iter_last 4
nb_iter_total 4
_ampl_elapsed_time 0.093000
_ampl_elapsed_time 0.095000
_total_solve_time 0.031250
total_time 0

operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_1042775858349572355'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_7140935963031466466'

log_level_ampl INFO
log_level_knitro 2
Expand All @@ -25,7 +25,7 @@ epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks 1
buses_with_reactive_slacks NO_GENERATION
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
final_status OK
dcopf_status OK

ctime_start 'Thu Nov 23 14:55:00 2023'
ctime_start 'Fri Nov 24 12:01:03 2023'
last_solve_result_num 0
nb_iter_last 6
nb_iter_total 6
_ampl_elapsed_time 0.110000
_total_solve_time 0.031250
_total_solve_time 0.046875
total_time 0

operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_4704726281504951464'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_2514974589581916563'

log_level_ampl INFO
log_level_knitro 2
Expand All @@ -25,6 +25,7 @@ epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks NO_GENERATION
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
Expand Down

0 comments on commit 8ed0001

Please sign in to comment.