Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GPDL/Examples/OneMaxBinary.txt @ 15899

Last change on this file since 15899 was 10424, checked in by gkronber, 11 years ago

#2026 maximal depth limit for random search

File size: 1.1 KB
RevLine 
[10423]1// special adaptation of the one-max problem for tree representations
2// must find maximal number of 1-terminals (maximum for a limited tree height h is 2 ^ (h - 1) )
3
4// the actual grammar:
5// E -> 0 | 1 | E E
6//
7// leading to example tree:
8//   E
9//  / \
10// 0   E
11//    / \
12//   1   0
13// with a value of 1
14//
15// optimal tree for height = 3 has the value 4
16//       E
17//     /   \
18//    E     E
19//   / \   / \
20//  1   1 1   1
21
22
23// because of constraints of the implemented solvers we have to express the grammar differently
24//
25// E -> T | N
26// N -> E E
27// T -> A | B     // A has value 0, B has value 1
28
[10415]29PROBLEM OneMaxBinary
30
31NONTERMINALS
[10423]32  E<<out int n>>.
33  N<<out int n>>.
[10415]34
35TERMINALS
36  A.
37  B.
38
39RULES
[10423]40  E<<out int n>> =
[10424]41    A                                             SEM << n = 0; >>
42    | B                                           SEM << n = 1; >>
[10423]43    | N<<out n>>
[10415]44  .
45
[10423]46  N<<out int n>> =                                LOCAL << int n1, n2; >>
47    E<<out n1>> E<<out n2>>                       SEM << n = n1 + n2; >>
[10415]48  .
[10423]49 
[10415]50MAXIMIZE
51  <<
52    int n;
[10423]53    E(out n);
[10415]54    return (double) n;
55  >>
56END OneMaxBinary.
Note: See TracBrowser for help on using the repository browser.