Print

Print


On Oct 5, 2011, at 5:43 PM, Buijs, J.C.A.M. wrote:

> I have a problem that I can represent as a tree and would like to solve using a genetic algorithm. The number of function nodes is limited (lets say they are the arithmetic operators of tutorial 4). The leaves can be instances of a limited alphabet (say A,B,C) that is different for each problem instance.
> A solution I'm looking for could for instance be '+ A (- B (* C A )'.
> 
> When I look at the type of problem of tutorial 4 then this is solving a formula with 2 variables and 3 operators. In my problem I have an unknown number of variables. So my question is how do I go about solving this? I can't create classes beforehand since I don't know the (size of the) alphabet beforehand. I could create one class (say AlphabetInstance) but how do I initialize each instance with a value from the alphabet while not breaking the ECJ framework guidelines.
> 
> So, in short, my question is how to model a problem with an unknown number of variables and instances of these variables.

Hi Jaos.  I think you have two choices for GP in general.  One option is to create a whole bunch of function classes, then specify which ones you want to use in the parameter file.  Another (in your case easier) option is to create an ERC which converts into one of your letters.  What you could do is have your ERC subclass read a parameter from the file which tells it how many different letters it might convert into, then picks one at random in its reset() method.  This is how I'd do it.

Sean