Symbolic regression based on JGAP
Supported function
The program has support for the following functions from JGAP. The "main" type is double so all functions are not applicable there (e.g. IfElse
etc). However, for the ADF functions (defined by setting adf_arity
to > 0) many more functions is supported. Please note that some of these are (very) experimental and maybe don't even make sense in this context.
-
Multiply
(double)
-
Multiply3
(double)
-
Add
(double)
-
Add3
(double)
-
Add4
(double)
-
Divide
(double)
-
Subtract
(double)
-
Sine
(double)
-
ArcSine
(double)
-
Tangent
(double)
-
ArcTangent
(double)
-
Cosine
(double)
-
ArcCosine
(double)
-
Exp
(double)
-
Log
(double)
-
Abs
(double)
-
Pow
(double)
-
Round
(double)
-
Ceil
(double)
-
Floor
(double)
-
Modulo
(double), implements Java's %
operator for double. See ModuloD for a variant
-
Max
(double)
-
Min
(double)
-
LesserThan
(boolean)
-
GreaterThan
(boolean)
-
If
(boolean)
-
IfElse
(boolean)
-
IfDyn
(boolean)
-
Loop
(boolean)
-
Equals
(boolean)
-
ForXLoop
(boolean)
-
ForLoop
(boolean) (cf the double variant ForLoopD)
-
Increment
(boolean)
-
Pop
(boolean)
-
Push
(boolean)
-
And
(boolean), cf the double variant AndD
-
Or
(boolean), cf the double variant OrD
-
Xor
(boolean), cf the double variant XorD
-
Not
(boolean), cf the double variant NotD
-
SubProgram
(boolean)
-
Tupel
(boolean)
Also, see my own defined functions defined in the Java files above.
Examples
Here are two small examples of the program, including the configuration file and a sample run.
Polynom
Here is a simple example of a configuration file. It happens to be the same problem as the JGAP example MathProblem, the polynom x^4 + x^3 + x^2 - x.
#
# Polynom x^4 + x^3 + x^2 - x
# The JGAP example
#
presentation: P(4) x^4 + x^3 + x^2 - x (the JGAP example)
num_input_variables: 1
variable_names: x y
functions: Add,Subtract,Multiply,Divide,Pow,Log,Sine
terminal_range: -10 10
max_init_depth: 4
population_size: 1000
max_crossover_depth: 8
num_evolutions: 800
max_nodes: 20
stop_criteria_fitness: 0.1
data
-2.378099 26.567495
4.153756 382.45743
2.6789956 75.23481
5.336802 986.33777
2.4132318 51.379707
-1.7993588 9.693933
3.9202332 307.8775
2.9227705 103.56364
-0.1422224 0.159982
4.9111285 719.39545
1.2542424 4.76668
1.5987749 11.577456
4.7125554 615.356
-1.1101999 2.493538
-1.7379236 8.631802
3.8303614 282.29697
5.158349 866.7222
3.6650343 239.42934
0.3196721 -0.17437163
-2.3650131 26.014963
A simple run example:
It was 20 data rows
Presentation: P(4) x^4 + x^3 + x^2 - x (the JGAP example)
output_variable: y (index: 1)
input variable: x
function1: &1 + &2
function1: &1 - &2
function1: &1 * &2
function1: /
function1: &1 ^ &2
function1: log &1
function1: sine &1
function1: 1.0
[19:52:57] INFO GPGenotype - Creating initial population
[19:52:57] INFO GPGenotype - Mem free: 10.5 MB
[19:52:57] INFO GPPopulation - Prototype program set
[19:52:57] INFO GPGenotype - Mem free after creating population: 10.5 MB
Creating initial population
Mem free: 10.5 MB
Evolving generation 1/800, memory free: 6.7 MB (time from start: 0,42s)
Best solution fitness: 968.56
Best solution: x ^ 4.0
Correlation coefficient: 0.9999999999999939
Fitness stopping criteria (0.1) reached with fitness 3.7509724195622374E-4 at generation 23
All time best (from generation 23)
Evolving generation 23/800, memory free: 10.4 MB (time from start: 3,20s)
Best solution fitness: 3.7509724195622374E-4
Best solution: (x * ((((x * x) + x) * x) + x)) - x
Depth of chrom: 6
Correlation coefficient: 0.9999999999999939
Total time 3,20s