Optimisation Language

An Optimisation Language file describes an optimisation problem and configures one or more algorithms to solve it. The optimisation language use the .ol file ending.

When to Use the Optimisation Language

Use the Optimisation Language when you want to:

  • Define an optimisation problem by specifying its search and optimisation space
  • Configure an optimisation algorithm such as an evolutionary algorithm, particle swarm optimisation, or local search
  • Connect a surrogate model to act as the optimisation function when the real function is unknown or too expensive to evaluate

Basic Structure

An OL file consists of imports and a module. The module contains a problem specification, an algorithm configuration, or both:

import "definitions" from de.evoal.optimisation.core;

module com.example {
  specify problem 'my-problem' {
    // problem definition
  }

  configure 'some-algorithm' for 'my-problem' {
    // algorithm configuration
  }
}

The problem of a search is the problem of its algorithm configuration (for 'my-problem'). A module that specifies one problem and configures its algorithm for another one is rejected.

Problem and Configuration in Separate Modules

The problem can be specified in a module of its own, so several algorithm configurations can share it. Shared problem modules and their data are kept in a library folder, here lib, that is added to the search path:

// file lib/problems/sphere.ol
import "definitions" from 'de.evoal.optimisation.core';
import "data" from 'problems.variables';

module problems.sphere {
  specify problem 'sphere' {
    // problem definition
  }
}
// file search.ol
import "definitions" from 'de.evoal.optimisation.core';
import "data" from 'problems.variables';
import "optimisation" from 'problems.sphere';

module search {
  configure 'some-algorithm' for 'sphere' {
    // algorithm configuration
  }
}
$EVOAL_HOME/bin/evoal-search.sh . search.ol output -Bcore:search-path=lib
  • An import names a file by its qualified name: 'problems.sphere' with "optimisation" is problems/sphere.ol, 'problems.variables' with "data" is problems/variables.ddl. The file is searched in the working directory, then in the entries of core:search-path (separated by the path separator of the platform), then on the classpath, i.e. in the jars of the plugins. Keep imported modules in folders below a search path entry rather than in subfolders of the working directory: a module in a subfolder of the working directory does not find its own imports.
  • Write the imported name in single quotes. Unquoted, a keyword in the name cuts it short: import "data" from problems.data; imports problems.ddl, while import "data" from 'problems.data'; imports problems/data.ddl. A module whose name contains a keyword is declared with quotes as well: module 'problems.data' { … }.
  • The algorithm refers to the problem by its name ('sphere') or by its qualified name (problems.sphere.'sphere'). A name that cannot be resolved stops the search with “Couldn’t resolve reference to ProblemInstance …”.
  • The configuration module imports the data itself if it names features, e.g. in a genotype or in start candidates.
  • A plugin that ships problem modules has to open their package in its module-info.java (opens problems;), like the packages of its DL files.

Specifying the Problem

The specify problem block defines the optimisation problem. It has three required parts:

specify problem 'example-search' {
  search for data 'x:0'

  map with 'some-function' { ... }

  and maximise data 'y:0'
}
  • search for — the data dimensions that form the search space, i.e. the variables the algorithm will adjust. Multiple dimensions are separated by commas
  • map with — the function used to evaluate candidates. This maps the search space to the optimisation space
  • and maximise / and minimise — the data dimension to optimise, and whether it should be maximised or minimised

Instead of maximising or minimising, a goal can bring an objective as close as possible to a target value. The distance from the target is minimised:

and optimise data 'y:0' towards 3.0 with distance {}
Distance Value
distance abs(v - t)
'squared-distance' (v - t)^2; large deviations count more than small ones
'relative-distance' abs(v - t) / max(abs(t), scale); scale (default 1.0, greater than 0) is the smallest denominator, so a target of 0 is measured absolutely in units of scale

With towards target instead of a number, the target is taken from the target points of a search evaluation (evoal-evaluate-search.sh with -Boptimisation:target-points-file=<file>): every target point is searched for separately.

and optimise data 'y:0' towards target with 'relative-distance' { scale := 2.0; }

The search and optimisation space data references data specified in a .ddl file.

Optimisation Functions

The map with clause specifies how candidates are evaluated. The following functions appear in the examples:

Benchmark Function

Uses a known benchmark function to evaluate candidates. Multiple benchmark configurations can be provided:

map with 'benchmark-function' {
  'benchmarks' := [
    'benchmark-configuration' {
      function := ackley {};
      reads    := [data 'x:0'];
      writes   := [data 'y:0'];
    }
  ];
}

Available benchmark functions include ackley and rosenbrock, among others. The required import is de.evoal.pipeline.benchmarks.

Unknown Function

Used when the optimisation function is not known directly and will be provided by a surrogate model configured in the algorithm block:

map with 'unknown-function' {}

Configuring an Algorithm

The configure block selects an algorithm and provides its parameters as key-value pairs. The algorithm is linked to a problem by name:

configure 'some-algorithm' for 'example-search' {
  // parameters
}

Initialisation Strategies

All algorithms require an initialisation strategy that determines the starting population or candidate. Here, we introduce two examples:

Random Population

Generates an initial population of candidates randomly within the search space:

'initialisation' := 'random-population' {};

Specify Candidates

Provides an explicit list of starting candidates ('candidate-list', at least one). The random flag (default true) controls whether the candidates are drawn randomly from the list, with repetition, or always taken in order, starting again after the last one:

'initialisation' := 'specify-candidates' {
  'candidate-list' := [
    'candidate' {
      'values' := [
        'variable' { var := data 'x:0'; val := 1.0; },
        'variable' { var := data 'x:1'; val := 5.0; }
      ];
    }
  ];
  'random' := false;
};

Candidates from a File

'candidates-from-file' takes the starting candidates from the file 'candidate-file', read by the reader of its extension (e.g. .json); random works as for 'specify-candidates':

'initialisation' := 'candidates-from-file' { 'candidate-file' := "start.json"; };

Stopping Criteria

All algorithms require at least one stopping criterion, e.g. by terminating after a given number of iterations/generations:

'stopping-criteria' := [
  'iteration-count' { 'maximum-iterations' := 200; }
];

If several criteria are listed, the search stops as soon as one of them is met:

Criterion Stops
iteration-count After maximum-iterations iterations (the initial evaluation is iteration 0)
evaluation-budget When maximum-evaluations evaluations have been counted (counted-evaluations: real ones by default)
file-check When the file file (default evoal-stop.txt) exists in the working folder
target-value When the best candidate so far reaches the value target of the objective objective
stagnation When a measure of the fitness has not improved for iterations iterations
all-of When all of its criteria are met
any-of When at least one of its criteria is met

The example stopping-criteria compares the iteration count with the evaluation budget.

evaluation-budget counts the evaluations of the real optimisation function by default ('counted-evaluations' := 'evaluation-count.real'). A search on a surrogate model only makes predictions, so its budget counts them with 'evaluation-count.surrogate'. Otherwise the budget is never used up and the search never stops. 'evaluation-count.all' counts both together, e.g. if a study prescribes one budget for real evaluations and predictions. An evaluation of a mixed-function (see below) counts once for every source of its parts, e.g. as one real evaluation and one prediction, so it uses 2 of a budget on 'evaluation-count.all'. Budgets with different counted evaluations can be combined, and the first one that is used up stops the search:

'stopping-criteria' := [
  'evaluation-budget' { 'maximum-evaluations' := 300; 'counted-evaluations' := 'evaluation-count.surrogate'; }
];

target-value measures how many iterations and evaluations an algorithm needs to get close to a known optimum, e.g. “stop after 1000 iterations or as soon as y:0 is below 0.001”:

'stopping-criteria' := [
  'iteration-count' { 'maximum-iterations' := 1000; },
  'target-value' { 'objective' := data 'y:0'; 'target' := 0.001; }
];
  • The problem needs a goal for the objective. The target is given in the units of the objective and compared in the direction of the goal: the value has to be below the target for minimise, above it for maximise, and closer to the goal’s target for towards.
  • The target is reached only if the value is strictly better, as in the COCO benchmarks. A target equal to the optimum (e.g. 0 for a function whose minimum is 0) is never reached; use the optimum plus a precision instead.
  • The criterion reads the best candidate found so far, so it also works for algorithms that move to worse candidates, such as simulated annealing. An infeasible candidate (one that violates a constraint of the problem) never reaches the target.
  • With several goals, the best candidate so far is the one the comparator prefers; the run stops only if this candidate reaches the target in the given objective.

