// special adaptation of the one-max problem for tree representations // must find maximal number of 1-terminals (maximum for a limited tree height h is 2 ^ (h - 1) ) // the actual grammar: // E -> 0 | 1 | E E // // leading to example tree: // E // / \ // 0 E // / \ // 1 0 // with a value of 1 // // optimal tree for height = 3 has the value 4 // E // / \ // E E // / \ / \ // 1 1 1 1 // because of constraints of the implemented solvers we have to express the grammar differently // // E -> T | N // N -> E E // T -> A | B // A has value 0, B has value 1 PROBLEM OneMaxBinary NONTERMINALS E<>. T<>. N<>. TERMINALS A. B. RULES E<> = T<> | N<> . N<> = LOCAL << int n1, n2; >> E<> E<> SEM << n = n1 + n2; >> . T<> = A SEM << n = 0; >> | B SEM << n = 1; >> . MAXIMIZE << int n; E(out n); return (double) n; >> END OneMaxBinary.