-4

I am working on genetic algorithm project. I need code to find out maxima/minima of Rastrigin function or Easom function (For y=0) using basic genetic algorithm.

Aman
  • 115
  • 1
  • 10
  • The usual procedure is to obtain and plug together several related matlab libraries without to much caring about theory or implementation. Where exactly is your problem, do you have example code for some "easy" functions? – Lutz Lehmann Jan 15 '17 at 21:38
  • @Lutzl No I don't. Actually I'm writing code in JAVA / C++ and I don't understand how to use GA for optimisation of functions. I've written population evolution code using GA but never worked with function optimisations using GA. – Aman Jan 16 '17 at 05:49
  • You have some population, you compute the value of function for every individual in population and individual with minimal value gets the higher fitness in population. – viceriel Jan 16 '17 at 11:21
  • @viceriel Yes I have done implementation of basic GA consisting of fitness functions,mutations,crossover and elitism. I have written code for it and it works fine. Now I need to know how can I use GA to find minima of Rastrigin function or maxima of Easom function (taking y for Easom function as 0 always). – Aman Jan 16 '17 at 11:44

1 Answers1

2

Ok, we look at Easom function.

Problem statement

Finding minimum at:

f(x) = -cos(x1)cos(x2)exp(-(x1-phi)^2 - (x2-phi)^2)

Representation choose

For example vector of real numbers. Interval of values for each element is <-5; 5>.

Fitness

Main issue of GA. We have for example two individuals:

Individual1: [-1|2.7|-0.68|3.78||-2.14|1.63|-1.75|-3.8]

Individual2: [1|1|1|1||-0.5|-0.5|-0.5|-0.5]

First individual is decoded as 4.8 and -6.06. His fitness function is -9.23073... × 10^-40.

Second individual is decoded as 4 and -2. His fitness is -4.30104456071396041116767479151655914468678005731098... × 10^-13

And now the issue. Fitness is so low, so we can considerate both as 0. You have two options. Waiting for Godot(maybe at some generation born the divination individual with global minimum value). Or you can use heuristic. Heuristic is based on dividing fitness on two values, major fitness and minor fitness. Major fitness is value of x in function. This value is always 0 so start can't search. Minor fitness is heuristic with purpose give the search a way. You defines some function, for example average of x. So minor fitness for individual1 is -0.63 and individual2 is 1. So individual2 is "better" and he will have higher probability for selection etc.

Minor fitness only give your search a way.
Can be this way wrong? Yes, it's heuristic. Important, minor function purpose is create preference for individuals with same major function. When major fitness is different, we use major fitness as value for orientation.

Example:

Individual1 fitness: Major: -0.1| Minor: 3

Individual2 fitness: Major: 0| Minor: 8

First one is better because of major fitness.

viceriel
  • 835
  • 12
  • 18