The local search examples (local-search-hill-climbing, local-search-simulated-annealing, local-search-threshold-accepting) and the examples random-search and pso-basic use it to show how many iterations and evaluations each algorithm needs.

stagnation stops a run that no longer makes progress, e.g. “stop when the best fitness has not improved by more than 1 % for 5 iterations”:

'stagnation' {
  'iterations'         := 5;
  'relative-tolerance' := 0.01;
  'measure'            := 'best-fitness' {};
}
  • The measure is computed from the recorded fitness of every iteration, where smaller is better: 'best-fitness' is the smallest fitness of the best candidates (rank 0, as chosen by the comparator, e.g. feasible ones first), 'mean-fitness' the mean fitness of the population. Plugins can add further measures. These are the criteria ImpBest and ImpAv of K. Zielinski, P. Weitkemper, R. Laur, K.-D. Kammeyer: Examination of Stopping Criteria for Differential Evolution based on a Power Allocation Problem (OPTIM 2006).
  • Iteration 0 sets the reference value. An iteration improves if its value is below the reference by more than the tolerance, the larger of 'absolute-tolerance' and 'relative-tolerance' times the magnitude of the reference (both default to 0). An improvement becomes the new reference, so small improvements add up until they exceed the tolerance.
  • The measures need a fitness with one component. With several goals, add a scalarisation such as 'weighted-sum' to the 'fitness-pipeline'; otherwise the configuration is rejected.

all-of and any-of combine criteria and can be nested. Both check every criterion in every iteration. For example, “stop after at most 500 iterations, or when the mean fitness stagnates, but not before iteration 20”:

'stopping-criteria' := [
  'iteration-count' { 'maximum-iterations' := 500; },
  'all-of' {
    'criteria' := [
      'stagnation' { 'iterations' := 5; 'relative-tolerance' := 0.01; 'measure' := 'mean-fitness' {}; },
      'iteration-count' { 'maximum-iterations' := 20; }
    ];
  }
];

Fitness and Comparators

The algorithms compare candidates by their fitness, not by the objectives directly. The fitness has one component per goal, and smaller is always better: a minimised objective is its own fitness, a maximised one is negated, and a target goal contributes its distance from the target. The steps configured in 'fitness-pipeline' then change the fitness in their order. The comparator finally compares the fitness of two candidates.

Step Effect
scaling Divides components by a reference value (f / r, r > 0); unlisted components stay unchanged
objective-selection Keeps the component of objective and drops all others
weighted-sum Reduces the fitness to one component weighted-sum: the sum of the components multiplied by their weights
tchebycheff Reduces the fitness to one component tchebycheff: the largest weighted difference of a component from its reference value, max_i w_i (f_i - z_i)
augmented-tchebycheff Like tchebycheff, plus augmentation times the unweighted sum of the differences, max_i w_i (f_i - z_i) + augmentation * sum_i (f_i - z_i)
constraint-penalty Adds weight times the violation of a constraint group to every component (see Constraints)

weighted-sum is a scalarisation: it must be the last step, and a pipeline has at most one. weights lists every component exactly once, also if all components have the same weight; weights are not negative and at least one is greater than 0. With normalise := true (the default), the weights are divided by their sum, which only changes the scale of the fitness, not the order of the candidates. The scale matters for simulated annealing and threshold accepting, which compare fitness differences.

