Skip to content
Snippets Groups Projects
Commit 79c0ee12 authored by Bernhard Johannes Berger's avatar Bernhard Johannes Berger
Browse files

Adapting to previous changes in DSL files and added a search path to DSL loading.

parent 81cbe247
No related branches found
No related tags found
1 merge request!2Allow arrays, instance literals and stuff in initialisation of attribute...
Pipeline #257152 canceled
Showing
with 136 additions and 82 deletions
......@@ -4,12 +4,12 @@ module de.evoal.approximative.density.ml {
*
* @param bandwith Width for density calculation.
*/
def void 'kernel-density-estimation'(float bandwidth);
def void 'kernel-density-estimation'(real bandwidth);
/**
* Measures density information using a gaussian kernel.
*
* @param bandwith Width for density calculation.
*/
def void 'gaussian-density-estimation'(float bandwidth);
def void 'gaussian-density-estimation'(real bandwidth);
}
\ No newline at end of file
......@@ -13,12 +13,12 @@ module de.evoal.approximative.density.optimisation {
/**
* Exponent for the formula.
*/
exponent : float;
exponent : real;
/**
* Exponent for the formula.
*/
'root-exponent' : float;
'root-exponent' : real;
}
type 'kernel-density' extends density {}
......
......@@ -48,7 +48,7 @@ module de.evoal.core.ea.optimisation {
}
type 'standard-deviation' extends 'constraint-calculation' {
factor : float;
factor : real;
}
abstract type 'constraint-handling' {}
......@@ -62,7 +62,7 @@ module de.evoal.core.ea.optimisation {
type 'repair-with-random' extends 'repair-strategy' {}
type 'malus-for-fitness' extends 'constraint-handling' {
smoothing : float;
smoothing : real;
}
type selectors {
......@@ -77,12 +77,12 @@ module de.evoal.core.ea.optimisation {
}
type 'elite-selector' extends selector {
'size-factor' : float;
'size-factor' : real;
'non-elite-selector' : instance selector;
}
type 'boltzmann-selector' extends selector {
beta : float;
beta : real;
}
type 'exponential-rank-selector' extends selector {
......@@ -102,7 +102,7 @@ module de.evoal.core.ea.optimisation {
}
type 'tournament-selector' extends selector {
'size-factor' : float;
'size-factor' : real;
}
type 'truncation-selector' extends selector {
......@@ -117,86 +117,86 @@ module de.evoal.core.ea.optimisation {
abstract type crossover {}
type 'mean-alterer' extends crossover {
probability : float;
probability : real;
}
type 'correlation-mean-alterer' extends crossover {
probability : float;
probability : real;
}
type 'partial-matched-alterer' extends crossover {
probability : float;
probability : real;
}
type 'correlation-partial-matched-alterer' extends crossover {
probability : float;
probability : real;
}
type 'line-crossover' extends crossover {
probability : float;
position : float;
probability : real;
position : real;
}
type 'correlation-line-crossover' extends crossover {
probability : float;
position : float;
probability : real;
position : real;
}
type 'multi-point-crossover' extends crossover {
probability : float;
probability : real;
count : int;
}
type 'correlation-multi-point-crossover' extends crossover {
probability : float;
probability : real;
count : int;
}
type 'single-point-crossover' extends crossover {
probability : float;
probability : real;
}
type 'correlation-single-point-crossover' extends crossover {
probability : float;
probability : real;
}
type 'uniform-crossover' extends crossover {
'crossover-probability' : float;
'swap-probability' : float;
'crossover-probability' : real;
'swap-probability' : real;
}
type 'correlation-uniform-crossover' extends crossover {
'crossover-probability' : float;
'swap-probability' : float;
'crossover-probability' : real;
'swap-probability' : real;
}
abstract type mutator {
}
type 'gaussian-mutator' extends mutator {
probability : float;
probability : real;
}
type 'correlation-gaussian-mutator' extends mutator {
probability : float;
threshold : float;
probability : real;
threshold : real;
}
type 'swap-mutator' extends mutator {
probability : float;
probability : real;
}
type 'correlation-swap-mutator' extends mutator {
probability : float;
threshold : float;
probability : real;
threshold : real;
}
type 'bit-flip-mutator' extends mutator {
probability : float;
probability : real;
}
type 'correlation-bit-flip-mutator' extends mutator {
probability : float;
threshold : float;
probability : real;
threshold : real;
}
}
\ No newline at end of file
......@@ -3,10 +3,10 @@ type 'parent' {
}
type A {
'float-field' : float;
'float-field' : real;
'string-field' : string;
'integer-field' : int;
'boolean-field' : boolean;
'array-1D-float' : array float;
'array-1D-float' : array real;
'array-2D-int' : array array int;
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ type 'shekel' {
/**
* 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 {
......@@ -16,10 +16,10 @@ type 'shekel' {
* {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;
}
......@@ -11,7 +11,6 @@ cd $1
set -x
java $CLASSPATH \
"-Bcore:logging=debug" \
"-Bcore:main=heuristic-search" \
"-Bcore:optimisation-configuration-file=$2" \
"-Bcore:evaluation-output-folder=$3"
......@@ -10,37 +10,32 @@ import javax.inject.Named;
public class CoreBlackboardEntries implements BlackboardEntries {
/**
* The target properties to search for.
*/
public static final String TARGET_PROPERTIES = "core:target-properties";
/**
* Folder containing the constraint files.
* Number of evaluation runs.
*/
public static final String CONSTRAINT_FOLDER = "core:constraint-folder";
@Commandline(main = "heuristic-search", name = "core:evaluation-iterations", doc = "Number of iterations to run the search.")
public static final String EVALUATION_ITERATIONS = "core:evaluation-iterations";
/**
* Parameter to specify for logging leven.
* The actual output folder for the evaluation.
*/
@Commandline(main = "", name = "core:logging", doc = "Logging level to use (ERROR,WARN,INFO,DEBUG)")
public static final String LOGGING_LEVEL = "core:logging";
@Commandline(main = "heuristic-search", name = "core:evaluation-output-folder", doc = "Folder to write the results to.")
public static final String EVALUATION_OUTPUT_FOLDER = "core:evaluation-output-folder";
/**
* Number of evaluation runs.
* The evaluation run number.
*/
@Commandline(main = "heuristic-search", name = "core:evaluation-iterations", doc = "Number of iterations to run the search.")
public static final String EVALUATION_ITERATIONS = "core:evaluation-iterations";
public static final String EVALUATION_RUN = "core:evaluation-run";
/**
* The evaluation run number.
* Parameter to specify for logging leven.
*/
public static final String EVALUATION_RUN = "core:evaluation-run";
@Commandline(main = "", name = "core:logging", doc = "Logging level to use (ERROR,WARN,INFO,DEBUG)")
public static final String LOGGING_LEVEL = "core:logging";
/**
* The actual output folder for the evaluation.
* Name of the main to run.
*/
@Commandline(main = "heuristic-search", name = "core:evaluation-output-folder", doc = "Folder to write the results to.")
public static final String EVALUATION_OUTPUT_FOLDER = "core:evaluation-output-folder";
public static final String MAIN = "core:main";
/**
* The heuristic configuration.
......@@ -53,14 +48,19 @@ public class CoreBlackboardEntries implements BlackboardEntries {
@Commandline(main = "heuristic-search", name = "core:optimisation-configuration", doc = "Optimisation configuration to use.")
public static final String OPTIMISATION_CONFIGURATION_FILE = "core:optimisation-configuration-file";
/**
* Name of the main to run.
*/
public static final String MAIN = "core:main";
@Commandline(main="", name="core:search-path", doc="Additional search path entries for DSL lookup.")
public static final String SEARCH_PATH = "core:search-path";
/**
* File containing targets for evaluation.
*/
@Commandline(main="heuristic-search-evaluation", name = "core:target-points-file", doc = "A file containing the targets to use for evaluation.")
public static final String TARGET_POINTS_FILE = "core:target-points-file";
/**
* The target properties to search for.
*/
public static final String TARGET_PROPERTIES = "core:target-properties";
}
package de.evoal.core.main.language;
import de.evoal.core.api.board.Blackboard;
import de.evoal.core.api.board.BlackboardEntry;
import de.evoal.core.api.board.CoreBlackboardEntries;
import de.evoal.languages.model.utils.scoping.ClasspathGlobalScopeProvider;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import java.io.File;
import java.util.Arrays;
@ApplicationScoped
public class SearchPathConfigurator {
@Inject
private Blackboard board;
public void configure(final @Observes BlackboardEntry entry) {
if (!entry.isSame(CoreBlackboardEntries.SEARCH_PATH)) {
return;
}
final String searchPath = board.get(CoreBlackboardEntries.SEARCH_PATH);
final String [] searchPathEntries = searchPath.split(File.pathSeparator);
ClasspathGlobalScopeProvider.SEARCH_PATH.addAll(Arrays.asList(searchPathEntries));
}
}
......@@ -17,6 +17,7 @@ import de.evoal.languages.model.dl.impl.DlPackageImpl;
import de.evoal.languages.model.ol.OptimisationModule;
import de.evoal.languages.model.ol.dsl.OptimisationLanguageStandaloneSetup;
import de.evoal.languages.model.ol.impl.OLPackageImpl;
import de.evoal.languages.model.utils.scoping.ClasspathGlobalScopeProvider;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
......@@ -51,6 +52,10 @@ public class OptimisationModuleLoader {
throw new IllegalArgumentException("Unable to read optimisation configuration file: " + configurationFileName);
}
final File folder = configurationFile.getAbsoluteFile().getParentFile();
ClasspathGlobalScopeProvider.SEARCH_PATH.add(folder.toString());
log.info("Adding {} to search path.", folder);
initializeEMF();
final Injector ealInjector = new OptimisationLanguageStandaloneSetup().createInjectorAndDoEMFRegistration();
......
......@@ -7,9 +7,9 @@ module de.evoal.core.constraint {
* <li>Reference to the data ...</li>
* </ol>
*/
def void variance(data reference, float variance);
def void variance(data reference, real variance);
def void connection(data ref1, data ref2, float connection);
def void connection(data ref1, data ref2, real connection);
def void constraint(expression exp, string category);
}
......@@ -2,5 +2,10 @@ module de.evoal.core.math {
/**
* The one and only PI.
*/
const float PI := 3.1415926535;
const real PI := 3.1415926535;
/**
* The one and only PI.
*/
const real 'π' := 3.1415926535;
}
......@@ -154,7 +154,7 @@ module de.evoal.core.optimisation {
/**
* Weights for summing the dimensions.
*/
weights : array float;
weights : array real;
}
/**
......
......@@ -4,11 +4,11 @@ module de.evoal.core.api.utils.definitions {
}
type A {
'float-field' : float;
'float-field' : real;
'string-field' : string;
'integer-field' : int;
'boolean-field' : boolean;
'array-1D-float' : array float;
'array-1D-float' : array real;
'array-2D-int' : array array int;
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import de.evoal.languages.model.base.impl.BasePackageImpl;
import de.evoal.languages.model.generator.dsl.GeneratorDSLStandaloneSetup;
import de.evoal.languages.model.generator.GeneratorModule;
import de.evoal.languages.model.generator.impl.GeneratorPackageImpl;
import de.evoal.languages.model.utils.scoping.ClasspathGlobalScopeProvider;
import lombok.extern.slf4j.Slf4j;
import javax.enterprise.context.ApplicationScoped;
......@@ -31,7 +32,7 @@ import org.eclipse.xtext.resource.XtextResourceSet;
@ApplicationScoped
@Slf4j
public class GeneratroeModuleProducer {
public class GeneratorModuleProducer {
public void loadModel(final @Observes BlackboardEntry value, final Blackboard board) {
if(!value.isSame(GeneratorBlackboardEntries.GENERATOR_CONFIGURATION_FILE)) {
return;
......@@ -55,6 +56,10 @@ public class GeneratroeModuleProducer {
throw new IllegalArgumentException("Please specify a readable genrator file.");
}
final File folder = file.getAbsoluteFile().getParentFile();
ClasspathGlobalScopeProvider.SEARCH_PATH.add(folder.toString());
log.info("Adding {} to search path.", folder);
final GeneratorModule configuration = read(file).get();
board.bind(GeneratorBlackboardEntries.GENERATOR_CONFIGURATION, configuration);
}
......
......@@ -26,6 +26,7 @@ module de.evoal.generator.main {
requires de.evoal.core.main;
requires commons.math3;
requires com.google.guice;
requires de.evoal.languages.model.utils;
opens de.evoal.generator;
......
......@@ -112,17 +112,17 @@ module de.evoal.generator.generator {
/**
* The constant a is set to 20 in the original Ackley function.
*/
'a' : float := 20.0;
'a' : real := 20.0;
/**
* The constant b is set to 0.2 in the original Ackley function.
*/
b : float := 0.2;
b : real := 0.2;
/**
* The constant c is set to 2π in the original Ackley function.
*/
'c' : float := 2 * PI;
'c' : real := 2 * PI;
}
/**
......@@ -191,7 +191,7 @@ module de.evoal.generator.generator {
/**
* Constant a, which is typically 10.
*/
'a' : float := 10.0;
'a' : real := 10.0;
}
/**
......@@ -213,15 +213,15 @@ module de.evoal.generator.generator {
/**
* The constant values to append.
*/
constants : array float;
constants : array real;
}
type distribution {}
type 'multivariate-normal-distribution' extends distribution {
means : array float;
covariance : array array float;
means : array real;
covariance : array array real;
}
/**
......@@ -244,12 +244,12 @@ module de.evoal.generator.generator {
/**
* The distribution's expected value.
*/
'μ' : float;
'μ' : real;
/**
* The distribution's standard deviation.
*/
'σ' : float;
'σ' : real;
}
......
......@@ -10,6 +10,7 @@ import de.evoal.languages.model.dl.dsl.DefinitionLanguageStandaloneSetup;
import de.evoal.languages.model.mll.dsl.MachineLearningLanguageStandaloneSetup;
import de.evoal.languages.model.mll.MachineLearningModule;
import de.evoal.languages.model.mll.impl.MllPackageImpl;
import de.evoal.languages.model.utils.scoping.ClasspathGlobalScopeProvider;
import de.evoal.surrogate.api.SurrogateBlackboardEntries;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.emf.common.util.URI;
......@@ -75,6 +76,10 @@ public class MachineLearningModuleProducer {
private Optional<MachineLearningModule> read(final File modelFile) {
log.info("Reading model file {}.", modelFile);
final File folder = modelFile.getAbsoluteFile().getParentFile();
ClasspathGlobalScopeProvider.SEARCH_PATH.add(folder.toString());
log.info("Adding {} to search path.", folder);
final Injector injector = new MachineLearningLanguageStandaloneSetup().createInjectorAndDoEMFRegistration();
new DataDescriptionLanguageStandaloneSetup().createInjectorAndDoEMFRegistration();
new DefinitionLanguageStandaloneSetup().createInjectorAndDoEMFRegistration();
......
......@@ -29,6 +29,7 @@ module de.evoal.surrogate.api {
requires de.evoal.languages.model.instance;
requires de.evoal.core.ea;
requires com.google.guice;
requires de.evoal.languages.model.utils;
exports de.evoal.surrogate.api;
exports de.evoal.surrogate.api.function;
......
......@@ -7,4 +7,8 @@ module de.evoal.surrogate.simple {
requires de.evoal.core.main;
requires de.evoal.surrogate.api;
requires jakarta.inject.api;
exports de.evoal.surrogate.simple.identity to weld.core.impl;
exports de.evoal.surrogate.simple.linear to weld.core.impl;
exports de.evoal.surrogate.simple.quadratic to weld.core.impl;
}
......@@ -12,12 +12,12 @@ module de.evoal.surrogate.simple.ml {
}
type 'linear-regression' extends surrogate {
intercept : float;
slope : float;
intercept : real;
slope : real;
}
type 'simple-quadratic-regression' extends surrogate {
intercept : float;
slope : float;
intercept : real;
slope : real;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment