Constants in a GPModel

51 views
Skip to first unread message

Ian Clarke

unread,
May 30, 2011, 6:33:36 PM5/30/11
to epo...@googlegroups.com
I'm a little confused as to how constants can be created and mutated in a GPModel.

Specifically, I want to create operators on DateTime objects (from the JodaTime package), and I want the genetic algorithm to be able to come up with its own DateTime objects if it wants to (within constraints specified by me eg. nothing before 1 year ago), and also mutate them.

I would appreciate any guidance,

Kind regards,

Ian.

Tom Castle

unread,
May 31, 2011, 8:22:15 PM5/31/11
to EpochX
Hi Ian,

It sounds as though you need to create a new type of Node which will
operate in a similar way to an ephemeral random constant, but for
dates. The easiest way to do this is probably to extend Literal, and
use your DateTime object as the value. Take a look at the source code
for DoubleERC, to see how this is done with Doubles, including
constraints. The important thing is to implement the newInstance()
method so that a new instance of your node is created with a randomly
generated date (within any constraints you have set).

You then need to supply an instance of your node (and any other nodes)
to the GPModel through the setSyntax method. This is where the
initialisation and mutation operators will get the set of nodes to use
from.

All the standard mutation operators should be able to work with your
new node. They won't change the value of one of your DateTimeERC nodes
(they are constants after all), but will potentially replace one with
another.

Ian Clarke

unread,
Jun 1, 2011, 6:17:37 AM6/1/11
to epo...@googlegroups.com
Sounds good, will do :-)

Ian.
--
Ian Clarke
CEO, SenseArray
Email: i...@sensearray.com
Ph: +1 512 422 3588
Reply all
Reply to author
Forward
0 new messages