Sorry for the late response. My work started late this week, because of holidays.
So here is a sample code of my problem. I have a GPNode called Faktum that has a overridden setup method which looks like this:
@Override
public void setup(final EvolutionState state, final Parameter base) {
super.setup(state, base);
setMethod(state.random[0].nextInt(c.getDeclaredMethods().length));
}
also the setMethod:
public void setMethod(int i) {
types = new ArrayList<Type>();
method = c.getDeclaredMethods()[i];
for (Type t : method.getGenericParameterTypes()) {
types.add(t);
}
}
c is a global object:
public Class c = rulevolution.FactChecker.class;
My problem is, that a tree always looks like this...
Tree 0:
(when (ADF0 (eval isInIndex) (eval isInIndex)) (ADF0 (eval isInIndex) (eval isInIndex)) (ADF0 (eval isInIndex) (eval isInIndex)) (ADF0 (eval isInIndex) (eval isInIndex)))
or like this...
Tree 0:
(when (ADF0 contains contains) (ADF0 contains contains) (ADF0 contains (eval isInIndex)) (ADF0 contains contains))
or like this...
Tree 0:
(when (ADF0 contains contains) (ADF0 contains contains) (ADF0 contains contains) (ADF0 contains contains))
and so on.
But what I would want is something more mixed :
Tree 0:
(when (ADF0 contains eval) (ADF0 isInIndex eval) (ADF0 contains isInIndex) (ADF0 eval eval)) //just a self made sample
I'm using the state.random.nextInt function in a range of the amount of declared methods in my FaktChecker.class which is about 25 or 30. But I'm getting only 1 or 2 different
methods which is not what I wanted. Where do I have to set the state.random.nextInt to get a random function each time a GPNode is created? I thought it would be in the setup
method, but this does not work.
Thanks for any help.
Greetings
Bojan
----- Ursprüngliche Mail -----
Von: "Bojan Janisch" <[log in to unmask]>
An: "ECJ Evolutionary Computation Toolkit" <[log in to unmask]>
Gesendet: Freitag, 17. Mai 2013 23:47:01
Betreff: AW: Getting random Numbers
N is the length of an array that contains all declaredmethods from an specific class. I did not count them but I think its around 25. I'm using the generated number to choose a method from the array and use it in a node, but I always get a tree full of the same methods, what should not be possible if i really always get a different number.
I'll post some code on monday where you can see the implementation.
Greetings from Germany
Bojan
Von: Sean Luke
Gesendet: 17.05.2013 18:07
An: [log in to unmask]
Betreff: Re: Getting random Numbers
|