Commit c1b0360d authored by Sam Thiriot's avatar Sam Thiriot
Browse files

added test functions for NSGA2: CPT1, ConstrEx and Schaffer N1

parent 0e9bc71f
...@@ -32,3 +32,5 @@ All the accepted submissions will be part of the market place and will be compil ...@@ -32,3 +32,5 @@ All the accepted submissions will be part of the market place and will be compil
- [SimPopLocal model](simpoplocal): a geographical model calibrated using genetic algorithms. - [SimPopLocal model](simpoplocal): a geographical model calibrated using genetic algorithms.
[Sensitivity-Screening analysis](sensitivity/morris): a method to quickly analyze which inputs are influential on large spaces of parameters. [Sensitivity-Screening analysis](sensitivity/morris): a method to quickly analyze which inputs are influential on large spaces of parameters.
[Global Sensitivity Analysis](sensitivity/saltelli): a variance based sensitivity analysis of model output. [Global Sensitivity Analysis](sensitivity/saltelli): a variance based sensitivity analysis of model output.
- [Test Functions for NSGA2](nsga2-test-functions): reference functions to double check the correctedness of the NSGA2 algorithm, and also view examples of usage of NSGA2
# Test Functions for NSGA2
## Why Test?
Metaheuristics for optimization such as genetic algorithms leave a huge freedom to developers for their implementation.
Genetic Algorithms such as NSGA2 are even less trivial.
Their implementation in the [mgo](https://github.com/openmole/mgo) used in [OpenMole](https://openmole.org/) was adapted so they are efficient for computation on clusters or grids.
This leaves a lot of uncertainty to the user on what really happens.
Why should you, as a user, trust this implementation?
The answer is simple: you should not.
Any implementation in scientific computing should be verified.
## Test Functions
Many functions named "Test Functions" were proposed over time to test and compare multi-objective optimization algorithmls.
The [wikipedia page](https://en.wikipedia.org/wiki/Test_functions_for_optimization) lists several of them.
A test function is an optimization function which you can propose as the problem to optimize to your implementation.
Functions test:
- problems with multiple parameters and multiple objectives
- problems with constraints: a part of the space of parameter leads to computation errors as a result, so the algorithm should achieve to deal with it
- problems with parts of the space of solution that are tricky to detect, either because they are statistically unlikely to find, or because they are is a part of the space of solutions which is heavily constrained, etc.
Test tunctions enable the testing of several aspects including:
- coverage of the Pareto front,
- speed of convergence
Once a test function was explored by an implementation of an algorithm, you should compare the Pareto front obtained withou your implementation with the one expected in literature.
## Test and Learn
Test functions have another role: they constitute a simple example of optimization problem.
As a user, you can also learn to tune the parameters of the genetic algorithm as check when convergence
occurs.
## Test Workflows for OpenMole
We provide here a few examples of test functions which you can open with OpenMole.
For each workflow:
- Choose a test function.
- Run the workflow.
- Open the files with the solutions, check you understand them.
- Graph them and compare them with the literature.
//model inputs
val x = Val[Double]
val y = Val[Double]
//model outputs
val f1 = Val[Double]
val f2 = Val[Double]
val testFunctionCPT1 =
ScalaTask("""
val f1 = x;
val f2 = (1 + y) * Math.exp( -x / (1 + y) );
""") set (
inputs += x,
inputs += y,
outputs += f1,
outputs += f2
)
val evolutionCPT1 =
NSGA2Evolution(
genome = Seq(
x in (0.0, 10000.0),
y in (-10000.0, 1.0)
),
objective = Seq(f1, f2),
evaluation = testFunctionCPT1,
parallelism = 10,
termination = 1000
)
val savePopulation = SavePopulationHook(evolutionCPT1, workDirectory/"results/CPT1")
evolutionCPT1 hook savePopulation on LocalEnvironment(4)
//model inputs
val x = Val[Double]
val y = Val[Double]
//model outputs
val f1 = Val[Double]
val f2 = Val[Double]
val testFunctionConstrEx =
ScalaTask("""
val f1 = x;
val f2 = (1 + y) / x;
""") set (
inputs += x,
inputs += y,
outputs += f1,
outputs += f2
)
val evolutionConstrEx =
NSGA2Evolution(
genome = Seq(
x in (0.1, 1.0),
y in (0.0, 1.0)
),
objective = Seq(f1, f2),
evaluation = testFunctionConstrEx,
parallelism = 10,
termination = 1000
)
val savePopulation = SavePopulationHook(evolutionConstrEx, workDirectory/"results/ConstrEx")
evolutionConstrEx on LocalEnvironment(4) hook savePopulation
//model inputs
val x = Val[Double]
//model outputs
val f1 = Val[Double]
val f2 = Val[Double]
// explored space
val A = 1000.0 // up to 10^5
val testFunctionSchafferN1 =
ScalaTask("""
val f1 = Math.pow(x, 2);
val f2 = Math.pow(x - 2, 2);
""") set (
inputs += x,
outputs += f1,
outputs += f2
)
val evolutionSchafferN1 =
NSGA2Evolution(
genome = Seq(
x in (-A, A)
),
objective = Seq(f1, f2),
evaluation = testFunctionSchafferN1,
parallelism = 10,
termination = 1000
)
val savePopulation = SavePopulationHook(evolutionSchafferN1, workDirectory/"results/SchafferN1")
evolutionSchafferN1 hook savePopulation on LocalEnvironment(4)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment