Results 1 to 11 of 11
Thread: JGAP genetic algorithms for Java
 10142010, 12:27 PM #1Member
 Join Date
 Mar 2010
 Posts
 27
 Rep Power
 0
JGAP genetic algorithms for Java
Hi all,
I am stuck with JGAP, I am trying to test the code by finding Maximum Likelihood Estimates, I seem to have a problem with the fitness function. First, JGAP requires the fitness function to be positive valued. I have tried the usual transform: fitness = Math.exp(f(x)), but this doesn't work, JGAP can't find the optimum values of x. In most cases fitness stays at 0.0 due to f(x) being very low. Any suggestions on scaling the f(x)? Or is there other more popular packages for GA?
Regards,
Iskatel
 10142010, 01:12 PM #2
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,371
 Blog Entries
 1
 Rep Power
 20
Could you provide more details, like posting some code segment related to your work and so on. It's easy comment on your question.
I'm using GA Playground toolkit, in all my studies, which is more capable of customization accordingly.
 10142010, 01:55 PM #3Member
 Join Date
 Mar 2010
 Posts
 27
 Rep Power
 0
Here is some of the related code:
Java Code:public double evaluate(IChromosome subject) { double[] x = convertGeneToDouble(subject); double f = objFun.functionAtX(x); f += addPenalty(subject); System.out.println("f: " + f); double fitness = 1.0+1.0/Math.abs(f); System.out.println("Fitness: " + fitness); return fitness; }
Java Code:public double functionAtX(double[] param){ int numX = this.X[0].length; double b = param[param.length  2]; double var = param[param.length  1]; double sum = 0; for (int i = 0; i < 30; i++) { double mean = 0; for (int j = 0; j < numX; j++) { mean = param[j] * this.X[i][j] + b; // A*X+B } double logL = Math.log(2 * Math.PI * var) / 2  Math.pow((Y[i]  mean), 2) / (2 * var); sum += logL; } return sum; }
I guess I need to make transformations of parameters and restrict them to say [0,1] and reward more those chromosomes that come up with lower variance than others.
 10142010, 03:47 PM #4Member
 Join Date
 Mar 2010
 Posts
 27
 Rep Power
 0
Eranga, can you post and example java code for GAPlayground?
Thanks.
 10152010, 08:07 AM #5
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,371
 Blog Entries
 1
 Rep Power
 20
I'll try to find some of the stuff that I've done on my assignments, and send it to you later. I've to search them. :)
But I've found the following URL from my bookmarks.
GA Playground  Java Genetic Algorithms Toolkit
Scroll to bottom of the page, you can see several demos related with different fitness functions.
 10152010, 02:17 PM #6Member
 Join Date
 Mar 2010
 Posts
 27
 Rep Power
 0
Thanks Eranga; I don't really get the GA Playground; the example on the link you've posted is an applet, I wonder whether GA Playground can be used as library for my Java programs that involve other stuff. For such libraries there are usually example codes on their websites, but not for the GA Playground.
With kind regards,
Iskatel
 10182010, 10:51 AM #7
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,371
 Blog Entries
 1
 Rep Power
 20
If you search on the that, you can find the complete free download package. If not let me know.
I'll try to send you an example today from my stuff.
 10252010, 04:08 PM #8Member
 Join Date
 Mar 2010
 Posts
 27
 Rep Power
 0
Sorry for late reply Eranga. I got the JGAP working, I guess it just wasn't good for some stuff, I read that GA in general can home in to a local maximum and stay there. Now, it is working OK within reason I guess. I will probably have a look at the GA Playground later again.
Thanks for your comments.
 10252010, 06:12 PM #9
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,371
 Blog Entries
 1
 Rep Power
 20
When we start learning GA and looking into different tools, I remember that my professor said that most of the tools are not capable of training data set properly with complex training equations. It's not an easy task to implement those equations, and I don't know JGAP in that too.
GA Playground is more advanced than other tools I've used. More importantly, it could customize easily.
 11042010, 01:44 PM #10Member
 Join Date
 Mar 2010
 Posts
 27
 Rep Power
 0
I have downloaded the GA zip package. I can't find any examples of using GA within a program, or using it as a library.
 11042010, 05:26 PM #11
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,371
 Blog Entries
 1
 Rep Power
 20
Similar Threads

Q about Genetic programming
By m00nchile in forum New To JavaReplies: 8Last Post: 05122010, 11:23 AM 
genetic algorithms
By nurfadhillah in forum Advanced JavaReplies: 1Last Post: 10192008, 04:13 PM 
Algorithms in Java: where to find sources?
By javalover in forum New To JavaReplies: 0Last Post: 09212008, 07:33 AM 
Jgap 3.3
By JavaBean in forum Java SoftwareReplies: 0Last Post: 11122007, 07:03 PM 
Jgap 3.2
By JavaBean in forum Java SoftwareReplies: 0Last Post: 06242007, 08:45 AM
Bookmarks