From 88d7411e923e587e4cc197c7386fc8b622fc800f Mon Sep 17 00:00:00 2001 From: "Bernhard J. Berger" <bernhard.berger@uni-bremen.de> Date: Sat, 13 May 2023 11:01:28 +0200 Subject: [PATCH] Renamed DoubleX and FloatX to RealX. --- .../evoal/core/api/utils/ConstantSwitch.java | 2 +- .../comparator/WeightedSumComparator.java | 6 ++-- .../constraint/ast/ConditionConverter.java | 2 +- .../ast/UnaryBoundaryIdentifier.java | 2 +- .../correlation/el/RangeSwitch.java | 2 +- .../constraints/el/DataReferenceSwitch.java | 2 +- .../main/constraints/el/NumberSwitch.java | 2 +- .../main/constraints/el/StringSwitch.java | 2 +- .../constraints/el/ValueReferenceSwitch.java | 2 +- .../producer/ConfigurationValueProducer.java | 6 ++-- .../utils/LanguageHelperRegressionTest.java | 6 ++-- .../core/api/utils/LanguageHelperTest.ol | 31 ++++++++++--------- .../core/api/utils/regressions/generator.dl | 6 ++-- .../generator/main/benchmarks/Rastrigin.java | 2 -- .../main/functions/ConstantFunction.java | 2 -- .../MultivariateNormalDistribution.java | 3 +- .../MultivariateUniformDistribution.java | 5 ++- .../main/generators/UniformDistribution.java | 4 +-- 18 files changed, 41 insertions(+), 46 deletions(-) diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/api/utils/ConstantSwitch.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/api/utils/ConstantSwitch.java index e23ea035..1befdb4f 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/api/utils/ConstantSwitch.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/api/utils/ConstantSwitch.java @@ -99,7 +99,7 @@ public class ConstantSwitch extends BaseSwitch<Object> { } @Override - public Object caseDoubleLiteral(final DoubleLiteral object) { + public Object caseRealLiteral(final RealLiteral object) { return object.getValue(); } diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/comparator/WeightedSumComparator.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/comparator/WeightedSumComparator.java index 4770d415..48b6dcdd 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/comparator/WeightedSumComparator.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/comparator/WeightedSumComparator.java @@ -2,7 +2,7 @@ package de.evoal.core.main.comparator; import de.evoal.core.api.optimisation.OptimisationValueComparator; import de.evoal.core.api.optimisation.OptimisationValue; -import de.evoal.languages.model.base.DoubleLiteral; +import de.evoal.languages.model.base.RealLiteral; import de.evoal.languages.model.base.Array; import de.evoal.languages.model.base.Instance; import de.evoal.languages.model.base.Literal; @@ -28,8 +28,8 @@ public class WeightedSumComparator implements OptimisationValueComparator { this.weights = weights.getValues() .stream() .map(Literal.class::cast) - .map(DoubleLiteral.class::cast) - .mapToDouble(DoubleLiteral::getValue) + .map(RealLiteral.class::cast) + .mapToDouble(RealLiteral::getValue) .toArray(); return this; diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/constraint/ast/ConditionConverter.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/constraint/ast/ConditionConverter.java index bee5f980..671ecd0d 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/constraint/ast/ConditionConverter.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/constraint/ast/ConditionConverter.java @@ -209,7 +209,7 @@ public class ConditionConverter extends BaseSwitch<Object> { } @Override - public Object caseDoubleLiteral(final DoubleLiteral object) { + public Object caseRealLiteral(final RealLiteral object) { return (BiFunction<Properties, Properties, Object>) (gen, fit) -> object.getValue(); } diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/constraint/ast/UnaryBoundaryIdentifier.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/constraint/ast/UnaryBoundaryIdentifier.java index d1a096e7..cffa6dd2 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/constraint/ast/UnaryBoundaryIdentifier.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/constraint/ast/UnaryBoundaryIdentifier.java @@ -147,7 +147,7 @@ public class UnaryBoundaryIdentifier extends BaseSwitch<Object> { } @Override - public Object caseDoubleLiteral(final DoubleLiteral object) { + public Object caseRealLiteral(final RealLiteral object) { return object.getValue(); } diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/correlation/el/RangeSwitch.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/correlation/el/RangeSwitch.java index 94a16406..ecee9aa1 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/correlation/el/RangeSwitch.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/correlation/el/RangeSwitch.java @@ -81,7 +81,7 @@ public class RangeSwitch extends BaseSwitch<Range> { } @Override - public Range caseDoubleLiteral(final DoubleLiteral object) { + public Range caseRealLiteral(final RealLiteral object) { throw new IllegalStateException("Searching for range but found a double literal."); } diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/DataReferenceSwitch.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/DataReferenceSwitch.java index 45996b76..f5840b06 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/DataReferenceSwitch.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/DataReferenceSwitch.java @@ -82,7 +82,7 @@ public class DataReferenceSwitch extends BaseSwitch<DataDescription> { } @Override - public DataDescription caseDoubleLiteral(final DoubleLiteral object) { + public DataDescription caseRealLiteral(final RealLiteral object) { throw new IllegalStateException("Searching for Data but found a double literal."); } diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/NumberSwitch.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/NumberSwitch.java index f0270ff0..c3d8d584 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/NumberSwitch.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/NumberSwitch.java @@ -93,7 +93,7 @@ public class NumberSwitch extends BaseSwitch<Number> { } @Override - public Number caseDoubleLiteral(final DoubleLiteral object) { + public Number caseRealLiteral(final RealLiteral object) { return object.getValue(); } diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/StringSwitch.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/StringSwitch.java index 99e4b053..f9d8cb48 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/StringSwitch.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/StringSwitch.java @@ -79,7 +79,7 @@ public class StringSwitch extends BaseSwitch<String> { } @Override - public String caseDoubleLiteral(final DoubleLiteral object) { + public String caseRealLiteral(final RealLiteral object) { throw new IllegalStateException("Searching for String but found a double literal."); } diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/ValueReferenceSwitch.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/ValueReferenceSwitch.java index 30a9fd61..daea5ea8 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/ValueReferenceSwitch.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/constraints/el/ValueReferenceSwitch.java @@ -89,7 +89,7 @@ public class ValueReferenceSwitch extends BaseSwitch<String> { } @Override - public String caseDoubleLiteral(final DoubleLiteral object) { + public String caseRealLiteral(final RealLiteral object) { throw new IllegalStateException("Searching for a value reference but found a double literal."); } diff --git a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/producer/ConfigurationValueProducer.java b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/producer/ConfigurationValueProducer.java index 4feffa90..f7bf0878 100644 --- a/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/producer/ConfigurationValueProducer.java +++ b/src/core/de.evoal.core.main/src/main/java/de/evoal/core/main/producer/ConfigurationValueProducer.java @@ -6,9 +6,8 @@ import de.evoal.core.api.cdi.ConfigurationValue; import de.evoal.core.api.utils.LanguageHelper; import de.evoal.languages.model.base.Literal; import de.evoal.languages.model.ddl.DataDescription; -import de.evoal.languages.model.instance.DataReference; import de.evoal.languages.model.ol.OptimisationModule; -import de.evoal.languages.model.base.DoubleLiteral; +import de.evoal.languages.model.base.RealLiteral; import de.evoal.languages.model.base.Array; import de.evoal.languages.model.base.Instance; import lombok.extern.slf4j.Slf4j; @@ -17,7 +16,6 @@ import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.InjectionPoint; import javax.inject.Inject; -import java.util.Arrays; @ApplicationScoped @Slf4j @@ -107,7 +105,7 @@ public class ConfigurationValueProducer { return (this.<Array>lookup(board.get(value.entry()), value.access())) .getValues() .stream() - .mapToDouble(x -> ((DoubleLiteral)((Literal)x)).getValue()) + .mapToDouble(x -> ((RealLiteral)((Literal)x)).getValue()) .toArray(); } diff --git a/src/core/de.evoal.core.main/src/test/java/de/evoal/core/api/utils/LanguageHelperRegressionTest.java b/src/core/de.evoal.core.main/src/test/java/de/evoal/core/api/utils/LanguageHelperRegressionTest.java index 9e0ee9e8..475492b0 100644 --- a/src/core/de.evoal.core.main/src/test/java/de/evoal/core/api/utils/LanguageHelperRegressionTest.java +++ b/src/core/de.evoal.core.main/src/test/java/de/evoal/core/api/utils/LanguageHelperRegressionTest.java @@ -17,7 +17,7 @@ public class LanguageHelperRegressionTest { Assertions.assertTrue(attribute.getType() instanceof ArrayType); final ArrayType typeA = (ArrayType) attribute.getType(); Assertions.assertEquals(1, typeA.getElements().size()); - Assertions.assertTrue(typeA.getElements().get(0) instanceof FloatType); + Assertions.assertTrue(typeA.getElements().get(0) instanceof RealType); } private void assertAttributeTypeOfC(final AttributeDefinition attribute) { @@ -28,12 +28,12 @@ public class LanguageHelperRegressionTest { Assertions.assertTrue(typeC.getElements().get(0) instanceof ArrayType); final ArrayType typetypeC = (ArrayType) typeC.getElements().get(0); Assertions.assertEquals(1, typetypeC.getElements().size()); - Assertions.assertTrue(typetypeC.getElements().get(0) instanceof FloatType); + Assertions.assertTrue(typetypeC.getElements().get(0) instanceof RealType); } private void assertAttributeTypeOfM(final AttributeDefinition attribute) { Assertions.assertNotNull(attribute); - Assertions.assertTrue(attribute.getType() instanceof FloatType); + Assertions.assertTrue(attribute.getType() instanceof RealType); } @Test diff --git a/src/core/de.evoal.core.main/src/test/resources/de/evoal/core/api/utils/LanguageHelperTest.ol b/src/core/de.evoal.core.main/src/test/resources/de/evoal/core/api/utils/LanguageHelperTest.ol index a0e767fc..e7f8346b 100644 --- a/src/core/de.evoal.core.main/src/test/resources/de/evoal/core/api/utils/LanguageHelperTest.ol +++ b/src/core/de.evoal.core.main/src/test/resources/de/evoal/core/api/utils/LanguageHelperTest.ol @@ -1,17 +1,20 @@ import "definitions" from de.evoal.core.api.utils.definitions; -declare 'p' as parent { - child := A { - 'boolean-field' := true; - 'float-field' := 1.3; - 'integer-field' := 4; - 'string-field' := "FOOBAR"; - 'array-1D-float' := [4.2, 3.1, 1.0]; - 'array-2D-int' := [ - [ 1, 2, 3, 4, 5], - [ 3, 2, 1], - [42] - ]; - }; -} documenting := []; \ No newline at end of file +module de.evoal.core.api.utils.regressions.LangiageHelperTest { + declare 'p' as parent { + child := A { + 'boolean-field' := true; + 'float-field' := 1.3; + 'integer-field' := 4; + 'string-field' := "FOOBAR"; + 'array-1D-float' := [4.2, 3.1, 1.0]; + 'array-2D-int' := [ + [ 1, 2, 3, 4, 5], + [ 3, 2, 1], + [42] + ]; + }; + } documenting := []; + +} \ No newline at end of file diff --git a/src/core/de.evoal.core.main/src/test/resources/de/evoal/core/api/utils/regressions/generator.dl b/src/core/de.evoal.core.main/src/test/resources/de/evoal/core/api/utils/regressions/generator.dl index 61909779..595d2445 100644 --- a/src/core/de.evoal.core.main/src/test/resources/de/evoal/core/api/utils/regressions/generator.dl +++ b/src/core/de.evoal.core.main/src/test/resources/de/evoal/core/api/utils/regressions/generator.dl @@ -8,7 +8,7 @@ module de.evoal.core.api.utils.regressions.generator { /** * The recommended value for the vector a is (1/m)*{1,2,2,4,4,6,3,7,5,5}. */ - 'a' : array float; + 'a' : array real; /** * The recommended value for the constant c is { @@ -17,11 +17,11 @@ module de.evoal.core.api.utils.regressions.generator { * {4.0, 1.0, 8.0, 6.0, 3.0, 2.0, 5.0, 8.0, 6.0, 7.0}, * {4.0, 1.0, 8.0, 6.0, 7.0, 9.0, 3.0, 1.0, 2.0, 3.6}}. */ - 'c' : array array float; + 'c' : array array real; /** * The recommended value for the constant m is 10. */ - 'm' : float; + 'm' : real; } } \ No newline at end of file diff --git a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/benchmarks/Rastrigin.java b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/benchmarks/Rastrigin.java index a6e253f0..0554a369 100644 --- a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/benchmarks/Rastrigin.java +++ b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/benchmarks/Rastrigin.java @@ -6,9 +6,7 @@ import de.evoal.core.api.properties.PropertySpecification; import de.evoal.core.api.utils.InitializationException; import de.evoal.generator.api.AbstractGeneratorFunction; import de.evoal.generator.api.GeneratorFunction; -import de.evoal.languages.model.base.DoubleLiteral; import de.evoal.languages.model.generator.Step; -import de.evoal.languages.model.base.Literal; import javax.enterprise.context.Dependent; import javax.inject.Inject; diff --git a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/functions/ConstantFunction.java b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/functions/ConstantFunction.java index d99a3c34..4a49175f 100644 --- a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/functions/ConstantFunction.java +++ b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/functions/ConstantFunction.java @@ -5,9 +5,7 @@ import de.evoal.core.api.properties.Properties; import de.evoal.core.api.utils.InitializationException; import de.evoal.generator.api.AbstractGeneratorFunction; import de.evoal.generator.api.GeneratorFunction; -import de.evoal.languages.model.base.DoubleLiteral; import de.evoal.languages.model.generator.Step; -import de.evoal.languages.model.base.Array; import javax.enterprise.context.Dependent; import javax.inject.Inject; diff --git a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/MultivariateNormalDistribution.java b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/MultivariateNormalDistribution.java index e3bfd78d..4344527e 100644 --- a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/MultivariateNormalDistribution.java +++ b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/MultivariateNormalDistribution.java @@ -2,7 +2,6 @@ package de.evoal.generator.main.generators; import de.evoal.core.api.utils.InitializationException; import de.evoal.generator.api.GeneratorFunction; -import de.evoal.languages.model.base.DoubleLiteral; import de.evoal.languages.model.generator.Step; import de.evoal.languages.model.base.*; import lombok.NonNull; @@ -45,7 +44,7 @@ public class MultivariateNormalDistribution extends MultivariateRealDistribution } private double readDouble(final Value value) { - return ((DoubleLiteral)value).getLiteral(); + return ((RealLiteral)value).getLiteral(); } private double[] readMeans(final @NonNull Instance instance) { diff --git a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/MultivariateUniformDistribution.java b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/MultivariateUniformDistribution.java index 8b3e0dc9..69f49563 100644 --- a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/MultivariateUniformDistribution.java +++ b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/MultivariateUniformDistribution.java @@ -2,11 +2,10 @@ package de.evoal.generator.main.generators; import de.evoal.core.api.utils.InitializationException; import de.evoal.generator.api.GeneratorFunction; -import de.evoal.languages.model.base.DoubleLiteral; +import de.evoal.languages.model.base.RealLiteral; import de.evoal.languages.model.generator.Step; import de.evoal.languages.model.base.Array; import de.evoal.languages.model.base.Instance; -import de.evoal.languages.model.base.Literal; import javax.inject.Named; import java.util.List; @@ -45,7 +44,7 @@ public class MultivariateUniformDistribution extends MultivariateRealDistributio } private double readDouble(final Instance value, final String name) { - return ((DoubleLiteral)value.findAttribute(name)).getLiteral(); + return ((RealLiteral)value.findAttribute(name)).getLiteral(); } } diff --git a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/UniformDistribution.java b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/UniformDistribution.java index 1b697151..491c73b3 100644 --- a/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/UniformDistribution.java +++ b/src/core/de.evoal.generator.main/src/main/java/de/evoal/generator/main/generators/UniformDistribution.java @@ -2,7 +2,7 @@ package de.evoal.generator.main.generators; import de.evoal.core.api.utils.InitializationException; import de.evoal.generator.api.GeneratorFunction; -import de.evoal.languages.model.base.DoubleLiteral; +import de.evoal.languages.model.base.RealLiteral; import de.evoal.languages.model.generator.Step; import org.apache.commons.math3.distribution.UniformRealDistribution; @@ -15,7 +15,7 @@ public class UniformDistribution extends RealDistributionBase { public GeneratorFunction init(final Step configuration) throws InitializationException { super.init(configuration); - Object ranges = ((DoubleLiteral)configuration.getInstance().findAttribute("μ").getValue()).getLiteral(); + Object ranges = ((RealLiteral)configuration.getInstance().findAttribute("μ").getValue()).getLiteral(); if(true) throw new IllegalStateException("Not yet implemented."); for(int i = 0; i < writeSpecification.getProperties().size(); ++i) { -- GitLab