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

Added regression tests for all surrogate models provided by `surrogate.simple`...

Added regression tests for all surrogate models provided by `surrogate.simple` and `surrogate.smile`. Fixed minor bugs that prevented regression tests to work.

Closes #84
Resolve "Create regression tests for surrogate functions"
parent a55b6f51
No related branches found
No related tags found
2 merge requests!26Merge current develop into release,!18Resolve "Create regression tests for surrogate functions"
Pipeline #344732 passed
Showing
with 1257 additions and 11 deletions
......@@ -16,7 +16,7 @@ fi
cd "$1" || exit 1
POSITIONAL_ARGUMENTS=( "$@" )
POSITIONAL_ARGUMENTS=("${POSITIONAL_ARGUMENTS[@]:4}")
ADDITIONAL_ARGUMENTS=("${POSITIONAL_ARGUMENTS[@]:4}")
declare -a LOCAL_JVM_ARGUMENTS=()
......@@ -29,14 +29,14 @@ if [ ${EVOAL_DEBUG+x} ]; then
fi
if [ ${EVOAL_LOGGING+x} ]; then
POSITIONAL_ARGUMENTS+=( "-Bcore:logging=$EVOAL_LOGGING" )
ADDITIONAL_ARGUMENTS+=( "-Bcore:logging=$EVOAL_LOGGING" )
fi
set -x
java ${LOCAL_JVM_ARGUMENTS[@]} \
${EVOAL_JVM_ARGUMENTS[@]} \
${POSITIONAL_ARGUMENTS[@]} \
-Bcore:main=heuristic-search-evaluation \
"-Bcore:main=heuristic-search-evaluation" \
"-Bcore:optimisation-configuration-file=$2" \
"-Bcore:evaluation-output-folder=$3" \
"-Bcore:evaluation-iterations=$4"
"-Bcore:evaluation-iterations=$4" \
${ADDITIONAL_ARGUMENTS[@]}
......@@ -14,7 +14,7 @@ fi
cd "$1" || exit 1
POSITIONAL_ARGUMENTS=( "$@" )
POSITIONAL_ARGUMENTS=("${POSITIONAL_ARGUMENTS[@]:3}")
ADDITIONAL_ARGUMENTS=("${POSITIONAL_ARGUMENTS[@]:3}")
declare -a LOCAL_JVM_ARGUMENTS=()
......@@ -27,13 +27,13 @@ if [ ${EVOAL_DEBUG+x} ]; then
fi
if [ ${EVOAL_LOGGING+x} ]; then
POSITIONAL_ARGUMENTS+=( "-Bcore:logging=$EVOAL_LOGGING" )
ADDITIONAL_ARGUMENTS+=( "-Bcore:logging=$EVOAL_LOGGING" )
fi
set -x
java ${LOCAL_JVM_ARGUMENTS[@]} \
${EVOAL_JVM_ARGUMENTS[@]} \
${POSITIONAL_ARGUMENTS[@]} \
-Bcore:main=heuristic-search \
"-Bcore:main=heuristic-search" \
"-Bcore:optimisation-configuration-file=$2" \
"-Bcore:evaluation-output-folder=$3"
"-Bcore:evaluation-output-folder=$3" \
${ADDITIONAL_ARGUMENTS[@]}
......@@ -42,6 +42,11 @@ public class MachineLearningModuleProducer {
final File file = new File(configurationFile);
if(!file.exists()) {
log.info("Specified configuration file '{}' does not exist.", file);
throw new IllegalArgumentException("Please specify an existing mll file.");
}
if(!file.isFile()) {
log.info("Configured surrogate configuration is a folder.");
throw new IllegalArgumentException("Please specify a surrogate file.");
......
......@@ -10,7 +10,7 @@ import javax.inject.Inject;
import javax.inject.Named;
@Dependent
@Named("surrogate")
@Named("de.evoal.surrogate.optimisation.surrogate")
public class SurrogateFitnessFunction implements OptimisationFunction {
@Inject
......
#!/bin/sh
export EVOAL_HOME=$( cd -- "$(dirname $0)/../../" >/dev/null 2>&1 ; pwd -P )
$SHELL $EVOAL_HOME/bin/evoal-search.sh . search.ol output -Bsurrogate:configuration-file=training.mll -Bsurrogate:pre-trained=simple.pson
import "definitions" from de.evoal.core.math;
import "definitions" from de.evoal.core.optimisation;
import "definitions" from de.evoal.core.ea.optimisation;
import "definitions" from de.evoal.surrogate.optimisation;
import "data" from surrogate;
module search {
specify problem 'example-search' {
description := "Simple search";
'search-space' := [data 'x:0'];
'optimisation-space' := [data 'y:0', data 'y:1', data 'y:2'];
'maximise' := true;
'optimisation-function' := 'unknown-function' {};
}
configure 'evolutionary-algorithm' for 'example-search' {
'number-of-generations' := 10;
'size-of-population' := 50;
'maximum-age' := 10;
'offspring-fraction' := 0.6;
'initialisation' := 'random-population' {};
'comparator' := 'weighted-sum' {
'weights' := [1.0, 1.0, 1.0];
};
genotype := 'vector-genotype' {
chromosomes := [
'double-chromosome' {
genes:= [
gene {content:= data 'x:0';}
];
}
];
};
handlers := [];
selectors := selectors {
offspring := 'elite-selector' {
'size-factor' := 0.3;
'non-elite-selector' := 'tournament-selector' {
'size-factor' := 0.1;
};
};
survivor := 'elite-selector' {
'size-factor' := 0.3;
'non-elite-selector' := 'tournament-selector' {
'size-factor' := 0.1;
};
};
};
alterers := alterers {
crossover := [
'single-point-crossover' {
probability := 0.5;
}
];
mutator := [
'mean-alterer' {
probability := 0.5;
}
];
};
'optimisation-function' := 'surrogate' {};
}
}
\ No newline at end of file
{
"mappings" : [ {
"functions" : [ {
"inputDimensions" : [ "x:0" ],
"name" : "identity",
"outputDimensions" : [ "y:0" ],
"parameters" : [ ],
"state" : [ ],
"outputParameters" : { }
}, {
"inputDimensions" : [ "x:0" ],
"name" : "linear-regression",
"outputDimensions" : [ "y:1" ],
"parameters" : [ {
"name" : "intercept",
"value" : {
"type" : "double",
"value" : 0.0
}
}, {
"name" : "slope",
"value" : {
"type" : "double",
"value" : 1.0
}
} ],
"state" : [ {
"name" : "intercept",
"value" : {
"type" : "double",
"value" : 11.712570037202154
}
}, {
"name" : "slope",
"value" : {
"type" : "double",
"value" : -0.15365798063682554
}
}, {
"name" : "r²",
"value" : {
"type" : "double",
"value" : 0.025909832934437375
}
} ],
"outputParameters" : { }
}, {
"inputDimensions" : [ "x:0" ],
"name" : "simple-quadratic-regression",
"outputDimensions" : [ "y:2" ],
"parameters" : [ {
"name" : "intercept",
"value" : {
"type" : "double",
"value" : 0.0
}
}, {
"name" : "slope",
"value" : {
"type" : "double",
"value" : 1.0
}
} ],
"state" : [ {
"name" : "intercept",
"value" : {
"type" : "double",
"value" : 8.826315970399465
}
}, {
"name" : "slope",
"value" : {
"type" : "double",
"value" : 0.09933588719842316
}
}, {
"name" : "r²",
"value" : {
"type" : "double",
"value" : 0.5440278766948579
}
} ],
"outputParameters" : { }
} ],
"inputDimensions" : [ "x:0" ],
"name" : "transfer",
"outputDimensions" : [ "y:0", "y:1", "y:2" ]
} ],
"outputParameters" : {
"y:2" : [ {
"name" : "r²",
"value" : {
"type" : "double",
"value" : 0.5485875979279088
}
} ],
"y:1" : [ {
"name" : "r²",
"value" : {
"type" : "double",
"value" : 0.03565073460509294
}
} ],
"y:0" : [ {
"name" : "r²",
"value" : {
"type" : "double",
"value" : -7.063682935513912
}
} ]
}
}
\ No newline at end of file
module surrogate {
data:
/**
* Source dimension of the training data.
*/
quotient real data 'x:0';
/**
* Target dimension of the training data.
*/
quotient real data 'y:0';
/**
* Target dimension of the training data.
*/
quotient real data 'y:1';
/**
* Target dimension of the training data.
*/
quotient real data 'y:2';
}
\ No newline at end of file
import "definitions" from de.evoal.surrogate.ml;
import "definitions" from de.evoal.surrogate.simple.ml;
import "data" from surrogate;
module training {
prediction svr
maps 'x:0'
to 'y:0', 'y:1', 'y:2'
using
layer transfer
with
function 'identity'
mapping 'x:0'
to 'y:0'
function 'linear-regression'
mapping 'x:0'
to 'y:1'
with parameters
intercept := 0.0;
slope := 1.0;
function 'simple-quadratic-regression'
mapping 'x:0'
to 'y:2'
with parameters
intercept := 0.0;
slope := 1.0;
predict svr from "data.json"
and measure
'R²'();
end
and store to "simple.pson"
}
\ No newline at end of file
#!/bin/sh
export EVOAL_HOME=$( cd -- "$(dirname $0)/../../" >/dev/null 2>&1 ; pwd -P )
$SHELL $EVOAL_HOME/bin/evoal-training.sh . training.mll
module surrogate {
data:
/**
* Source dimension of the training data.
*/
quotient real data 'x:0';
/**
* Target dimension of the training data.
*/
quotient real data 'y:0';
/**
* Target dimension of the training data.
*/
quotient real data 'y:1';
/**
* Target dimension of the training data.
*/
quotient real data 'y:2';
}
\ No newline at end of file
import "definitions" from de.evoal.surrogate.ml;
import "definitions" from de.evoal.surrogate.simple.ml;
import "data" from surrogate;
module training {
prediction svr
maps 'x:0'
to 'y:0', 'y:1', 'y:2'
using
layer transfer
with
function 'identity'
mapping 'x:0'
to 'y:0'
function 'linear-regression'
mapping 'x:0'
to 'y:1'
with parameters
intercept := 0.0;
slope := 1.0;
function 'simple-quadratic-regression'
mapping 'x:0'
to 'y:2'
with parameters
intercept := 0.0;
slope := 1.0;
predict svr from "data.json"
and measure
'R²'();
end
and store to "simple.pson"
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ module de.evoal.surrogate.simple {
requires de.evoal.core.main;
requires de.evoal.surrogate.api;
opens de.evoal.surrogate.simple;
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;
......
#!/bin/sh
export EVOAL_HOME=$( cd -- "$(dirname $0)/../../" >/dev/null 2>&1 ; pwd -P )
$SHELL $EVOAL_HOME/bin/evoal-search.sh . search.ol output -Bsurrogate:configuration-file=training.mll -Bsurrogate:pre-trained=svr.pson
import "definitions" from de.evoal.core.math;
import "definitions" from de.evoal.core.optimisation;
import "definitions" from de.evoal.core.ea.optimisation;
import "definitions" from de.evoal.surrogate.optimisation;
import "data" from surrogate;
module search {
specify problem 'example-search' {
description := "Simple search";
'search-space' := [data 'x:0'];
'optimisation-space' := [data 'y:0', data 'y:1', data 'y:2', data 'y:3', data 'y:4', data 'y:5', data 'y:6', data 'y:7'];
'maximise' := true;
'optimisation-function' := 'unknown-function' {};
}
configure 'evolutionary-algorithm' for 'example-search' {
'number-of-generations' := 10;
'size-of-population' := 50;
'maximum-age' := 10;
'offspring-fraction' := 0.6;
'initialisation' := 'random-population' {};
'comparator' := 'weighted-sum' {
'weights' := [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
};
genotype := 'vector-genotype' {
chromosomes := [
'double-chromosome' {
genes:= [
gene {content:= data 'x:0';}
];
}
];
};
handlers := [];
selectors := selectors {
offspring := 'elite-selector' {
'size-factor' := 0.3;
'non-elite-selector' := 'tournament-selector' {
'size-factor' := 0.1;
};
};
survivor := 'elite-selector' {
'size-factor' := 0.3;
'non-elite-selector' := 'tournament-selector' {
'size-factor' := 0.1;
};
};
};
alterers := alterers {
crossover := [
'single-point-crossover' {
probability := 0.5;
}
];
mutator := [
'mean-alterer' {
probability := 0.5;
}
];
};
'optimisation-function' := 'surrogate' {};
}
}
\ No newline at end of file
module surrogate {
data:
/**
* Source dimension of the training data.
*/
quotient real data 'x:0';
/**
* Target dimension of the training data.
*/
quotient real data 'y:0';
/**
* Target dimension of the training data.
*/
quotient real data 'y:1';
/**
* Target dimension of the training data.
*/
quotient real data 'y:2';
/**
* Target dimension of the training data.
*/
quotient real data 'y:3';
/**
* Target dimension of the training data.
*/
quotient real data 'y:4';
/**
* Target dimension of the training data.
*/
quotient real data 'y:5';
/**
* Target dimension of the training data.
*/
quotient real data 'y:6';
/**
* Target dimension of the training data.
*/
quotient real data 'y:7';
}
\ 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