Not for PTC1 or PTC2: they both rely on the fact that they control
whether a nonterminal or a terminal is chosen.
http://www.cs.gmu.edu/~sean/papers/treecreation.pdf
You may wish to look at some other algorithm, such as UNIFORM. Now
UNIFORM does not normally select based on probability: but you can fake
it by creating multiple copies of the same function in your function
set, which causes it to be picked more often.
Or you may have to roll your own. See the following paper for some
comparison of common algorithms:
http://www.cs.gmu.edu/~sean/papers/treegenalgs.pdf
Sean
José Carlos B. Ribeiro wrote:
> Hi again,
>
> first of all, thanks for the quick response! The CVS version works
> great -- I should have checked it first... Sorry for that.
>
> I have one more question: is there any way for me to define
> probabilities without making any destinction between terminal and
> non-terminal nodes and constraints?
>
> For example (and considering the parametrization below), i'd like
> GPNodeConstraint nc1 (terminal) to be selected with a probability of
> 10%, nc2 (terminal) with a probability of 20%, and nc3 (non-terminal)
> with a probability of 70%.
>
> ----- EXAMPLE PARAMETERIZATION -----
> gp.type.a.size = 2
> gp.type.a.0.name = A
> gp.type.a.1.name = B
>
> gp.nc.size = 4
> # NT B
> gp.nc.0 = ec.gp.GPNodeConstraints
> gp.nc.0.name = nc0
> gp.nc.0.returns = B
> gp.nc.0.size = 1
> gp.nc.0.child.0 = A
> # T A
> gp.nc.1 = ec.gp.GPNodeConstraints
> gp.nc.1.name = nc1
> gp.nc.1.returns = A
> gp.nc.1.size = 0
> gp.nc.1.prob = 0.1
> # T A
> gp.nc.2 = ec.gp.GPNodeConstraints
> gp.nc.2.name = nc2
> gp.nc.2.returns = A
> gp.nc.2.size = 0
> gp.nc.2.prob = 0.2
> # NT A
> gp.nc.3 = ec.gp.GPNodeConstraints
> gp.nc.3.name = nc3
> gp.nc.3.returns = A
> gp.nc.3.size = 1
> gp.nc.3.child.0 = A
> gp.nc.3.prob = 0.7
>
> gp.fs.0.size = 4
> gp.fs.0.func.0 = functionFiles.FFB1
> gp.fs.0.func.0.nc = nc0
> gp.fs.0.func.1 = functionFiles.FFA1
> gp.fs.0.func.1.nc = nc1
> gp.fs.0.func.2 = functionFiles.FFA2
> gp.fs.0.func.2.nc = nc2
> gp.fs.0.func.3 = functionFiles.FFA3
> gp.fs.0.func.3.nc = nc3
> -----
>
> Thanks again for the help,
>
> José
>
>
> On Tue, Oct 14, 2008 at 17:57, Sean Luke <[log in to unmask]> wrote:
>> A few months back I made modifications to PTC1 and PTC2 to make them more
>> robust for exactly your purposes. I don't know if those versions are on the
>> current ECJ snapshot yet -- they're definitely on CVS. Before we go further
>> here, let's make sure that you've got the most recent versions and things
>> are still having problems.
>>
>> Sean
>>
>> José Carlos B. Ribeiro wrote:
>>> Hi,
>>>
>>> I've been using ECJ for performing some experiments with
>>> Strongly-Typed GP (namely, for evolving unit-test cases for Java
>>> programs).
>>>
>>> I wanted to perform some experiments that require setting different
>>> probabilities of selecting constraints, and I found out that the PTC1
>>> and PTC2 algorithms allow me to do this. However, I've been having
>>> some problems.
>>>
>>> Please consider the parametrization below. Basically, I want
>>> GPNodeConstraint nc1 to be chosen with a probability of 30% and nc2 to
>>> be selected with a probability of 70%.
>>>
>>> ----- EXAMPLE PARAMETERIZATION -----
>>> gp.type.a.size = 2
>>> gp.type.a.0.name = A
>>> gp.type.a.1.name = B
>>>
>>> gp.nc.size = 3
>>> gp.nc.0 = ec.gp.GPNodeConstraints
>>> gp.nc.0.name = nc0
>>> gp.nc.0.returns = B
>>> gp.nc.0.size = 1
>>> gp.nc.0.child.0 = A
>>>
>>> gp.nc.1 = ec.gp.GPNodeConstraints
>>> gp.nc.1.name = nc1
>>> gp.nc.1.returns = A
>>> gp.nc.1.size = 0
>>> gp.nc.1.prob = 0.3
>>>
>>> gp.nc.2 = ec.gp.GPNodeConstraints
>>> gp.nc.2.name = nc2
>>> gp.nc.2.returns = A
>>> gp.nc.2.size = 0
>>> gp.nc.2.prob = 0.7
>>>
>>> gp.fs.0.size = 3
>>> gp.fs.0.func.0 = functionFiles.FFB1
>>> gp.fs.0.func.0.nc = nc0
>>> gp.fs.0.func.1 = functionFiles.FFA1
>>> gp.fs.0.func.1.nc = nc1
>>> gp.fs.0.func.2 = functionFiles.FFA2
>>> gp.fs.0.func.2.nc = nc2
>>> -----
>>>
>>> When I tried this out I got the following error message:
>>> "java.lang.ArithmeticException: Distribution has no elements". I guess
>>> that the problem here is that I didn't define any non-terminals for
>>> the atomic type A, and no terminals for B. Everything works fine if
>>> both A and B have terminals and non-terminals.
>>>
>>> The problem is that my problem requires me to define some types that
>>> only have terminal nodes (like A). Is there any way for me to get
>>> around this? Or am I missing something?
>>>
>>> Thanks, in advance, for your help,
>>>
>>> José
|