Line | |
---|
1 | PROBLEM Rastrigin
|
---|
2 |
|
---|
3 | /* Optimize the Rastrigin function. Solutions are full binary trees so the vector x can only have 2^n elements */
|
---|
4 |
|
---|
5 | NONTERMINALS
|
---|
6 | F<<out IEnumerable<double> x>>.
|
---|
7 | F1<<out IEnumerable<double> x>>.
|
---|
8 | F2<<out IEnumerable<double> x>>.
|
---|
9 | F3<<out IEnumerable<double> x>>.
|
---|
10 | F4<<out IEnumerable<double> x>>.
|
---|
11 |
|
---|
12 | TERMINALS
|
---|
13 | X<<out double val>>
|
---|
14 | CONSTRAINTS
|
---|
15 | val IN RANGE <<-5.12>> .. <<5.12>>
|
---|
16 | .
|
---|
17 |
|
---|
18 | RULES
|
---|
19 | F<<out IEnumerable<double> x>> = LOCAL<< IEnumerable<double> x1, x2; >>
|
---|
20 | F1<<out x1>> F1<<out x2>> SEM<< x = x1.Concat(x2); >>
|
---|
21 | .
|
---|
22 | F1<<out IEnumerable<double> x>> = LOCAL<< IEnumerable<double> x1, x2; >>
|
---|
23 | F2<<out x1>> F2<<out x2>> SEM<< x = x1.Concat(x2); >>
|
---|
24 | .
|
---|
25 | F2<<out IEnumerable<double> x>> = LOCAL<< IEnumerable<double> x1, x2; >>
|
---|
26 | F3<<out x1>> F3<<out x2>> SEM<< x = x1.Concat(x2); >>
|
---|
27 | .
|
---|
28 | F3<<out IEnumerable<double> x>> = LOCAL<< IEnumerable<double> x1, x2; >>
|
---|
29 | F4<<out x1>> F4<<out x2>> SEM<< x = x1.Concat(x2); >>
|
---|
30 | .
|
---|
31 | F4<<out IEnumerable<double> x>> = LOCAL<< double v; >>
|
---|
32 | X<<out v>> SEM<< x = Enumerable.Repeat(v, 1); >>
|
---|
33 | .
|
---|
34 |
|
---|
35 | MINIMIZE
|
---|
36 | <<
|
---|
37 | IEnumerable<double> x;
|
---|
38 | F(out x);
|
---|
39 | return 10.0 * x.Count() + x.Sum(xi=>xi*xi - 10 * Math.Cos(2*Math.PI*xi));
|
---|
40 | >>
|
---|
41 | END Rastrigin.
|
---|
Note: See
TracBrowser
for help on using the repository browser.