Generator Language
A Generator Language file describes how EvoAl should create data. It defines a sequence of steps
that generate, transform, or annotate data, and specifies how the resulting data should be stored.
Generator files use the .generator file ending.
When to Use the Generator Language
The Generator Language is useful in several scenarios:
- Training data generation: Create input and output data for machine learning models
- Function landscape exploration: Sample a function’s output across its input space
- Noised data generation: Simulate experimental data by adding statistical noise to clean data
- Algorithm initialisation: Generate starting data for stochastic optimisation algorithms
- Correlation estimation: Estimate the correlations of tabular data for the correlation-aware operators of a search (see Sinks and Pipeline Values)
- Data in a region: Keep only the rows that satisfy the constraints of the data description or a condition, e.g. to leave a gap in training data (see Filtering Rows)
Basic Structure
A Generator Language file consists of imports, a module, one or more named pipelines, and a
begin/end block that specifies what to do with those pipelines:
module com.example {
pipeline 'my-pipeline' [
// steps go here
]
begin
write "output.csv" with 1000 samples from executing ['my-pipeline'];
end
}
Pipelines
A pipeline is a named sequence of steps. Each step reads data dimensions, processes them using a component, and writes the results to data dimensions. Steps are executed in order, so a later step can use data written by an earlier one.
pipeline 'my-pipeline' [
step {
component 'some-component' {
// component configuration
}
reads [data 'x:0', data 'x:1'];
writes [data 'y:0'];
}
]
The reads clause specifies which data dimensions the step takes as input. The writes clause
specifies which data dimensions the step produces as output. Not every step requires both — for
example, a step that generates data from scratch does not need a reads clause.
Steps and Components
Each step is driven by a component. A component is a named, configurable processing unit. Configuration is provided as key-value pairs inside the component block:
component 'some-component' {
'key' := value;
}
The following components are shown in the examples. Note that available components depend on which definition files you have imported.
Generating Data from a Statistical Distribution
The distribution-based-data component generates values by sampling from statistical
distributions. You provide one distribution per output dimension, in the same order as the
writes clause:
step {
component 'distribution-based-data' {
distributions := [
'normal-distribution' {
'μ' := 0.0;
'σ' := 8192.0;
},
'normal-distribution' {
'μ' := 0.0;
'σ' := 8192.0;
}
];
}
writes [data 'x:0', data 'x:1'];
}
Each of the following distributions gives one value per sample. They all have a quantile function, so they can also be the marginals of a copula (see below). EvoAl checks their parameters when it loads the file: a σ of 0, or a mode outside [a, b], stops the run before it starts.
| Distribution | Parameters | Values | Typical use |
|---|---|---|---|
normal-distribution |
'μ', 'σ' > 0 |
all reals | measurement errors, sums of many small effects |
uniform-distribution |
'lower' < 'upper' |
[lower, upper) | no preference within a range |
log-normal-distribution |
'μ', 'σ' > 0 of ln X |
positive | skewed positive values, products of effects |
truncated-normal-distribution |
'μ', 'σ' > 0 before the truncation, 'lower' < 'upper' |
[lower, upper] | a normal quantity with physical limits |
triangular-distribution |
minimum 'a', mode 'c', maximum 'b' |
[a, b] | an expert estimate “at least a, most likely c, at most b” (Kotz and van Dorp 2004) |
beta-distribution |
shapes 'α', 'β' > 0, 'lower' := 0.0, 'upper' := 1.0 |
[lower, upper] | proportions, bounded skewed values |
exponential-distribution |
rate 'λ' > 0 |
≥ 0, mean 1/λ | waiting times between independent events |
gamma-distribution |
shape 'k' > 0, scale 'θ' > 0 |
> 0, mean kθ | skewed positive values, sums of waiting times |
weibull-distribution |
shape 'k' > 0, scale 'λ' > 0 |
≥ 0 | lifetimes and strengths |
gaussian-mixture-distribution |
arrays 'weights' (sum 1), 'μ', 'σ' (> 0), one entry per component |
all reals | multimodal values, e.g. two operating points (McLachlan and Peel 2000) |
The following distributions give whole numbers. Write them to integer data, e.g.
quotient integer data 'defects';, and all other distributions to real data. The values of a
categorical distribution name categories, so they need nominal or ordinal integer data, e.g.
nominal integer data 'variant';. EvoAl checks all this when the pipeline starts, as well as
that the distributions give exactly one value per written data.
| Distribution | Parameters | Values | Typical use |
|---|---|---|---|
bernoulli-distribution |
'p' in [0, 1] |
1 with probability p, else 0 | a switch that is on or off |
binomial-distribution |
'n' ≥ 0, 'p' in [0, 1] |
0 to n, mean np | successes in n trials |
poisson-distribution |
mean 'λ' > 0 |
0, 1, 2, … | events per interval, e.g. defects per part |
categorical-distribution |
'values' (whole numbers), 'probabilities' (one per value, sum 1) |
the values | variants of a design |
μ and σ of the truncated normal distribution belong to the normal distribution before the truncation; the mean of the generated data lies closer to the middle of [lower, upper]. For a bound on one side only, place the other bound far in the tail, e.g. at μ + 10σ.
The truncated normal, triangular, beta, exponential, gamma, Weibull, Gaussian mixture and the discrete distributions draw a uniform number u and return their quantile F⁻¹(u) (inversion, Devroye 1986). For a discrete distribution, F⁻¹(u) is the smallest value k with F(k) ≥ u; for a categorical distribution, this follows the order of the list. Like every distribution, they take their numbers from EvoAl’s random numbers, so the same seed gives the same data.
The example generator-distributions generates parts with properties from most of these
distributions, among them counts, a design variant, and a load with two operating points that is
coupled to a count of failures.
Covering a Box Evenly: Sobol’ Sequences
Independent random samples leave clusters and holes by chance. A low-discrepancy sequence spreads
its points evenly over a box. sobol-sequence is such a distribution: the Sobol’ sequence (Sobol’
1967) with the direction numbers of Joe and Kuo (2008), for up to 1000 dimensions. Each row gets
the next point. One sequence fills several outputs at once, one per dimension of the box:
step {
component 'distribution-based-data' {
distributions := [
'sobol-sequence' {
'lower' := [0.0, 0.0];
'upper' := [1.0, 1.0];
'randomisation' := 'random-shift' {};
}
];
}
writes [data 'x', data 'y'];
}
loweranduppergive the box [lower, upper), one entry per dimension.randomisationis required:no-randomisation {}keeps the points of the sequence. Every run then gives the same data, whatever the seed, starting with the cornerlower.random-shift {}(Cranley and Patterson 1976) shifts all points by one random vector and wraps them around the box. Every seed then gives different but equally even data.
- Use sample counts that are powers of two (e.g. 256 or 1024). For these counts, the points are evenly balanced. A filter after the sequence breaks this balance.
- Use one sequence for all outputs that should cover the box together. Two one-dimensional sequences return the same points, so their outputs would be (up to their shifts) the same.
The example generator-sobol-sequence writes 256 Sobol’ points and 256 uniform points. On a
16 × 16 grid, the Sobol’ points leave 16 cells empty, the uniform points 92.
random-points gives independent uniform points in a box with the same lower and upper.
Correlated Data with Any Marginals: Copulas
multivariate-normal-distribution generates correlated data, but every value is normally
distributed. copula-distribution separates the two parts of a joint distribution (Sklar 1959;
Nelsen 2006): the marginals say how each value is distributed, the copula how the values depend on
each other. Each row takes the next point of points, the copula turns it into dependent uniform
values, and each marginal turns its value into data through its quantile function:
step {
component 'distribution-based-data' {
distributions := [
'copula-distribution' {
copula := 'gaussian-copula' {
correlation := [[1.0, 0.8], [0.8, 1.0]];
};
marginals := [
'normal-distribution' { 'μ' := 0.0; 'σ' := 1.0; },
'log-normal-distribution' { 'μ' := 0.0; 'σ' := 0.5; }
];
points := 'sobol-sequence' {
'lower' := [0.0, 0.0];
'upper' := [1.0, 1.0];
'randomisation' := 'random-shift' {};
};
}
];
}
writes [data 'x', data 'y'];
}
marginalsare distributions of one value from the table above, one per output.copulais required:independence-copula {}keeps the values independent. Together with a Sobol’ sequence, this gives evenly covering data with any marginals.gaussian-copulatakes the correlation matrix R of the normal scores: symmetric, with ones on the diagonal, and positive semi-definite. With normal marginals, the data has the Pearson correlation R. With other continuous marginals, Pearson’s coefficient differs, but the rank correlations follow from R: Spearman ρ_S = (6/π)·arcsin(ρ/2), Kendall τ = (2/π)·arcsin ρ. A discrete marginal gives the same value for a range of normal scores. These ties lower the measured correlations below these values; EvoAl does not correct for them. For a categorical marginal, the order ofvaluesdecides which values go with high values of the other marginals.
pointsisrandom-pointsor a low-discrepancy sequence on the unit cube (everylower0, everyupper1), one dimension per output. Userandom-shiftwith a Sobol’ sequence: its first unrandomised point (0, 0) would map to −∞ for a normal marginal, which stops EvoAl with an error.
The example generator-gaussian-copula couples a normal and a log-normal value with R = 0.8.
Pearson’s coefficient of the data is 0.754 (theory 0.751), Spearman’s 0.789 (theory 0.786).
Applying a Function
A function component reads input dimensions, evaluates a function, and writes the result to an output dimension. The following example evaluates the Ackley function:
step {
component 'ackley' {
}
reads [data 'x:0', data 'x:1', data 'x:2', data 'x:3', data 'x:4'];
writes [data 'y:0'];
}
The benchmarks of de.evoal.pipeline.benchmarks are ackley, forrester, rastrigin,
rosenbrock, weighted-sphere, zdt1, and zdt2. zdt1 (Zitzler, Deb, and Thiele 2000) has two
objectives: it reads n >= 2 variables in [0, 1] and writes two values, f_1 = x_1 and
f_2 = g * (1 - sqrt(f_1 / g)) with g = 1 + 9 / (n - 1) * (x_2 + ... + x_n). Its Pareto front
is f_2 = 1 - sqrt(f_1), which is convex. zdt2 is the same with f_2 = g * (1 - (f_1 / g)^2).
Its Pareto front f_2 = 1 - f_1^2 is not convex, so a weighted sum of both objectives only finds
its two end points. forrester (Forrester, Sóbester, and Keane 2008), a one-dimensional
test function of surrogate modelling, reads one variable x in [0, 1] and writes
f(x) = (6x - 2)^2 * sin(12x - 4); its global minimum is f(0.7572) = -6.0207. The example
surrogate.adaption-training generates its training data with it.
Sequences
'sequence-generator' of de.evoal.pipeline.sequences generates data that depends on the
previous row, e.g. a time series. Every 'expression-based-sequence' writes one variable: the
first row gets its initial value (default 0.0), every further row the value of its
'expression' on the values so far. The sequences are evaluated in their order, so a sequence
sees the new value of the sequences before it:
step {
component 'sequence-generator' {
sequences := [
'expression-based-sequence' { variable := data time; initial := 1; 'expression' := data time + 1; },
'expression-based-sequence' { variable := data 'value'; initial := 1; 'expression' := data time * 42; }
];
}
writes [data time, data 'value'];
}
The rows are (1, 1), (2, 84), (3, 126), and so on. The step writes every sequence; its writes
lists their variables. The example generator-timeseries of the plugin generator.main writes 25
rows.
Adding Noise
The noise-data component adds noise sampled from a statistical distribution to existing data
dimensions. This is useful for simulating experimental data or testing the robustness of machine
learning models. You provide one distribution per dimension listed in the reads clause:
step {
component 'noise-data' {
distributions := [
'normal-distribution' {
'μ' := 0.0;
'σ' := 1.0;
}
];
}
reads [data 'y:0'];
writes [data 'y:0'];
}
Note that the same dimension can appear in both reads and writes, meaning the noise is
applied in place.
Reading from a File
The reader component reads existing data from a file instead of generating it. This is useful
when you want to reuse or reprocess previously generated data:
step {
component 'reader' {
filename := "ackley-expanded.csv";
}
writes [data 'run', data 'target', data 'x:0', data 'y:0'];
}
A reader is finite: its type has the annotation @Finite, and the pipeline ends when the file has
no more rows, wherever the reader is in the pipeline. write ... with all samples (see
The Begin/End Block) writes every row of the file this way. With
write ... with n samples, a file that ends before n rows are written stops the run with a message
that names the file and both counts.
Using a Trained Model
The trained-model component uses a previously trained machine learning model to predict output
values from input data:
step {
component 'trained-model' {
'model-file' := "svr.pson";
}
reads [data 'x:0'];
writes [data 'y:0'];
}
Filtering Rows
A filter is a step that passes on the rows that satisfy its condition and drops the others.
write ... with n samples counts the rows after the filters, so the file holds n rows that passed
every filter. Every filter needs 'maximum-consecutive-rejections': if it drops that many rows one
after the other, EvoAl stops with an error that names the filter and the last violation. This keeps
a filter that the data never passes from running forever. At the end, every filter logs how many
rows it kept.
Keeping the Rows that Satisfy the Data Description
constraint-validation checks the rows against the data description of their data in reads:
the annotations @LowerBoundary and @UpperBoundary of the data and of their data types, and the
constraints constraint(comparison, "group") of the DDL modules that declare the data:
step {
component 'constraint-validation' {
'maximum-consecutive-rejections' := 100;
}
reads [data 'x', data 'y'];
}
What happens to a row that violates a constraint depends on the severity of the annotation
(see constraint annotations); a
constraint(...) declaration has no severity and counts as an error:
| Attribute | Default | Reaction to a row that violates |
|---|---|---|
'error-reaction' |
'row-reaction.drop' |
an annotation with Severity.error or a constraint(...) declaration |
'warning-reaction' |
'row-reaction.keep' |
an annotation with Severity.warning |
The reactions are drop (the row is dropped), keep (the row is passed on, and at the end the
step logs how many passed rows violated each constraint) and stop (EvoAl stops with the row and
the violated constraint). If a row violates several constraints, stop takes precedence over
drop, and drop over keep.
EvoAl stops before generating data if a constraint compares data the step does not read, if a
constraint is an equality (generated data almost never satisfies it exactly; compute the dependent
data in a step instead), or if a data description has a constraint that is no annotation
(with constraints: ...). EvoAl never checks the data description on its own; only a
constraint-validation step does. The example generator-constraints keeps the normally
distributed points that lie in the triangle x >= 0, y >= 0, x + y <= 1.
Keeping the Rows that Satisfy a Condition
condition-filter keeps the rows for which its condition is true. The condition may only use
data the step reads:
step {
component 'condition-filter' {
'maximum-consecutive-rejections' := 20;
'condition' := data 'x:0' < 0.695 OR data 'x:0' > 0.805;
}
reads [data 'x:0'];
}
The example surrogate.adaption-training generates a grid on [0, 1] once and uses two filters:
one keeps the training data outside the gap (0.69, 0.81), the other the test data inside it.
Rejection Sampling
rejection-sampling keeps a row with the probability p that its acceptance-probability
computes from the data the step reads (the acceptance-rejection method of von Neumann 1951; see
also Devroye 1986). For every row, EvoAl draws a uniform random number u in [0, 1) and keeps the
row if u < p, so the same seed keeps the same rows. The kept rows follow a density shaped by p:
step {
component 'rejection-sampling' {
'maximum-consecutive-rejections' := 50;
'acceptance-probability' := data 'x';
}
reads [data 'x'];
}
With x drawn uniformly from [0, 1), the kept points have the density 2x: few near 0, many near
1 (example generator-rejection-sampling). The acceptance probability has to be in [0, 1]: a
constant outside is rejected when the file is loaded, and an expression of data that leaves
[0, 1] for a row stops EvoAl with an error.
Sinks and Pipeline Values
A sink is a step that acts when the stream of rows has ended, e.g., to estimate values from
all rows or to write a file. A sink passes the rows on unchanged, so several sinks can follow each
other; they act in the order of the pipeline. Sinks can publish pipeline values under a name
(result := "…") that later sinks read by that name. A pipeline value is plain data (lists, maps
with camelCase keys, strings, numbers and booleans). A name may be set once per execution of a
pipeline; a later execution replaces the value.
Estimating Correlations
The correlation-estimation sink (de.evoal.pipeline.statistics) estimates the correlation of
every pair of the data it reads and publishes the estimates as a pipeline value. It writes no data.
step {
component 'correlation-estimation' {
result := "correlations";
'minimum-correlation' := 0.3;
'confidence-level' := 0.95;
'confidence-interval' := 'bonett-wright' {};
ranges := [
'feature-range' { feature := data 'x:0'; lower := 0.0; upper := 5.12; },
'feature-range' { feature := data 'x:1'; lower := 0.0; upper := 5.12; }
];
}
reads [data 'x:0', data 'x:1', data 'x:2'];
}
- The kind of a pair follows from the scales in the DDL: the Pearson correlation for cardinal and quotient data, the Spearman rank correlation (average ranks for ties) if one of the two is ordinal. Pairs with nominal data are skipped; other data that is not numeric (e.g. an ordinal enum) is rejected.
- A row without a value for one of the two data is left out for that pair only.
- Every estimate has the number of rows
n, thecoefficientand a confidence interval by Fisher’s z-transformation with the variance 1/(n−3) for Pearson. For Spearman,'confidence-interval'selects the variance:'bonett-wright'(1 + r²/2)/(n−3), the default, or'fieller-hartley-pearson'1.06/(n−3) (meant for |r| ≤ 0.8). At most three rows give no interval. - Every pair gets an estimate on all rows and, if
rangesgive ranges for both data, one per combination of their ranges (for'ranged-correlation'). Ranges are given by hand. 'minimum-correlation'(default 0.0) leaves out estimates with a smaller absolute coefficient; estimates without a coefficient (fewer than two rows, constant data) are left out with a warning.- The keys of an estimate are
first,second,firstLower,firstUpper,secondLower,secondUpper(the ranges, missing on all rows),ranged,kind(pearsonorspearman),n,coefficient,absoluteCoefficient,confidenceLower,confidenceUpper,confidenceLevelandintervalMethod.
The same computation is used by the statistics writer 'correlation-statistics' of a search, so
both give the same values for the same data.
Rendering a Template
The template sink (de.evoal.pipeline.io) renders an Apache FreeMarker
template with pipeline values, e.g., a DDL module of the estimated correlations that a search
imports:
step {
component 'template' {
template := "estimated-correlations.ddl.ftl";
filename := "estimated-correlations.ddl";
values := ["correlations"];
}
}
import "definitions" from 'de.evoal.optimisation.constraint';
import "data" from 'search';
module 'estimated-correlations' {
constraints:
<#list correlations?sort_by("absoluteCoefficient")?reverse as c>
correlation(data '${c.first}', data '${c.second}', ${c.coefficient});
</#list>
}
Every value is available under its name. Numbers are written with a point, at most 16 decimals
and no exponent (e.g. 0.8031 or 1000), so they are valid literals of the languages; a template
can format them differently (${c.coefficient?string("0.00")}). A missing value is an error, and
templates cannot create or call Java objects (?new and ?api are disabled). The step reads and
writes no data.
Writing a Pipeline Value as CSV
The csv-writer sink (de.evoal.pipeline.io) writes a pipeline value that is a list of maps as
a CSV file: one row per map, one column per key (in the order of the first map), the keys as
column names. A missing value is an empty cell, an empty list an empty file.
step {
component 'csv-writer' {
name := "correlations";
filename := "output/correlations.csv";
}
}
The Begin/End Block
The begin/end block specifies how to execute the pipelines and where to store the results.
The following statement executes a pipeline, generates 1000 samples, and writes the result to a
file:
begin
write "output.csv" with 1000 samples from executing ['my-pipeline'];
end
The output file format is determined by the file extension. The examples show both .csv and
.json as supported formats. The sample count counts the rows that passed the filters of the
pipelines (see Filtering Rows). The pipelines of executing [...] run one after
the other on every row, so a pipeline can hold only a filter and be combined with others, e.g.
executing ['grid', 'training-region', 'function'].
with all samples instead of a count writes until a finite component has no more rows, e.g. every
row of the file of a reader:
begin
write "recalculated.csv" with all samples from executing ['read-and-recalculate'];
end
A finite component is one whose type has the annotation @Finite (of de.evoal.pipeline.base).
A pipeline without one would never end, so with all samples rejects it before the file is
created. Filters after the reader only reduce the rows that are written.
execute runs a pipeline once, without a sample count and without writing its rows. Its first
step is the source, e.g. reader, and the pipeline ends when the source has no more data, e.g. at
the end of the file. The pipeline is named by a string:
begin
execute("estimate-correlations");
end
An unknown name is rejected before anything runs. The example correlation-estimation of the
generator plugin reads a file, estimates its correlations, renders them into a DDL module and
writes them as a table.
A for loop repeats statements for each value of a range. A counter range counts from a start to an
end, both included, by an increment; a value range lists its values. Bounds, increment and values
are expressions:
begin
for i in [0 to 10 increment by 2] begin // 0, 2, 4, 6, 8, 10
execute("my-pipeline");
end
for j in [10 / 5 to -4 increment by -2] begin // 2, 0, -2, -4
execute("my-pipeline");
end
for k in [-1, 2 * 3, 0.5] begin
execute("my-pipeline");
end
end
The increment has to lead from the start to the end: it is positive if the range counts up and negative if it counts down. An increment of 0, or one that points away from the end, stops EvoAl with an error.
A pipeline run records its provenance and the literature of its components in
provenance/<name of the generator file>/ in the execution folder (see
Provenance of a Run).
A Complete Example
The following example generates data for the Ackley function. It first generates normally distributed input values, evaluates the Ackley function, and then adds noise to the output:
import "definitions" from 'de.evoal.pipeline.base';
import "definitions" from 'de.evoal.pipeline.benchmarks';
import "definitions" from 'de.evoal.pipeline.distributions';
import "data" from ackley;
module ackley {
pipeline 'main-pipeline' [
/**
* Step 1: Generate normally distributed input data.
*/
step {
component 'distribution-based-data' {
distributions := [
'normal-distribution' { 'μ' := 0.0; 'σ' := 8192.0; },
'normal-distribution' { 'μ' := 0.0; 'σ' := 8192.0; },
'normal-distribution' { 'μ' := 0.0; 'σ' := 8192.0; },
'normal-distribution' { 'μ' := 0.0; 'σ' := 8192.0; },
'normal-distribution' { 'μ' := 0.0; 'σ' := 8192.0; }
];
}
writes [data 'x:0', data 'x:1', data 'x:2', data 'x:3', data 'x:4'];
}
/**
* Step 2: Evaluate the Ackley function.
*/
step {
component 'ackley' {}
reads [data 'x:0', data 'x:1', data 'x:2', data 'x:3', data 'x:4'];
writes [data 'y:0'];
}
/**
* Step 3: Add noise to the output.
*/
step {
component 'noise-data' {
distributions := [
'normal-distribution' { 'μ' := 0.0; 'σ' := 1.0; }
];
}
reads [data 'y:0'];
writes [data 'y:0'];
}
]
begin
write "ackley.csv" with 1000 samples from executing ['main-pipeline'];
end
}