last day (15 days later) » 

3:08 PM
Hello, may I ask for more questions here in regard to my question here: stackoverflow.com/questions/56629830/…?
I would like to try to restate my second comment, if that's okay.
 
A chat room seems to be a good idea. I'll try to answer your questions here :)
Yeah shure I'm fine with that.
To me it still seems that you are using some kind of equally distributed selection in the code you posted.
The fitness-proportional selection works somehow different from the code you use I think:

So fitness proportional selection for genetic algorithms should work like this:
1. calculate the probability of every individual to be selected (where a higher fitness leads to a higher probability and the summed up probabilities of all chromosomes is 1)
2. randomly choose twice as much of them as there are in the next generation you want
 
Tobias, I also have a question. Before I do the crossover process, I go through a selection process which is basically selecting chromosomes which will go to the next generation IMMEDIATELY without modification, this means that some chromosomes are discarded and some are replicated using the same principle: fitness-proportionate selection. Is doing a crossover using the same selection method redundant or will this lead into erroneous results? THAT is what I'm currently doing, except for the fact that during crossover, I'm randomly selecting chromosomes.
@Tobias I SEE! I THINK I KNOW WHAT I GOT WRONG NOW. I mistook SELECTION and CROSSOVER as TWO different steps when they're exactly one? Is that where my mistake is?
 
Yeah that could be it. Selection and crossover are not realy one step, but they are a combination that leads to a new chromosome in the next generation (so one could say they are basicly only one step)
 
Oh lord. So to recap:

1. I will choose 100 individuals (because my population size is 50, so 50 * 2 = 100) to do recombination

2. After choosing 100 individuals, I will RANDOMLY (right?) select 2 of the 100 individuals chosen using roulette-wheel selection to recombine to ONE individual. I will repeat this step 50 times.

3. I get 50 new individuals and I will do mutation on these 50 individuals.

4. After mutation, I get the next generation or population.

Is that correct?
I'm sorry if I didn't explain well, English is not my first language.
Step 3 correction: I will mutate some individuals' genes, not mutate all the 50 individuals.
 
I think it's ALMOST it :)

in the second step you don't realy chose them completely randomly but depending on the probabilities for every chromosome
and step 1 and 2 are more only one combined step I think
steps 3 and 4 are already correct
Your english is no problem :)
It's not my first language too
I think I can explain it better using an example:
For a simple example lets say we have a population size of 3...
now lets say the chromosomes have fitness values like [1, 2, 4] so the third is the best one of them (here we try to maximize the fitness instead of minimizing the error like in your problem because that's somewhat easier to explain)
so after you know the fitness values you calculate the sum of the fitnesses:
1 + 2 + 4 = 7
 
3:26 PM
Okay. Then?
 
now you divide the fitness values by the summed fitness and get these selection probabilities:
[1/7, 2/7, 4/7] (summs up to 1)
afterwards you select two of them by selecting two random numbers:
lets say the first random number you got was 0.5/7 and the second one was 0.9
now you want to know which chromosomes to choose by these random values:
the first chosen value is lower than 1/7 which means the first chromosome is selected
 
@Tobias Why do I only choose two of them? Shouldn't I choose 6 of them?
@Tobias Okay I get this. This is the roulette-wheel selection method.
 
the last one is greater than 1/7 + 2/7 and smaller than 1/7 + 2/7 + 4/7 = 1 so you choose the thrid (and last) one of them
yes thats basically the roulette-wheel selection
you choose only two in the first step and repeat this the number of times you want the next generation to be.
So yes you choose 6 of them but one after another
 
@Tobias I see!
Oh how I've missed the point 100 percently xD Oh my god, thank you. I get it now.
Thank you thank you.
 
Allright. Your welcome! :)
 
3:32 PM
I've accepted your answer. I wish I could give you more reputation points. Thank you again!
I've missed the concept wholly. That's why I couldn't get the most optimal solution for such an easy problem.
Have a good day!
Also, your code is very clean, I like it, with the comments and all in Java.
 
Thank you very much :)
Have a good day too!
 
4:00 PM
Hello I would like to inform you that I've made my code work thanks to you :-) I've successfully implemented the algorithm to find optimal solution.
Thank you, really.
 
Glad to hear that :)
You're welcome
 

last day (15 days later) »