Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2026 maximal depth limit for random search

File size: 1.1 KB
Line 
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
29PROBLEM OneMaxBinary
30
31NONTERMINALS
32  E<<out int n>>.
33  N<<out int n>>.
34
35TERMINALS
36  A.
37  B.
38
39RULES
40  E<<out int n>> =
41    A                                             SEM << n = 0; >>
42    | B                                           SEM << n = 1; >>
43    | N<<out n>>
44  .
45
46  N<<out int n>> =                                LOCAL << int n1, n2; >>
47    E<<out n1>> E<<out n2>>                       SEM << n = n1 + n2; >>
48  .
49 
50MAXIMIZE
51  <<
52    int n;
53    E(out n);
54    return (double) n;
55  >>
56END OneMaxBinary.
Note: See TracBrowser for help on using the repository browser.