Thursday, August 7, 2008

Coding a GA

dLet us consider a minimization problem

eg: f(x) = x^2 + 5(x) + 6

since it's a quadratic equation, it has got 2 solutions....lets say an x1 and x2.

This problem is subjected to a constraint x(l) <= x(i) <= x(u) i = 1, 2… N , where l and u specify the upper and lower limits and i specifies the no of solutions.

Step 1:

Choose a coding o represent problem parameters, a selection operator, a crossover operator, and a mutation operator. Choose population size, n, crossover probability, and mutation probability, . Initialize a random population of strings of size. Choose a maximum allowable generation number tmax. Set t=0.

To know about choosing GA parameters Click here

Step 2:

Evaluate each string in the population.

To know about evaluation Click here

Step 3:

If no of generations is exceeded or other termination criteria are satisfied, terminate.

Step 4:

Perform reproduction on the population.

Step 5:

Perform crossover on random pairs of strings.

To know about cross over, Click here

Step 6:

Perform mutation on every string.

To know about mutation, Click here

Step 7:

Evaluate strings in the new population. Set t= t+1 and go to step 3

No comments: