Print

Print


Robert, this is a common problem people have with typing in ECJ.   
Many of GP's standard tree-generation algorithms are constructive:  
they build the tree starting at the root, and expect to be able to  
top whenever they feel like it.  But as you didn't provide terminals  
for every possible return type, the algorithm CAN'T stop when it  
feels like it by sticking in a terminal when it wants to.

I believe you'll avoid the problem if you use UNIFORM as your tree- 
generator algorithm, as first it computes the available space of  
trees before it attempts to create any.  Otherwise you'll need to  
figure out how to allow terminals for every return type.

Sean

On Oct 23, 2006, at 11:22 PM, Robert Baruch wrote:

> Hi all,
>
> Attached is my params file. I have an "mkrule" node which has two  
> children, the first of which is a "rule" node.
>
> Some "rule" nodes take more "rule" nodes as children, or they can  
> also take an "end" node instead of a "rule" node. The "end" node  
> essentially ends the chain.
>
> Thus, you can have something like this:
>
> mkrule -> rule -> rule -> rule -> end
>
> or this:
>
> mkrule -> rule -> end
>
> but not this:
>
> mkrule -> end
>
>
> So I defined a type set "rule-or-end" which contains the types rule  
> and end. Now "mkrule" takes a rule as a parameter, and any rule  
> takes a rule-or-end as a parameter.
>
> The problem is that when I do this, I get this warning and exception:
>
> WARNING:
> In function set f0 for the GPTreeConstraints tc0, no terminals are  
> given with the return type rule which is required by other  
> functions in the function set or by the tree's return type.  Nearly  
> all tree-builders in ECJ require the ability to add a terminal of  
> any type for which there is a nonterminal, and at any time.   
> Without terminals, your code may not work.  One common indication  
> that a tree-builder has failed due to this problem is if you get  
> the MersenneTwister error 'n must be positive'.
> PARAMETER: gp.tc.0
> Initializing Generation 0
> Exception in thread "main" java.lang.IllegalArgumentException: n  
> must be positive
> 	at ec.util.MersenneTwisterFast.nextInt(MersenneTwisterFast.java:1081)
>
> The problem is that I can't make end return a rule (which would  
> satisfy having a terminal of return type rule), because then mkrule  
> -> end becomes a possibility.
>
> Any idea how to solve this?
>
> Thanks!
>
> --Rob
>
>