4

I have read many tutorials, papers and I understood the concept of Genetic Algorithm, but I have some problems to implement the problem in Matlab.

In summary, I have:

  • A chromosome containing three genes [ a b c ] with each gene constrained by some different limits.

  • Objective function to be evaluated to find the best solution

What I did:

  • Generated random values of a, b and c, say 20 populations. i.e
    [a1 b1 c1] [a2 b2 c2]…..[a20 b20 c20]

  • At each solution, I evaluated the objective function and ranked the solutions from best to worst.

Difficulties I faced:

  • Now, why should we go for crossover and mutation? Is the best solution I found not enough?

  • I know the concept of doing crossover (generating random number, probability…etc) but which parents and how many of them will be selected to do crossover or mutation?
    Should I do the crossover for the entire 20 solutions (parents) or only two of them?

Erfan
  • 163
  • 11
user488182
  • 235
  • 6
  • 14
  • 2
    the solution you found is the best of a random 20, if that is good enough for you then you don't need any algorithm... The idea of crossover and mutation is to create new population, that will improve over the generations. selection methods are a major part of genetic algorithms, any book/tutorial should have dedicated a big part of it to selection. But, the fact that you suggest crossing over the whole population suggests that you misunderstood something fundamental about GA, maybe try some introductory book... – pseudoDust Oct 06 '13 at 17:07

2 Answers2

1

Generally a Genetic Algorithm is used to find a good solution to a problem with a huge search space, where finding an absolute solution is either very difficult or impossible. Obviously, I don't know the range of your values but since you have only three genes it's likely that a good solution will be found by a Genetic Algorithm (or a simpler search strategy at that) without any additional operators. Selection and Crossover is usually carried out on all chromosome in the population (although it's not uncommon to carry some of the best from each generation forward as is). The general idea is that the fitter chromosomes are more likely to be selected and undergo crossover with each other.

Mutation is usually used to stop the Genetic Algorithm prematurely converging on a non-optimal solution. You should analyse the results without mutation to see if it's needed. Mutation is usually run on the entire population, at every generation, but with a very small probability. Giving every gene 0.05% chance that it will mutate isn't uncommon. You usually want to give a small chance of mutation, without it completely overriding the results of selection and crossover.

As has been suggested I'd do a lit bit more general background reading on Genetic Algorithms to give a better understanding of its concepts.

OnABauer
  • 589
  • 3
  • 17
  • Thanks.I am keeping reading tutorials and papers.What I have understood currently is: after evaluation the fit. function, worst half of the solutions will be killed and the best half will survive.Then,crossover with Pc probability is done for the remaining half to produce new kids that replace the dead solutions. Then, 20 % of the last updated solution is selected in mutation process under low probability Pm.Lastly,these solutions will proceed to next generation and the same is repeated for specified number of generations.Please guide me if this is correct, I will proceed in my project as this – user488182 Oct 07 '13 at 12:57
  • 1
    You'd be better to not kill half the population and instead run a selection process on the entire population. The fitter solutions are more likely to be selected but there is a chance that every chromosome can be selected. This is often important to keep diversity in the population. Again, with mutation you should run it on the whole population, with a very small chance that each gene will mutate. Often, a process called elitism, which saves the best chromosomes each generation and carries them forward is applied. This ensures that you never lose the best result that has so far been found. – OnABauer Oct 07 '13 at 13:37
  • For the chance of mutation, do you mean 0.05% or 0.05, i.e. 5%? 0.05% seems very small.. – Marcus Johansson Jun 16 '15 at 13:31
  • @Marcus Johansson, I mean 0.05%. It does seem small, and for certain applications it is. Generally, I deal with genetic algorithms with closer to 50 digits in a chromosome (a lot less than the 3 above) and since you want to leave some chromosomes with no mutation it isn't really that small. Some applications may benefit from a higher chance, some with lower. Like with most things with genetic algorithms related it's all about experimentation and finding out what works best. A lot depends on other operaters you may have and how well they all work together. – OnABauer Jun 17 '15 at 14:57
0

Sharing a bit of advice from 'Practical Neural Network Recipies in C++' book... It is a good idea to have a significantly larger population for your first epoc, then your likely to include features which will contribute to an acceptable solution. Later epocs which can have smaller populations will then tune and combine or obsolete these favourable features.

And Handbook-Multiparent-Eiben seems to indicate four parents are better than two. However bed manufactures have not caught on to this yet and seem to only produce single and double-beds.

andrew pate
  • 2,773
  • 26
  • 17