A weighted sum cannot find candidates on a part of the Pareto front that is not convex, whatever the weights are (Das and Dennis 1997, https://doi.org/10.1007/BF01197559). The Tchebycheff scalarisations can (Miettinen 1998, https://doi.org/10.1007/978-1-4615-5563-6). They are scalarisations, too, so they must be the last step:

  • weights lists every component exactly once, as for weighted-sum. There is no normalise.
  • 'reference-point' lists the reference value z_i of every component exactly once. The values are in the units of the fitness the step gets: in the canonical direction (a maximised objective with the best value 2 has the reference value -2) and after the steps before it, e.g. scaling. Usually it is the ideal point, the best value of every component, or a point slightly better than that. Another point works as an aspiration level. The reference point is fixed during the run, because the fitness of a candidate is computed once and compared with later candidates.
  • tchebycheff finds weakly Pareto-optimal candidates: a candidate that is worse in a component with a small weight can have the same value. 'augmented-tchebycheff' adds the unweighted sum of the differences, multiplied by a small augmentation such as 0.001 (Steuer and Choo 1983, https://doi.org/10.1007/BF02591870). Its best candidates are Pareto-optimal. A suitable augmentation depends on the scale of the components, so it has no default.
'comparator' := 'numeric-comparator' {};
'fitness-pipeline' := [
  'augmented-tchebycheff' {
    weights := [
      'variable' { var := data 'f:1'; val := 0.5; },
      'variable' { var := data 'f:2'; val := 0.5; }
    ];
    'reference-point' := [
      'variable' { var := data 'f:1'; val := 0.0; },
      'variable' { var := data 'f:2'; val := 0.0; }
    ];
    augmentation := 0.001;
  }
];
'comparator' := 'numeric-comparator' {};
'fitness-pipeline' := [
  scaling {
    references := ['variable' { var := data 'y:0'; val := 100.0; }];
  },
  'weighted-sum' {
    weights := [
      'variable' { var := data 'y:0'; val := 2.0; },
      'variable' { var := data 'y:1'; val := 1.0; }
    ];
  }
];
Comparator Compares
numeric-comparator The only fitness component (one goal, or after a scalarisation or objective-selection)
hierarchical-comparator The components of the objectives in order: the next one only if the previous ones are equal
crowded-comparator All components by Pareto dominance; the selections compare by front and crowding distance (NSGA-II, evolutionary algorithm only, see below)
feasibility-comparator The only component, after the feasibility rules of a constraint group (see Constraints)
epsilon-comparator Like feasibility-comparator, but a violation up to epsilon counts as feasible

The former comparator 'weighted-sum' is replaced by the step of the same name. The former 'epsilon-comparator' { 'goal-objective' := data 'y'; }, which compared one objective, becomes 'comparator' := 'numeric-comparator' {}; with 'fitness-pipeline' := ['objective-selection' { objective := data 'y'; }];; the name 'epsilon-comparator' now denotes the epsilon-level comparison of constraint violations.

Evaluation Strategies

'evaluation-strategy' says how often the optimisation function is called for a candidate. It is an option of every algorithm; without it, every candidate is evaluated once. Every call counts as one evaluation of the budget. A strategy with several samples aggregates the objectives of a candidate before the fitness pipeline, so the constraints, the pipeline, the comparator and the stopping criteria see the aggregated objectives. Averaging and re-evaluation are the usual remedies for noisy objectives (Jin and Branke 2005, https://doi.org/10.1109/TEVC.2005.846356).

Strategy Evaluations of a candidate
'single-evaluation' {} once (the default)
'resampling' { samples := n; } n times when it is new; its objectives are the aggregate of the samples
're-evaluation' { samples := n; } n times when it is new and once more at the start of every iteration it stays in the population; its objectives are the aggregate of all its samples so far, so a lucky sample does not keep it in the population. Only the evolutionary algorithm and local search carry candidates over and support it

aggregation chooses the aggregate of the samples: 'sample-aggregation.mean' (the default) or 'sample-aggregation.median'. The memory model records the number of samples (samples) and the sample standard deviation of every objective (objective-standard-deviations) of a candidate; a re-evaluated member is related to its previous individual with the property re-evaluated.

'evaluation-strategy' := 'resampling' { samples := 5; aggregation := 'sample-aggregation.median'; };

The Best Candidate So Far under Noise

With several samples, 'best-so-far' of 'resampling' and 're-evaluation' decides how the best candidate so far is chosen. The writer best-candidate-so-far, the memory model (bestSoFar), 'model-xmi' with 'model-candidates.best-so-far' and the stopping criterion 'target-value' follow it. Only members of the population compete, as with a single evaluation.

Rule The best candidate so far is
'best-record' {} the member with the best value ever recorded (the default). A candidate whose first samples were lucky stays the best candidate so far after a re-evaluation has corrected its value
'best-current-estimate' { 'minimum-samples' := m; } the candidate with the best latest value, among the candidates with at least m samples (default 1). A re-evaluated member replaces the value of its earlier individuals, so the best candidate so far can change to another candidate
'best-confidence-bound' { weight := k; 'minimum-samples' := m; } the candidate with the best pessimistic bound of its latest value, among the candidates with at least m samples (default 2)

A candidate that has left the population keeps its last value. A member that is re-evaluated and leaves the population in the same iteration keeps the value of this re-evaluation. Until a candidate has 'minimum-samples' samples, it does not compete, and an iteration without a competing candidate has no best candidate so far. With 'resampling', the value of a candidate never changes, so only 'best-confidence-bound' differs from 'best-record'.

The bound of 'best-confidence-bound' is computed per component of the canonical fitness (smaller is better): the fitness plus k times the standard error s/√n, where s is the sample standard deviation of the component over the fitness of the n single samples. A candidate that was evaluated once with a lucky value then loses against one with many samples. Ranking by such a bound is a usual way to select the best system under noise (Kim and Nelson 2006, https://doi.org/10.1016/S0927-0507%2806%2913017-0). For the median, s/√n underestimates the standard error (by a factor of about 1.25 for normal noise). The memory model records the bound of every individual with at least two samples (fitness-bound). The weight has no default: weight := 2.0 gives a bound that a normally distributed estimate exceeds with a probability of about 2.3 %.

'evaluation-strategy' := 're-evaluation' {
    'best-so-far' := 'best-confidence-bound' { weight := 2.0; 'minimum-samples' := 3; };
};

The function 'noisy-function' (see below) adds noise to another function, e.g. to test a strategy on a benchmark function. The example ea-noisy-evaluation compares the strategies on a noisy function.

Candidate Checks

'candidate-checks' lists tests on candidates. Each check has a reaction to a candidate that fails it:

Reaction Effect
check-reaction.warn The failure is logged; the candidate stays
check-reaction.replace A new candidate takes the place of the failed one
check-reaction.resample The variation of the failed candidate is redone, at most 'maximum-attempts' times (checks of new candidates in the evolutionary algorithm and CMA-ES)
check-reaction.repair The repair strategy of the check changes the candidate, at most 'maximum-attempts' times; then its 'repair-fallback' reacts

A configuration with a reaction that the check does not support is rejected when it is loaded.

Every check type has a check point: checks of new candidates run before the candidates are evaluated (in the evolutionary algorithm also on the initial population, where resample takes the next candidate of the 'initialisation'), population checks run at the end of every iteration. An algorithm that does not offer the check point of a configured check rejects the configuration. The evolutionary algorithm offers both check points, local search offers population checks; CMA-ES offers checks of new candidates with the reactions warn and resample (a candidate that is not a sample of its distribution would bias its update); random search and particle swarm optimisation offer none yet.

Replacements come from 'replacement-source' (any initialisation strategy; default 'random-population' {}). With 'random-population' every replacement is a new random candidate; 'specify-candidates' and 'candidates-from-file' repeat their candidates, which the log warns about.

Check Check point Reactions Fails a candidate
maximum-age population warn, replace that stayed unchanged for more than iterations iterations
constraint-check new candidates all four that violates a constraint of its group (see Constraints)
maximum-size new candidates all four with a model of more objects than size (see models)
maximum-depth new candidates all four with a model deeper than depth; the root of a model has depth 0
uses-variable new candidates warn, replace, resample whose expression uses fewer than count different variables (see Genetic Programming)

maximum-size and maximum-depth test every model of the search space; repair replaces the parts of a model that are too large or too deep by the smallest subtrees that fit their places (“minimal-subtree repair”) and falls back to its 'repair-fallback' after 'maximum-attempts'.

In a local search, maximum-age with replace is a random restart: the current candidate is replaced after iterations + 1 iterations without an accepted neighbour. Hill climbing and threshold accepting already stop at the first iteration without an accepted neighbour, so the check acts with simulated annealing:

'candidate-checks' := [
  'maximum-age' {
    iterations := 3;
    reaction := 'check-reaction.replace';
    'replacement-source' := 'random-population' {};
  }
];

Constraints

The constraints are declared in the DDL with a group, e.g. constraint(data 'x:0' + data 'x:1' >= 1.0, "budget"); (see the Data Definition Language). The constraints sections of two kinds of DDL modules belong to a problem: those of the modules that declare its features, and those of every module that the OL module specifying the problem imports with import "data" from …;, even if the module declares no data, e.g. a module of correlations estimated from data (see Modules of Constraints). The imports of a module that only configures the algorithm for an imported problem do not count. The algorithm measures every constraint of every evaluated candidate with its 'constraint-measure'; the optimisation function is not called again, so the evaluation budget does not change.

Measure Degree of violation
exact-measure max(0, -g) for an inequality g >= 0, max(0, abs(g) - 'equality-tolerance') for an equality (the default)
tolerance-measure The smallest degree when every feature with a 'standard-deviation' is moved by -factor, 0 or +factor times it

A degree of 0 means satisfied. The violation of a group is the sum of the degrees of its constraints. Strict and non-strict comparisons are measured alike. The default 'equality-tolerance' is 1.0e-4.

Every group is handled by the configuration. A group that the configuration names but the DDL does not declare is rejected; a group that nothing handles is reported as a warning.

Handling Where Effect
constraint-check { group; reaction; ... } 'candidate-checks' Tests new candidates before their evaluation; only groups without constraints on objectives
constraint-penalty { group; weight; } 'fitness-pipeline' Static penalty: adds weight times the violation to every fitness component
feasibility-comparator { group; } 'comparator' Feasible before infeasible; two feasible by fitness, two infeasible by violation (K. Deb, 2000)
epsilon-comparator { group; epsilon; } 'comparator' Like the feasibility rules, but a violation up to epsilon counts as feasible, and equal violations are compared by fitness (Takahama and Sakai, 2006)
nsga2-selection { group; } replacement of the EA Constrained domination in the non-dominated sorting (Deb et al., 2002)
stochastic-ranking-selection { group; } selections of the EA Stochastic ranking: neighbours are compared by fitness with probability 'fitness-probability' (or if both are feasible), otherwise by violation (Runarsson and Yao, 2000)

The repair strategies of constraint-check (reaction repair):

Repair Constraints Effect
saturation-repair linear in one search feature A violated bound sets the feature to the bound; an integer feature takes the nearest integer on the feasible side, one step inside a strict bound
projection-repair linear in the search features Projects the candidate onto every violated constraint once per attempt, in the order of the DDL (S. Agmon, 1954)

Both round integer features and move the values into the bounds of the DDL. If the candidate still fails after 'maximum-attempts' attempts, 'repair-fallback' reacts (warn, the default, keeps the unrepaired candidate; replace; resample).

'candidate-checks' := [
  'constraint-check' {
    group := "budget";
    reaction := 'check-reaction.repair';
    repair := 'projection-repair' {};
    'repair-fallback' := 'check-reaction.replace';
    'maximum-attempts' := 3;
  }
];
'fitness-pipeline' := [ 'constraint-penalty' { group := "vague"; weight := 10.0; } ];

The examples ea-constraints, search-with-benchmark, search-with-benchmark-and-training and search-with-benchmark-and-target show the handlings; the README of de.evoal.optimisation.api gives the details and the references.

Documentation

The document parameter controls what information is recorded during the run. Multiple documentation targets can be listed:

document := [
  'best-candidate-per-iteration' {},
  'candidates-per-iteration' {}
];
Writer Output Content
best-candidate-per-iteration best-candidate-per-iteration.csv The best candidates (rank 0) of every iteration
best-candidate-so-far best-candidate-so-far.csv The best candidate found up to and including every iteration
candidates-per-iteration candidates-per-iteration.csv All candidates of every iteration
metrics-per-iteration metrics-per-iteration.csv The metrics of every iteration, e.g., the number of evaluations
constraint-statistics constraint-statistics.csv Per iteration and constraint group: the number of infeasible candidates and the sum of their violations
correlation-statistics correlation-statistics.csv Per iteration and correlation of the DDL: the empirical correlation of the candidates in its ranges and its deviation from the declared one
learned-linkage learned-linkage.csv Per iteration, correlation and building block of the DDL: the correlations the covariance matrix of CMA-ES implies, compared with the declared ones (see CMA-ES)
linkage-statistics linkage-statistics.csv Per iteration, building block and correlation of the DDL: how often the recombinations of the evolutionary algorithm preserve it (see below)
memory-model memory-model/*.json The whole run: candidates with objectives and fitness, their origin, ranks, metrics, and the best candidate so far (bestSoFar)
model-xmi models/<data>/*.xmi The models of structured data of an Ecore metamodel as XMI files (see below)
reference-values-per-individual reference-values-per-individual.csv The values of a reference function at the candidates of candidates-per-iteration (see below)
stopping-per-candidates-per-generation stopping-per-candidates-per-generation.csv Per iteration: which of the given stopping criteria are satisfied (1 or 0)
stopping-per-candidates-per-iteration stopping-per-candidates-per-iteration.csv Per iteration and candidate: which of the given candidate-based stopping criteria are satisfied
none nothing Disables the output

The CSV writers show the objectives (the output of the optimisation function). The memory-model writer also records the fitness that the algorithm compared: one value per component, where smaller is better. A minimised objective is its own fitness, a maximised one appears negated, and a target goal contributes its distance from the target. The fitness components and the steps configured in 'fitness-pipeline' are listed in execution-information.json, and every target goal there states its target and its distance (DL type and attribute values, e.g. the scale of 'relative-distance').

execution-information.json also holds the whole configuration of the run, so analysis tools do not have to read the OL file: algorithm (the configure block), problem.function (the map with function) and documentation (the writers of the problem, then those of the algorithm block). Each is written as its fully qualified DL type and the values of all its attributes in their order (inherited ones first), with the default values applied. Excerpt of the regression hill-climbing-weighted-sum:

"algorithm" : {
  "type" : "de.evoal.optimisation.local_search.optimisation.local-search",
  "attributes" : {
    "initialisation" : {
      "type" : "de.evoal.optimisation.core.specify-candidates",
      "attributes" : { "candidate-list" : [ … ], "random" : false }
    },
    …
    "stopping-criteria" : [ {
      "type" : "de.evoal.optimisation.core.iteration-count",
      "attributes" : { "maximum-iterations" : 10 }
    } ],
    …
    "accepting-strategy" : {
      "type" : "de.evoal.optimisation.local_search.optimisation.hill-climber",
      "attributes" : { }
    }
  }
},
"documentation" : [ …, {
  "type" : "de.evoal.optimisation.core.memory-model",
  "attributes" : { "steps" : false }
} ]

Nested instances are written the same way, data by its name, enum literals by name and expressions as their source text. An optional attribute without a value is null, an array without a value is empty ([]). File names, e.g. 'candidate-file', are written as in the OL file; the files themselves are not copied.

The memory-model writer has one option, 'steps', which selects one of two versions of the memory model. Both versions use the same individual ids. The run records the steps only if a writer writes them, so a run without 'steps' := true is faster.

  • Final ('steps' := false, the default): an iteration holds its ranked members, and every member is related to the individuals of the previous iteration it came from. The steps of iteration-<n>.json are empty. The best candidate so far (bestSoFar) can be one that is no member of any iteration, e.g. a candidate that was re-evaluated and then left the population (see 'best-so-far' of the evaluation strategies). The first iteration that names it then also holds it, after its members, so both versions contain every individual that bestSoFar names.
  • Steps ('steps' := true): every executed step of an iteration is listed with the ids of its outputs, e.g. Selection: select 10 parents by tournament-selection with the selected members, Adaption: recombine 5 pairs with the recombined children, FitnessCalculation: evaluate the candidates with the evaluated ones, or Acceptance: … with the next population. The individuals of the iteration also contain these outputs, and every individual is related to its direct predecessor, which may belong to the same iteration (e.g. a mutated child to its recombined child). A candidate that was created but not evaluated, e.g. because the evaluation budget ran out, has an empty output. Algorithms whose candidates stay inside the algorithm, e.g. the particles of a swarm, record their steps without outputs.
document ['memory-model' { 'steps' := true; }].

Besides the relationship to where a member came from, an algorithm can record influences: a relationship of the kind influence names individuals of any earlier iteration that influenced how the member was created without being its predecessors, e.g. the personal bests that pulled a particle (see PSO). The member is not derived from them. The role of the targets is the property role of the relationship, e.g. "kind": "influence" with "properties": {"role": "personal-best"}. The steps version records the same influences as the final version.

correlation-statistics needs correlations in the DDL and has two options. 'empirical-correlation' (default true) writes, for the n-th correlation, the number of candidates inside its ranges (n-<n>), their Pearson correlation, or the Spearman rank correlation if a feature is ordinal (correlation-<n>), and the empirical minus the declared coefficient (deviation-<n>). 'covariance-difference' (default false) writes the covariance in the population minus the one in the initial population (covariance-difference-<n>). A value that cannot be computed, e.g. with fewer than two candidates in the ranges, is empty.

A replacement by a candidate check is recorded as a relationship of the kind replacement to the candidate it replaced, with the property reason, e.g. maximum-age: age 4 exceeds 3 iterations; the check itself is a step of the kind Check. The properties are declared in propertyDefinitions of execution-information.json. A resampled candidate has the property attempts; a repaired candidate keeps the relationship of the failed one (e.g., to its parents) with the properties repair and attempts. With constraints, every individual has the property violation-<n>, the degree of violation of the n-th constraint of the DDL, and the metric constraint-evaluations counts the measured constraints.

model-xmi writes the models of structured search data whose classes come from an Ecore metamodel (@EcoreType, see the Data Definition Language) as XMI files, one per candidate: models/<data>/<iteration>-<individual id>.xmi. candidates chooses them: 'model-candidates.all' (every candidate of every iteration), 'model-candidates.best-per-iteration' (the best candidates of every iteration) or 'model-candidates.best-so-far' (the best candidate so far, written only when it changes, so the last file is the result of the run). A file holds only the model; its fitness is in the memory model under the same iteration and individual id. The files have no schema location: a reader registers the packages of the metamodel by their namespace URIs. Models of DL types are written by the memory model only.

document ['memory-model' {}, 'model-xmi' { feature := data 'policy'; candidates := 'model-candidates.best-so-far'; }].

best-candidate-so-far differs from best-candidate-per-iteration for algorithms that also move to worse candidates, such as simulated annealing: it keeps the best candidate found earlier. The example statistics-output uses best-candidate-per-iteration, best-candidate-so-far, candidates-per-iteration, metrics-per-iteration and memory-model.

reference-values-per-individual evaluates a second optimisation function, the reference, at the candidates of every iteration and writes its values. With a benchmark as reference, a search on a surrogate model shows the true values along the search; with a surrogate model as reference, a search on the real function shows what the model predicts there; with two models, they can be compared. Excerpt of the example surrogate.gaussianprocess, whose EA searches on a Gaussian process model of the Forrester function:

document [
    'candidates-per-iteration' {},
    'reference-values-per-individual' {
        reference := 'benchmark-function' {
            'benchmarks' := [
                'benchmark-configuration' {
                    function := forrester {};
                    reads := [data 'x:0'];
                    writes := [data 'y:0'];
                }
            ];
        };
    }
].

The file has the columns individual-id, generation and the optimisation space as the reference computes it. Its rows are those of candidates-per-iteration.csv, in the same order, so both files join by individual-id and generation; prediction minus reference value is the error of the model where the search goes. The reference is evaluated in addition to the run: it uses no evaluation budget, is neither a real nor a surrogate evaluation, and the run does not change when the writer is added. The number of reference evaluations is the execution metric evaluations.reference of the memory model. The reference has to be deterministic: a function that draws random numbers during its evaluation (e.g. random-fitness) fails as reference.

Literature of a run

Every run writes citations.bib into its output folder (<output>/<name of the OL file>/), independent of the writers: the BibTeX entries of the methods its configuration uses, so you can cite them when you publish results. The file contains, each entry once and in this order:

  • the EvoAl paper;
  • the sources of every DL type of the configuration (the algorithm with all its components, the optimisation function, the target distances and the writers) and of its super types, in the order of the configuration, e.g. Deb et al. 2002 for 'nsga2-selection';
  • the sources of the DDL declarations of the problem, e.g. Harik and Goldberg 1997 for 'building-block';
  • for a surrogate model as fitness function, the sources of the types its model file records: the machine learning method, the types of its training and of its prediction pipeline;
  • the citations that the plugins declaring these types ask for, for themselves and for their libraries.

The runs of heuristic-search-evaluation share one file. The memory model lists the same keys in citations of execution-information.json, so analysis tools can relate a run to its literature. The sources of a type are named in its DL with @Literature (see Annotations); a plugin adds its entries to META-INF/evoal/credits.bib (see Credits and Licences). The regression ea-literature of the evolutionary algorithm shows a complete file. The folder provenance/ next to it records the environment, the configuration and the files of the run (see Provenance of a Run).

Algorithms

EvoAl provides several optimisation algorithms, we will give an short (and incomplete) overview here.

Evolutionary Algorithm

An evolutionary algorithm (EA) keeps a population of candidates. In every generation it selects parents, recombines pairs of parents into two children, mutates the children, evaluates them, and forms the next population from parents and children. Import de.evoal.optimisation.ea.optimisation to use this algorithm.

configure 'evolutionary-algorithm' for 'example-search' {
  'size-of-population'  := 40;
  'number-of-offspring' := 40;
  'initialisation'      := 'random-population' {};

  genotype := genotype {
    chromosomes := [
      'double-chromosome' {
        features      := [data 'x:0', data 'x:1'];
        recombination := [ 'sbx-crossover' { probability := 0.9; } ];
        mutation      := [ 'polynomial-mutation' {} ];
      }
    ];
  };

  'parent-selection' := 'tournament-selection' { size := 3; };
  replacement   := 'plus-replacement' {
    selection := 'elite-selection' {
      count := 2;
      rest  := 'tournament-selection' { size := 2; };
    };
  };

  'comparator'            := 'numeric-comparator' {};
  'optimisation-function' := 'problem-function' {};
  'stopping-criteria'     := [ 'iteration-count' { 'maximum-iterations' := 100; } ];
}

The key parameters are:

Parameter Description
size-of-population Number of candidates in the population (N)
number-of-offspring Number of children per generation (lambda)
genotype Which chromosomes represent the search variables, with their operators
parent-selection Selects 2 * ceil(lambda / 2) parents; consecutive parents form a pair
replacement Forms the next population of N candidates
boundary-handling Brings values outside the bounds back after every operator: boundary-handling.stick (default), bounce, or wrap
initialisation Strategy for creating the initial population
comparator How candidates are ranked against each other
optimisation-function The function used to evaluate candidates
stopping-criteria Conditions under which the algorithm stops

Every search variable that is not boolean needs a lower and an upper bound, and every chromosome needs features of its kind (real, integer, or for bit and Gray chromosomes also boolean); both are checked when the configuration is loaded. The EA offers both check points of candidate checks, and it can resample a child that fails a check of new candidates: it recombines the parents again and mutates the child again, at most 'maximum-attempts' times (default 10). The 'fitness-pipeline' applies as for the other algorithms.

Genotype

A genotype maps every search variable to exactly one chromosome:

Chromosome Genes Variables
double-chromosome One real value per variable real
integer-chromosome One integer per variable integer
bit-chromosome 1 bit per boolean, precision bits (default 16) per real or integer, standard binary code boolean, integer, real
gray-chromosome Like bit-chromosome, real and integer variables in Gray code boolean, integer, real

Every chromosome lists its recombination and mutation operators, applied in list order; both lists are required, and an empty list means that the chromosome is not recombined or not mutated. A chromosome with neither never changes, which the log reports:

genotype := genotype {
  chromosomes := [
    'gray-chromosome' {
      features      := [data 'x:0', data 'x:1'];
      precision     := 12;
      recombination := [ 'multi-point-crossover' { points := 2; } ];
      mutation      := [ 'bit-flip-mutation' {} ];
    },
    'integer-chromosome' {
      features      := [data 'n:0'];
      recombination := [ 'uniform-crossover' {} ];
      mutation      := [ 'creep-mutation' { step := 1; } ];
    }
  ];
};
Operators

Each operator applies only to some representations and scales; this is declared with the operator type (@Requires on the type of its chromosome, @RequiresScale on its features, see requirement annotations). An operator of a chromosome that does not apply to it is rejected when the configuration is loaded, also inside another operator such as 'single-choice-mutation'. The algorithm has no operators of its own, and a chromosome gets no default operators: the configuration states every operator.

Operator Representations Description
single-point-crossover all Swaps the genes after one random point
multi-point-crossover all Swaps the genes between points random points (default 2)
uniform-crossover all Swaps every gene with swap-probability (default 0.5)
sbx-crossover double Simulated binary crossover, distribution-index (default 15)
line-crossover double A point on the line through both parents, extended by extension (default 0.25)
arithmetic-crossover double Weighted mean of the parents, alpha (default 0.5)
blx-alpha-crossover double Uniform in the interval of the parents, extended by alpha (default 0.5)
random-reset-mutation double, integer A new uniform value within the bounds
gaussian-mutation double Adds a normal value with standard deviation sigma times the range (default 0.1)
polynomial-mutation double Polynomial mutation, distribution-index (default 20)
creep-mutation integer Adds a value from -step, …, -1, 1, …, step (default 1)
bit-flip-mutation bit, Gray Flips the bit
single-choice-mutation all its children have in common Applies exactly one of its children, chosen by weights (one per child)
correlation-aware-mutation those of its mutation Applies mutation and propagates the changes to correlated features (see below)
linkage-crossover those of its crossover Applies crossover and keeps building blocks and correlated features together (see below)

Every operator has a probability (default 1.0): a recombination fires once per pair, a mutation once per child. A mutation changes every gene of its chromosome with gene-probability (default 1 / n for a chromosome with n genes, the usual rate of one changed gene per mutation; Mühlenbein 1992, Bäck 1993). A pair that is not recombined passes on two copies.

Correlation-Aware Operators

Two operators use the correlations of the DDL. Both wrap another operator, whose probability and representations apply, and use every correlation whose absolute coefficient is at least 'minimum-correlation' (default 0). They work on the features, so a correlation can connect features of different chromosomes and representations.

// in a chromosome
mutation := [
  'correlation-aware-mutation' {
    mutation := 'polynomial-mutation' { 'gene-probability' := 0.5; };
    'minimum-correlation' := 0.5;
    'propagation-depth' := 1;
  }
];
recombination := [
  'linkage-crossover' {
    crossover := 'uniform-crossover' { probability := 0.9; };
    'minimum-correlation' := 0.5;
  }
];
  • correlation-aware-mutation: mutation makes the primary change. The change of every feature f is then propagated to every feature g correlated with it: change(g) = rho * change(f) / range(f) * range(g), where the range is given by the bounds of the DDL. An integer feature without bounds uses the range of its type; a pair with an unbounded real feature is skipped (both are reported in the log). For an ordinal feature the change applies to its rank. The new value is rounded for integer features and kept in the bounds. 'propagation-depth' (default 1) is the number of steps: with 2, the changed correlated features pass their change on once more. The correlations are visited in the order of the DDL, the first one wins, and every feature changes at most once; the features that mutation changed are not changed again. The propagation uses no random numbers.
  • linkage-crossover: crossover must exchange genes. Its type is instance 'gene-exchange', which single-point-crossover, multi-point-crossover and uniform-crossover extend, so a blending crossover (e.g. sbx-crossover) is an error when the configuration is loaded. It keeps the building blocks and the correlated pairs together; 'minimum-correlation' only applies to the correlations. For every building block and correlation, in the order of the DDL, a feature that a child inherited from one parent (the anchor) makes the child inherit the other features of the group from the same parent, and its sibling from the other one. A feature that an earlier group already set keeps its value and serves as the anchor, so every feature is set at most once: the shared feature of overlapping building blocks anchors the later one, and a group with two features already set from different parents is not kept completely. A feature that took bits from both parents (bit and Gray genes) is no anchor. The linkage of a group of genes is the probability that the crossover conserves it (Harik and Goldberg, 1996); this operator conserves every group whose anchor comes from one parent.

A ranged correlation applies only while the features lie in its ranges. The memory model records the properties primary-features and propagated-features (e.g. x:2 from x:1 (0.9)) on a mutated child and linked-features (e.g. x:2 with x:0 or x:7, x:12 with x:0) on a recombined one. The correlation-aware-mutation ignores building blocks, since they have no coefficient. The writer correlation-statistics compares the declared correlations with the population.

When the DDL declares building blocks or correlations, the evolutionary algorithm also counts how often its recombinations preserve them: a group is preserved in a child if all its features have the values of one parent. Every child of a recombination is counted, for every recombination and not only linkage-crossover, and for every group that applies to its parents (a ranged correlation only if both parents lie in its ranges). A group is checked at the end of the recombinations, before the mutation, and right before the first linkage step of the pair; with a single linkage-crossover, the latter shows the wrapped crossover alone. The memory model records the iteration metrics linkage-children-<g>, linkage-preserved-<g> and linkage-preserved-before-<g> for g = building-block-<n> or correlation-<n>. The writer linkage-statistics writes them with the rates into linkage-statistics.csv: per group children-<g>, preserved-<g>, rate-<g>, preserved-before-<g> and rate-before-<g> (a rate is empty without children). It needs building blocks or correlations in the DDL.

document ['linkage-statistics' {}, 'memory-model' {}].

The example ea-correlations uses both operators and correlation-statistics.

Selections and Replacements
Selection Description
tournament-selection The best of size random candidates (default 2)
elite-selection The best count candidates, the rest by the selection rest
truncation-selection Uniformly among the best fraction threshold
random-selection Uniformly at random
linear-ranking-selection By rank; eta-minus is the expected number of selections of the worst candidate per n selections
exponential-ranking-selection By rank, with exponentially falling weights (base c)
roulette-wheel-selection Proportional to the distance of the fitness to the worst fitness
stochastic-universal-sampling Like roulette wheel, with evenly spaced pointers
boltzmann-selection Proportional to exp(-(f - f_min) / temperature)
nsga2-selection The best non-dominated fronts; the last one by crowding distance (NSGA-II, see below)
stochastic-ranking-selection The first candidates of a stochastic ranking on fitness and the violation of a constraint group (see below)

Roulette wheel, stochastic universal sampling, Boltzmann selection and stochastic ranking use the fitness itself and need a fitness with one component (checked when the run builds its fitness pipeline, @RequiresFitnessComponents). All selections except nsga2-selection and stochastic-ranking-selection choose with replacement; a 'parent-selection' that cannot choose 2 ⌈λ / 2⌉ parents from the μ candidates is rejected when the run starts.

Roulette wheel, stochastic universal sampling and Boltzmann selection treat a fitness of Infinity (e.g. an infinite penalty) as the worst value, which is not selected while another candidate has a finite fitness, and -Infinity as the best value: if a candidate has it, only the candidates with -Infinity are selected. A fitness of NaN stops the run with an error. Stochastic universal sampling returns its selection in random order, so as 'parent-selection' it forms random pairs; elite-selection returns the best candidates first, so as 'parent-selection' the best candidates are paired with each other.

stochastic-ranking-selection (T. P. Runarsson, X. Yao: Stochastic ranking for constrained evolutionary optimization, IEEE Transactions on Evolutionary Computation 4(3), 2000) ranks the candidates by sweeps over neighbouring pairs, as in a bubble sort, starting from a random order. A pair is compared by fitness if both candidates are feasible or with the probability 'fitness-probability' (default 0.45, in [0, 1]; the paper recommends less than 0.5), otherwise by its penalty: penalty := 'stochastic-ranking-penalty.squared-sum' (default, the sum of the squared degrees as in the paper) or 'stochastic-ranking-penalty.sum' (the violation of the group). The ranking stops after a sweep without swap or after sweeps sweeps (default: the number of ranked candidates). The paper’s (mu, lambda) evolution strategy keeps the first mu of lambda children:

replacement := 'comma-replacement' {
  selection := 'stochastic-ranking-selection' { group := "region"; };
};

Every ranked candidate gets the property stochastic-rank (its place, 0 for the first), and the iteration metrics stochastic-ranking-sweeps, stochastic-ranking-fitness-comparisons and stochastic-ranking-penalty-comparisons count the sweeps and how many pairs with an infeasible candidate the fitness or the penalty decided.

Replacement Next population
survivor-replacement N - lambda parents chosen by selection, then all children (lambda <= N)
plus-replacement N of parents and children chosen by selection, (mu + lambda)
comma-replacement N of the children chosen by selection, (mu, lambda) (lambda >= N)
NSGA-II

NSGA-II (Deb et al. 2002) searches for the Pareto front of several goals. It is configured from three parts:

'parent-selection' := 'tournament-selection' { size := 2; };
'comparator'       := 'crowded-comparator' {};
replacement        := 'plus-replacement' { selection := 'nsga2-selection' {}; };
  • nsga2-selection sorts parents and children into non-dominated fronts (a candidate is in the first front if no other candidate is at least as good in every goal and better in one), computes the crowding distance in every front (how far the neighbours are; infinite at the ends of a front), and keeps the best fronts. The last front that does not fit completely keeps the candidates with the largest crowding distance.
  • With crowded-comparator, the selections compare by the crowded comparison: the lower front wins, in the same front the larger crowding distance. On a tie, the tournament keeps the first drawn candidate (the reference implementation chooses at random).
  • The fitness needs at least two components, so fitness-pipeline must not contain a scalarisation step. crowded-comparator and nsga2-selection are only used together and only in the evolutionary algorithm; nsga2-selection is the selection of plus-replacement or comma-replacement.
  • The ranks of an iteration are its fronts, so best-candidate-per-iteration writes the first front of every generation. The memory model records front and crowding-distance for every individual.

The example ea-nsga2 runs NSGA-II on the benchmark zdt1.

The memory model records how every child was created: a recombined child refers to both parents and its sibling, a mutated child to its parent, an unchanged child is an identity of its parent. The property operators names the operators that changed the child, changed-features the variables whose genes changed. In the steps version, a child that was recombined and then mutated appears twice: as the recombined child, a recombination of the parents with the crossover operators, and as the mutated child, a mutation of the recombined child with the mutation operators.

The examples ea-basic and ea-mixed-genotype show a double chromosome and a mixed genotype; the README of the plugin de.evoal.optimisation.ea gives the details and the literature.

Particle Swarm Optimisation

Particle swarm optimisation maintains a swarm of candidates that move through the search space influenced by their own best position and their neighbours’ best positions. Import de.evoal.optimisation.pso.optimisation to use this algorithm. It needs real search variables of at least cardinal scale; a configuration with other variables is rejected when it is loaded (requirement annotations).

configure 'particle-swarm-optimisation' for 'example-search' {
  'size-of-population'    := 25;
  'swarm'                 := 'default-swarm' {};
  'neighborhood-size'     := 5;
  'mover'                 := 'fips-mover' {
    'phi'           := 4.15;
    'boundary-type' := 'boundary-handling.bounce';
  };
  'topology'              := 'topology.global';
  'initialisation'        := 'random-population' {};
  'comparator'            := 'numeric-comparator' {};
  'optimisation-function' := 'problem-function' {};
  'stopping-criteria'     := [
    'iteration-count' { 'maximum-iterations' := 200; }
  ];
  document := [ 'candidates-per-iteration' {} ];
}

The key parameters are:

Parameter Description
size-of-population Number of particles in the swarm
swarm Swarm configuration strategy
neighborhood-size Number of particles in the neighbourhood of a ring topology, including the particle itself
mover Strategy controlling how particles move through the search space
topology Defines the neighbourhood structure of the swarm
initialisation Strategy for creating the initial swarm
comparator How candidates are ranked against each other
optimisation-function The function used to evaluate candidates
stopping-criteria Conditions under which the algorithm stops
document What information to record during the run
Swarm Strategies
Swarm Description
default-swarm Standard swarm with no additional adaptation
arpso-swarm Attracting-Repelling PSO swarm. Uses diversity thresholds to switch between attracting and repelling phases. Controlled by diversity-low and diversity-high. Requires the arpso-mover and a lower and an upper boundary for every search variable; both are checked when the configuration is loaded
Mover Strategies
Mover Description
fips-mover Fully Informed Particle Swarm mover, controlled by a single parameter phi (at least 4)
basic-mover Classic PSO mover with inertia weight and acceleration coefficients c1 and c2
constriction-factor-mover PSO mover with the constriction factor of Clerc and Kennedy; c1 + c2 must be at least 4
arpso-mover Attracting-Repelling PSO mover. Uses the same parameters as basic-mover but adapts behaviour based on the swarm’s diversity

All movers accept a boundary-type parameter that controls how particles behave when they reach the boundary of the search space. The examples use boundary-handling.bounce.

Boundary type Position Velocity
boundary-handling.wrap Enters the range from the other side (default) Kept
boundary-handling.bounce Reflected at the boundary Component negated
boundary-handling.stick Set to the boundary Component set to 0

The inertia weight of basic-mover and arpso-mover changes linearly from inertia-start to inertia-end within inertia-iterations iterations and stays at inertia-end afterwards:

'mover' := 'basic-mover' {
  'inertia-start'      := 0.9;
  'inertia-end'        := 0.4;
  'inertia-iterations' := 100;
  'c1'                 := 2.0;
  'c2'                 := 2.0;
  'boundary-type'      := 'boundary-handling.bounce';
};

The examples pso-basic, pso-topologies, and pso-arpso show the movers, the topologies, and the ARPSO swarm.

Local search algorithms start from one or more candidates and iteratively move to neighbouring solutions. EvoAl supports hill climbing, threshold accepting, and simulated annealing as accepting strategies under the local-search algorithm. Import de.evoal.optimisation.local_search.optimisation to use this algorithm. Since threshold accepting and simulated annealing also move to worse candidates, the last candidate is not necessarily the best one; the writer best-candidate-so-far records the best one.

configure 'local-search' for 'example-search' {
  'neighbour-choosing-strategy' := ...;
  'accepting-strategy'          := ...;
  'initialisation'              := ...;
  'comparator'                  := 'numeric-comparator' {};
  'optimisation-function'       := 'problem-function' {};
  'stopping-criteria'           := [
    'iteration-count' { 'maximum-iterations' := 200; }
  ];
  document := [ 'candidates-per-iteration' {} ];
}

The key parameters are:

Parameter Description
neighbour-choosing-strategy Strategy for identifying and evaluating neighbouring solutions
accepting-strategy Strategy for deciding whether to move to a neighbouring solution
initialisation Starting candidate or candidates
comparator How candidates are ranked against each other
optimisation-function The function used to evaluate candidates
stopping-criteria Conditions under which the algorithm stops
document What information to record during the run
Neighbour Choosing Strategy

The neighbour choosing strategy controls how the algorithm explores the neighbourhood of the current candidate. The manual-strategy searches in all directions by increasing or decreasing each variable by a fixed step size:

'neighbour-choosing-strategy' := 'manual-strategy' {
  'step-size' := [
    'variable' { var := data 'x:0'; val := 0.1; },
    'variable' { var := data 'x:1'; val := 0.1; }
  ];
  'neighbour-order' := 'neighbour-order.random';
};

Hill climbing and threshold accepting move to the first neighbour that the accepting strategy accepts. The parameter neighbour-order decides in which order the neighbours are offered:

Order Description
neighbour-order.random A new random order in every iteration (default). Threshold accepting accepts a random acceptable neighbour, hill climbing moves to a random better neighbour
neighbour-order.fixed Always the same order, the first variable changes fastest. Threshold accepting tends to walk in the direction of the first neighbours, because it accepts worse neighbours, too

Simulated annealing does not use the order: it tests a single random neighbour per iteration.

Accepting Strategies

The accepting strategy decides whether to move to a neighbouring solution. Three strategies are available. The examples local-search-hill-climbing, local-search-simulated-annealing, and local-search-threshold-accepting solve the same problem with each of them.

Hill Climbing

Accepts only better neighbours. The search ends in the first local minimum:

'accepting-strategy' := 'hill-climber' {};
Threshold Accepting

Accepts better and equal neighbours, and a worse neighbour if it is worse than the current solution by less than a threshold. The threshold decreases over time according to a decreasing function. If all neighbours of an iteration are rejected, the search ends, because the threshold only falls and the neighbours would be rejected in every later iteration, too:

'accepting-strategy' := 'threshold-accepting' {
  'initial-threshold'   := 10.0;
  'decreasing-function' := 'linear-decrease' { 'iterations' := 100; };
};
Simulated Annealing

As in the textbook version, every iteration tests a single neighbour, chosen at random. A better neighbour is always accepted, a worse one with the probability exp(-Δ / T), which decreases as the temperature T cools. If the neighbour is rejected, the search keeps its candidate and tries again in the next iteration at a lower temperature until a stopping criterion is met. Since every iteration evaluates only one neighbour, simulated annealing needs many iterations (the example uses 3000). The cooling schedule and acceptance probability function are configurable:

'accepting-strategy' := 'simulated-annealing' {
  'initial-temperature' := 50.0;
  'decreasing-function' := 'geometric-decrease' {
    'decrease-rate' := 0.95;
  };
  'acceptance-probability' := 'exponential-probability' {};
};

The available decreasing functions are:

Function Description
linear-decrease Reduces the value by a fixed amount each iteration, so that it reaches 0 after iterations iterations: T(k) = T0 - k · T0 / iterations
geometric-decrease Multiplies the value by a decrease-rate each iteration: T(k) = T(k-1) · rate. A rate below 1.0 causes gradual cooling
arithmetic-decrease Reduces the value by a growing amount: T(k) = T(k-1) - rate · k
logarithmic-decrease T(k) = T0 / ln(k + e), i.e., it starts at T0 and falls slowly
exponential-decrease T(k) = T0 · exp(-k^(1/N)) for N search variables

Random search samples candidates independently of each other and keeps the best one found so far. It is the simplest search and a baseline for the other algorithms: an algorithm that is not better than random search with the same number of evaluations does not use the structure of the problem. Import de.evoal.optimisation.random_search.optimisation to use this algorithm.

Iteration 0 and every further iteration take the next samples-per-iteration candidates from the initialisation and evaluate them; they form the population of the iteration. Use the writer best-candidate-so-far to get the best candidate of the run.

configure 'random-search' for 'example-search' {
  'samples-per-iteration' := 20;
  'initialisation'        := 'random-population' {};
  'comparator'            := 'numeric-comparator' {};
  'optimisation-function' := 'problem-function' {};
  'stopping-criteria'     := [ 'iteration-count' { 'maximum-iterations' := 100; } ];
}

The example random-search uses the same problem and number of evaluations as pso-basic, so the results can be compared.

CMA-ES

The covariance matrix adaptation evolution strategy samples its candidates from a normal distribution N(m, σ² C). In every iteration it updates the mean m, the step size σ and the covariance matrix C from the best candidates. C learns the dependencies between the variables, so CMA-ES is the baseline for comparing learned with declared linkage. The equations and default parameters are those of N. Hansen’s tutorial (arXiv:1604.00772v2); the update is checked against pycma, the reference implementation. Import 'de.evoal.optimisation.cma_es.optimisation' to use this algorithm. Only real search variables of at least cardinal scale are supported; both are checked when the configuration is loaded.

configure 'cma-es' for 'example-search' {
  'initial-step-size'     := 2.0;
  'covariance-model'      := 'full-covariance' {};
  'restart-strategy'      := 'bipop-restart' {};
  termination             := 'cma-es-termination' {};
  'initialisation'        := 'random-population' {};
  'comparator'            := 'numeric-comparator' {};
  'optimisation-function' := 'problem-function' {};
  'stopping-criteria'     := [ 'evaluation-budget' { 'maximum-evaluations' := 10000; } ];
}
Attribute Meaning
initial-step-size σ₀; the tutorial suggests 0.3 times the width of the search interval
population-size λ, optional; default 4 + ⌊3 ln n⌋ for n variables
parent-number μ, optional; default ⌊λ / 2⌋; at most λ / 2, so that every parent has a positive weight (checked when the configuration is loaded if both are set)
covariance-model full-covariance or diagonal-covariance (sep-CMA-ES: only the variances, linear time per candidate, for many variables)
restart-strategy no-restart, ipop-restart (the population grows by population-factor per restart) or bipop-restart (large and small restarts alternate); maximum-restarts is optional (unset: no limit; 0: no restart)
learning-rates optional, replaces the defaults: c-sigma, d-sigma, c-c, c-1, c-mu, c-m
termination the termination criteria of a CMA-ES run: tol-fun (1e-12), tol-x (1e-12, relative to σ₀), tol-x-up (1e4), condition-cov (1e14), and no-effect-axis, no-effect-coord, equal-fun-values, stagnation (all on); optionally maximum-iterations, the largest number of iterations of a run (see below)
record-all-correlations records the correlation of every pair of variables (default false)

The mean of the first CMA-ES run, and of every restart, is the next candidate of the initialisation. A termination criterion ends a CMA-ES run; then the restart strategy starts the next one, or the search ends. The stopping-criteria end the whole search. Samples outside the bounds of the DDL are mapped into them (the identity except in a small margin at each bound, as pycma’s BoundTransform), so no evaluation is wasted.

maximum-iterations ends a CMA-ES run after L iterations, computed for every run with its population size λ and the number of variables n:

Type L
fixed-iteration-limit { iterations } iterations
quadratic-iteration-limit { 'a'; 'b' } a + b (n + 3)² / √λ; the archived BBOB entries BIPOP-CMA-ES 2009 and IPOP-CMA-ES 2010 use a = 100, b = 50
sep-iteration-limit { 'a'; 'b' } a + b n √(n / λ); IPOP-SEP-CMA-ES 2009 uses a = 100, b = 300
termination := 'cma-es-termination' {
  'maximum-iterations' := 'quadratic-iteration-limit' { 'a' := 100.0; 'b' := 50.0; };
};

The memory model records the distribution of every iteration as metrics: sigma, axis-ratio, population-size, restart, mean-<variable>. With the full model, it also records the correlations C implies for the correlations (learned-correlation-<n>) and building blocks (learned-within-building-block-<n>, learned-between-building-block-<n>) of the DDL. The writer learned-linkage compares them with the declared values. The candidates have no predecessors; with restarts, each has the property restart.

The example cma-es-rosenbrock runs CMA-ES with IPOP restarts on the Rosenbrock function and shows the learned linkage.

Optimisation Functions for Optimisation Algorithm

Beyond the benchmark and unknown functions defined in the problem, the algorithms supports additional function wrappers in its optimisation-function parameter:

Surrogate

Evaluates candidates using a previously trained machine learning model:

'optimisation-function' := 'surrogate' {
  'model-file'   := "svr.pson";
  'input-space'  := [data 'x:0'];
  'output-space' := [data 'y:0'];
};
Problem Function

References the function already defined in the specify problem block, avoiding duplication:

'optimisation-function' := 'problem-function' {};
Search Space Distance

A function with a known optimum, e.g. for tests: for every mapping from a search variable to an objective, the objective gets the absolute difference between the variable and its target value.

'optimisation-function' := 'search-space-distance' {
  target  := [ variable { var := data 'x:0'; val := 1.5; } ];
  mapping := [ mapping { input := data 'x:0'; output := data 'y:0'; } ];
};
Noisy Function

Evaluates another optimisation function and adds Gaussian noise with mean 0 and the 'standard-deviation' to every objective: 'noise-model.additive' (the default) adds it, 'noise-model.multiplicative' scales the objective by 1 plus the noise. The noise of an evaluation depends only on the seed, the run and the evaluation, not on the threads. The objectives have to be real-valued.

'optimisation-function' := 'noisy-function' {
  function := 'problem-function' {};
  'standard-deviation' := 0.5;
};
Model Measures

For model search spaces: writes the size of a model (its number of objects) and its depth (the depth of its deepest object; the root has depth 0) into numeric objectives, e.g. as a size objective next to others in a part of a mixed-function or for tests. At least one of size and depth is required.

'optimisation-function' := 'model-measures' { model := data 'policy'; size := data 'size'; };
Mixed Function

Computes the outputs of a candidate with several functions, e.g. one objective with a surrogate model and another one with a formula, a benchmark or a real simulation. Every 'function-part' has a function and the outputs it writes. The parts run in their order for every evaluation (also for every sample of 'resampling' and 're-evaluation'), and each delivers only the outputs it writes. The writes of the parts must not overlap and must together cover every output of the problem, otherwise the run stops at start with the outputs that are written twice or not at all. A part cannot be another mixed-function.

map with 'mixed-function' {
  parts := [
    'function-part' {
      function := 'surrogate' {
        'model-file'   := "taste.pson";
        'input-space'  := [data 'grind size', data 'water pressure'];
        'output-space' := [data 'taste'];
      };
      writes := [data 'taste'];
    },
    'function-part' {
      function := 'benchmark-function' { ... };
      writes := [data 'cost'];
      'counted-as' := 'evaluation-source.none';
    }
  ];
}

A part counts as the source its function reports: a surrogate as a prediction, every other function as a real evaluation. 'counted-as' states it explicitly: 'evaluation-source.real', 'evaluation-source.surrogate' or 'evaluation-source.none' for a cheap part that uses no budget. An evaluation counts once for every source of its parts. The function can be used in map with, then the algorithm uses it with 'problem-function' {}, which counts as the sources of the problem’s function, or directly as 'optimisation-function'. The regression random-search-mixed-function of the random search plugin combines a Gaussian process with the Forrester function.

Symbolic Regression Fitness

For genetic programming: the error of a searched expression on a reference table, see Genetic Programming.

Surrogate Adaption

When candidates are evaluated with a surrogate, the fitness steps of the surrogate adaption change the fitness of a prediction depending on how reliable it is. They are configured in 'fitness-pipeline' and run in their order, each on the result of the previous one:

Step Reliability measured by
prediction-interval The width of the prediction interval of the surrogate (see below)
gaussian-density The Gaussian density of the training data around the candidate
kernel-density The kernel density of the training data around the candidate

The density steps take kind, a literal of the enum 'density-kind' ('source-based', 'target-based' or both, e.g. kind := 'density-kind.both';), exponent and 'root-exponent'. The information they need (density, prediction error) is calculated during training and stored with the model; a model without it fails at the start of the run. Only objectives with a minimise or maximise goal can be adapted, and the steps must run before scaling. The formulas are those of the former fitness decorators and will be redefined (issue #288).

prediction-interval takes the interval from the surrogate, in this order:

  • a model that predicts its own interval (gradient-boosting): its bounds for every output, with the coverage of the model; the steps after the prediction convert both bounds into the original unit;
  • a model with a predictive standard deviation σ (gaussian-process): ŷ ± z · σ for every output, with the 95 % quantile z of the standard normal distribution;
  • an SVR model: the prediction error data calculated during training ('predictive-error'()), for its first output only.
'optimisation-function' := 'surrogate' {
  'model-file'   := "model.pson";
  'input-space'  := [data 'x:0'];
  'output-space' := [data 'y:0'];
};

'fitness-pipeline' := [
  'prediction-interval' {},
  'gaussian-density' { kind := 'density-kind.source-based'; exponent := 1.0; 'root-exponent' := 1.0; },
  'kernel-density'   { kind := 'density-kind.source-based'; exponent := 1.0; 'root-exponent' := 1.0; }
];

Requires importing de.evoal.surrogate.adaption.density.optimisation and de.evoal.surrogate.adaption.interval.optimisation. The example surrogate.adaption-search runs the same search on a surrogate of the Forrester function twice, without adaption and with 'prediction-interval'; its training data has a gap around the minimum. The prediction interval uses native numeric libraries, whose results can differ slightly between platforms. The log warns about it, and the memory-model writer records it in setup.reproducibility of execution-information.json.

A Complete Example

The following example minimises the Rosenbrock function using simulated annealing, starting from two specified candidates:

import "definitions" from de.evoal.core.math;
import "definitions" from de.evoal.optimisation.core;
import "definitions" from de.evoal.pipeline.base;
import "definitions" from de.evoal.pipeline.benchmarks;
import "definitions" from de.evoal.pipeline.optimisation;
import "definitions" from de.evoal.optimisation.local_search.optimisation;

import "data" from 'search';

module 'search' {
  specify problem 'example-search' {
    search for data 'x:0', data 'x:1'

    map with 'benchmark-function' {
      'benchmarks' := [
        'benchmark-configuration' {
          function := rosenbrock {};
          reads    := [data 'x:0', data 'x:1'];
          writes   := [data 'y:0'];
        }
      ];
    }

    and minimise data 'y:0'
  }

  configure 'local-search' for 'example-search' {
    'neighbour-choosing-strategy' := 'manual-strategy' {
      'step-size' := [
        'variable' { var := data 'x:0'; val := 0.01; },
        'variable' { var := data 'x:1'; val := 0.01; }
      ];
    };

    'accepting-strategy' := 'simulated-annealing' {
      'initial-temperature' := 50.0;
      'decreasing-function' := 'geometric-decrease' {
        'decrease-rate' := 0.95;
      };
      'acceptance-probability' := 'exponential-probability' {};
    };

    'initialisation' := 'specify-candidates' {
      'candidate-list' := [
        'candidate' {
          'values' := [
            'variable' { var := data 'x:0'; val := 1.0; },
            'variable' { var := data 'x:1'; val := 5.0; }
          ];
        }
      ];
      'random' := false;
    };

    'comparator'            := 'numeric-comparator' {};
    'optimisation-function' := 'problem-function' {};

    'stopping-criteria' := [
      'iteration-count' { 'maximum-iterations' := 200; }
    ];

    document := [ 'candidates-per-iteration' {} ];
  }
}