AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Genetic Lib possible minor modifications and GP Question

The forum is to discuss topics from different artificial intelligence areas, like neural networks, genetic algorithms, machine learning, etc.

Genetic Lib possible minor modifications and GP Question

Postby Obi » Fri Feb 20, 2009 6:40 pm

Hi,

This is my 1st post, therefore would like to thank you first for the great work and lib. Can't wait until 2.0 is released.

Maybe I got it wrong (I'm also new to GA and GP), but I'm a bit puzzled by the followings:

1.Population.Selection()
Since the 'SelectionRate' is initially set to '0', this leads to the ApplySelection() method of ISelection to remove all individuals in the Population.
a.Therefore the Selection() method regenerates the population.
b. If the user sets the 'SelectionRate' to the usual 10%, this still leads to the removal of 90% of the population.
c. It seems that new Individuals are introduced to the population (to replace the removed individuals), however, the worst Individual is chosen as ancestor.
Shouldn't selection be based on the fitness of few better individuals.

If the above mentioned items are correct, then the population wouldn't evolve in a ideal way

2. BestChromosome
Probably a good idea to have the possibility to retrieve, not just the best, few better individuals in a population?

Again, these are my initial observations and they are probably not correct (I don't trust my eyes after staring at the screen all night).

3. A quick question on the 'TimeSeriesPrediction' sample. After playing with it for awhile, I still have the impression I'm getting past values (almost in curve fitting way) instead of future values. The question is really twofold:
a. What do I need to change in the sample to perform a prediction of a TimeSeries for say X(T+n), where n= 1,..,N
b. How should I interpret the returned 'solutions' Array? Or where is the predicted value stored?

Cheers,
Obi
Obi
 
Posts: 3
Joined: Fri Feb 20, 2009 5:28 pm

Re: Genetic Lib possible minor modifications and GP Question

Postby andrew.kirillov » Sat Feb 21, 2009 3:34 pm

Hello,

Obi wrote:Since the 'SelectionRate' is initially set to '0',


Sorry, but I am not really sure what are talking about. Population class does not properties like SelectionRate. Which version of AForge.NET Framework do you use?

There is RandomSelectionPortion, which controls amount of random members to add to new population. So, the population class performs selection of members to new population using specified selection method (see SelectionMethod property) and then adds some random members if required. Those are really random (not derived from best members) to make sure we have really "fresh blood" in population, which may bring new good solutions.

Obi wrote:Probably a good idea to have the possibility to retrieve, not just the best, few better individuals in a population?


You may get any member of population specifying its index. Then you may sort members or do whatever you want, like select 10 best members.

Obi wrote:What do I need to change in the sample to perform a prediction of a TimeSeries for say X(T+n), where n= 1,..,N


If you would like to predict, then pass last know values to the expression built with GP or GEP. For example, if you’ve trained to predict using 10 values from history, then pass 10 last value to predict the next one. Then 9 last known values + 1 new predicted to predict the next one. The 8 last known value + 2 new predicted to predict the next one. And so on.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3434
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Genetic Lib possible minor modifications and GP Question

Postby Obi » Sun Feb 22, 2009 1:43 am

Hi Andrew,

Thanks for the explanation on the 'prediction', I'll have a look at it, although I don't understand exactly what you mean with:

if you’ve trained to predict using 10 values from history, then pass 10 last value to predict the next one


Where is the predicted value stored in the TimeSeries sample? In 'solutions[0]' or where?

Regarding the GP issue mentioned, the
Code: Select all
RandomSelectionPortion
is what I mean with 'Selection Rate', because it allows you to determine the rate at which the individuals in a population will be 'selected' for mating. And as I said before, the way things are implemented now, it looks like at each generation, +90% of the population is wiped out and new individuals inserted.

Yes, there are new fresh blood added, but these replace the ones that have been removed. It is this removal that is also random and instead of removing the worst individuals.
Unless I'm mistaken, I thought the idea of the 'Selection' operator was to select the individual that are fit enough, to mate and reproduce for future generations.

The fresh blood are created by calling:

Code: Select all
ancestor.CreateOffspring()


Which just clones itself. And this ancestor is from

Code: Select all
population[0]


Which is the worst individual (since the population is sorted in ascending fitness order).

Andrew, what I'm saying is to have a look at the Population class. I know you know your code better than anyone else and maybe I just understood it incorrectly, but at least have another look at the Selection method.

I hope I'm not being a pain (that is not the goal here). Understand that I'm using this lib because I think it's a brilliant job. But nothing in this world is perfect and if we can make what is already very good even better, then everybody benefits from it.

Cheers,
Obi
Obi
 
Posts: 3
Joined: Fri Feb 20, 2009 5:28 pm

Re: Genetic Lib possible minor modifications and GP Question

Postby andrew.kirillov » Sun Feb 22, 2009 8:50 pm

Hello,

Obi wrote:And as I said before, the way things are implemented now, it looks like at each generation, +90% of the population is wiped out and new individuals inserted.


No, actually I said it before - you are making assumptions without any base for it. Where did you get this from? Check Population.RandomSelectionPortion property again and see that it is set to 0 by default. So, this means you will not get any random members by default.

Obi wrote:Yes, there are new fresh blood added, but these replace the ones that have been removed. It is this removal that is also random and instead of removing the worst individuals.
Unless I'm mistaken, I thought the idea of the 'Selection' operator was to select the individual that are fit enough, to mate and reproduce for future generations.


Again wrong. First of all we select some members from current population to the new population using specified selection method. It will be at least 10%, if you set random portion to max=90%. But since random portion is set to 0 by default, you will get 100% clear selection. Then all depends on selection method. If you want only the best, then just use elite selection.

Obi wrote:Which is the worst individual (since the population is sorted in ascending fitness order).


Again wrong. Take a look at CompareTo() method of chromosomes. It was designed in such way that chromosomes with better fitness will go first.

Obi wrote:The fresh blood are created by calling:


Code: Select all
ancestor.CreateOffspring()


Where did you get that from? Did you read the code before posting? The fresh blood is created using CreateNew( ) method.

Obi wrote:Andrew, what I'm saying is to have a look at the Population class. I know you know your code better than anyone else and maybe I just understood it incorrectly, but at least have another look at the Selection method.


Yes, I know my code. And I wish you spend some time learning it before making assumptions without any base. Believe me, currently implemented selection method works much better than you've described above.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3434
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Genetic Lib possible minor modifications and GP Question

Postby Obi » Mon Feb 23, 2009 9:36 am

Andrew,

I apoligise because you seem to have been crossed by those "assumptions". These assumptions were made after looking at the source code. Anyway, I'm glad to hear that I'm wrong and glad that you cleared it up.
Keep up the good work.

Cheers,
Obi
Obi
 
Posts: 3
Joined: Fri Feb 20, 2009 5:28 pm




Return to Artificial Intelligence