From 9f7abd99644e5861b600aa570ae38cb4c520bbd8 Mon Sep 17 00:00:00 2001 From: Lisrte Date: Wed, 13 Dec 2023 13:19:57 +0100 Subject: [PATCH] Rename optimizer to simplifier 2 Signed-off-by: lisrte --- .../com/powsybl/dynawaltz/DynaWaltzContext.java | 8 ++++---- .../powsybl/dynawaltz/DynaWaltzParameters.java | 16 ++++++++-------- .../dynawaltz/DynaWaltzParametersTest.java | 12 ++++++------ .../powsybl/dynawaltz/ModelsSimplifierTest.java | 2 +- .../src/test/resources/DynaWaltzParameters.json | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java index 9f42e19c5..bff2d47e8 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzContext.java @@ -75,8 +75,8 @@ public DynaWaltzContext(Network network, String workingVariantId, List dataOptimizers = dynaWaltzParameters.isUseModelOptimizers() ? ServiceLoader.load(ModelsSimplifier.class).iterator() : Collections.emptyIterator(); - this.dynamicModels = runSimplifiers(dataOptimizers, + Iterator dataSimplifiers = dynaWaltzParameters.isUseModelSimplifiers() ? ServiceLoader.load(ModelsSimplifier.class).iterator() : Collections.emptyIterator(); + this.dynamicModels = runSimplifiers(dataSimplifiers, Objects.requireNonNull(dynamicModels) .stream() .filter(distinctByDynamicId(reporter).and(distinctByStaticId(reporter))), @@ -114,8 +114,8 @@ private FrequencySynchronizerModel setupFrequencySynchronizer(Function runSimplifiers(Iterator dataOptimizers, Stream inputData, Reporter reporter) { - return dataOptimizers.hasNext() ? runSimplifiers(dataOptimizers, dataOptimizers.next().simplifyModels(inputData, dynaWaltzParameters, reporter), reporter) : inputData; + private Stream runSimplifiers(Iterator dataSimplifiers, Stream inputData, Reporter reporter) { + return dataSimplifiers.hasNext() ? runSimplifiers(dataSimplifiers, dataSimplifiers.next().simplifyModels(inputData, dynaWaltzParameters, reporter), reporter) : inputData; } public Network getNetwork() { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzParameters.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzParameters.java index d38584bba..268b66e1c 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzParameters.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzParameters.java @@ -39,7 +39,7 @@ public class DynaWaltzParameters extends AbstractExtension c.getOptionalBooleanProperty("writeFinalState")).orElse(DEFAULT_WRITE_FINAL_STATE); - boolean useModelOptimizers = config.flatMap(c -> c.getOptionalBooleanProperty("useModelOptimizers")).orElse(DEFAULT_USE_MODEL_OPTIMIZERS); + boolean useModelSimplifiers = config.flatMap(c -> c.getOptionalBooleanProperty("useModelSimplifiers")).orElse(USE_MODEL_SIMPLIFIERS); // Dump file config boolean exportDumpFile = config.flatMap(c -> c.getOptionalBooleanProperty("dump.export")).orElse(DumpFileParameters.DEFAULT_EXPORT_DUMP); @@ -134,7 +134,7 @@ public static DynaWaltzParameters load(PlatformConfig platformConfig, FileSystem .setSolverType(solverType) .setMergeLoads(mergeLoads) .setWriteFinalState(writeFinalState) - .setUseModelOptimizers(useModelOptimizers) + .setUseModelSimplifiers(useModelSimplifiers) .setDumpFileParameters(dumpFileParameters); } @@ -208,12 +208,12 @@ public boolean isWriteFinalState() { return writeFinalState; } - public boolean isUseModelOptimizers() { - return useModelOptimizers; + public boolean isUseModelSimplifiers() { + return useModelSimplifiers; } - public DynaWaltzParameters setUseModelOptimizers(boolean useModelOptimizers) { - this.useModelOptimizers = useModelOptimizers; + public DynaWaltzParameters setUseModelSimplifiers(boolean useModelSimplifiers) { + this.useModelSimplifiers = useModelSimplifiers; return this; } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzParametersTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzParametersTest.java index 9a439a6bc..3f3b26525 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzParametersTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzParametersTest.java @@ -57,8 +57,8 @@ void checkParameters() throws IOException { SolverType solverType = SolverType.IDA; String solverParametersId = "solverParametersId"; boolean mergeLoads = true; - boolean useModelOptimizers = true; - initPlatformConfig(networkParametersId, solverType, solverParametersId, mergeLoads, useModelOptimizers); + boolean useModelSimplifiers = true; + initPlatformConfig(networkParametersId, solverType, solverParametersId, mergeLoads, useModelSimplifiers); DynaWaltzParameters parameters = DynaWaltzParameters.load(platformConfig, fileSystem); @@ -88,7 +88,7 @@ void checkParameters() throws IOException { assertEquals(ParameterType.DOUBLE, absAccuracy.type()); assertEquals(mergeLoads, parameters.isMergeLoads()); - assertEquals(useModelOptimizers, parameters.isUseModelOptimizers()); + assertEquals(useModelSimplifiers, parameters.isUseModelSimplifiers()); } @Test @@ -122,7 +122,7 @@ void roundTripParametersSerializing() throws IOException { JsonDynamicSimulationParameters::read, "/DynaWaltzParameters.json"); } - private void initPlatformConfig(String networkParametersId, SolverType solverType, String solverParametersId, boolean mergeLoads, boolean useModelOptimizers) throws IOException { + private void initPlatformConfig(String networkParametersId, SolverType solverType, String solverParametersId, boolean mergeLoads, boolean useModelSimplifiers) throws IOException { String parametersFile = USER_HOME + "parametersFile"; String networkParametersFile = USER_HOME + "networkParametersFile"; String solverParametersFile = USER_HOME + "solverParametersFile"; @@ -135,7 +135,7 @@ private void initPlatformConfig(String networkParametersId, SolverType solverTyp moduleConfig.setStringProperty("network.parametersId", networkParametersId); moduleConfig.setStringProperty("solver.type", solverType.toString()); moduleConfig.setStringProperty("solver.parametersId", solverParametersId); - moduleConfig.setStringProperty("useModelOptimizers", String.valueOf(useModelOptimizers)); + moduleConfig.setStringProperty("useModelSimplifiers", String.valueOf(useModelSimplifiers)); Files.createDirectories(fileSystem.getPath(USER_HOME)); copyFile("/parametersSet/models.par", parametersFile); @@ -182,7 +182,7 @@ void checkDefaultParameters() throws IOException { assertEquals("1", parameters.getSolverParameters().getId()); assertEquals(DynaWaltzParameters.DEFAULT_MERGE_LOADS, parameters.isMergeLoads()); - assertEquals(DynaWaltzParameters.DEFAULT_USE_MODEL_OPTIMIZERS, parameters.isUseModelOptimizers()); + assertEquals(DynaWaltzParameters.USE_MODEL_SIMPLIFIERS, parameters.isUseModelSimplifiers()); } @Test diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/ModelsSimplifierTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/ModelsSimplifierTest.java index 52b6caa3c..f59b72482 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/ModelsSimplifierTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/ModelsSimplifierTest.java @@ -42,7 +42,7 @@ void loadSimplifiers() { void simplifyModels() { Network network = EurostagTutorialExample1Factory.create(); DynamicSimulationParameters parameters = DynamicSimulationParameters.load(); - DynaWaltzParameters dynawoParameters = DynaWaltzParameters.load().setUseModelOptimizers(true); + DynaWaltzParameters dynawoParameters = DynaWaltzParameters.load().setUseModelSimplifiers(true); List dynamicModels = List.of( new GeneratorFictitious("BBM_GEN", network.getGenerator("GEN"), "GPV"), new BaseLoad("BBM_LOAD", network.getLoad("LOAD"), "LOAD", "LoadAlphaBeta"), diff --git a/dynawaltz/src/test/resources/DynaWaltzParameters.json b/dynawaltz/src/test/resources/DynaWaltzParameters.json index 55802855d..8544c81e2 100644 --- a/dynawaltz/src/test/resources/DynaWaltzParameters.json +++ b/dynawaltz/src/test/resources/DynaWaltzParameters.json @@ -39,7 +39,7 @@ "solverType" : "IDA", "mergeLoads" : false, "writeFinalState" : true, - "useModelOptimizers" : false, + "useModelSimplifiers" : false, "dumpFileParameters" : { "exportDumpFile" : false, "useDumpFile" : false,