2013年8月26日 星期一

Modify the fitness equation of Tutorial 1 of ECJ

Okay, this time I switch to ECJ, which is a comprehensive library for evolutionary computation as I have surfed the web again for an easier platform than those C++ libraries.  I've tried the Tutorial 1 that is simple and easy to follow. As you may know, evolutionary process relies on a fitness equation to find optimal value.

In tutorial 1, the optimal solution is defined as the maximum  number of "1s" or "trues" in a chromosome / genome. To do this, it defines the  fitness value using the following codes in the MaxOnes.java file.
int sum=0; for(int x=0; xsum += (ind2.genome[x] ? 1 : 0);
The best genome will be 11111 when the size of genome is 5. Alternatively, I want the best genome be 10101. To do this, I replace the above code with the followings:
int sum=0; 
 for(int x=0; x
 if ((ind2.genome[x]==true) && ((x+1)%2!=0)) sum++;
else if ((ind2.genome[x]==true) && ((x+1)%2!=0)) sum++;
This increases the fitness value by 1 if the gene value is true at odd position or if the gene value is false at even position. The result is an alternating 1s and 0s string. Next, I will try to understand the entire evolutionary process in ECJ and how to define a representation and evolving operators.



沒有留言: