Ephemeral primitives

43 views
Skip to first unread message

Alessandro Re

unread,
Mar 19, 2015, 7:45:57 PM3/19/15
to deap-...@googlegroups.com
Hello,

I am in the need of creating "random primitives" (random functional), that is, functions that behaves randomly, such as

def add_random(x, y):
     return x + y + some_value

but, some_value, would be something like an ephemeral constant: randomly generated every time the function is used when building a tree.
I thought about using classes with __call__ method defined, but they don't seem to work.

Of course, a kind-of possible solution would be to use STGP and pass some_value with a different type, so that only ephemeral constants of that type could be used, but I am just interested in knowing if is possible to do by creating custom operators, for example using classes or by wrapping functions in some way.

Thanks!
~Ale

François-Michel De Rainville

unread,
May 6, 2015, 7:46:16 PM5/6/15
to deap-...@googlegroups.com
This cannot work as you want it because there is a single implementation of your function and it gets called with various arguments. You would have to use a unic id for each time the function is referenced and store the value for each instance, which looks like a lot of trouble!

Sorry for the delay
Cheers

--
You received this message because you are subscribed to the Google Groups "deap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deap-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages