Week 4 - Genetic Algorithm
AIM:
To write a code in MATLAB to optimise the stalagmite function and find the global maxima of the function.
OBJECTIVE:
The objective of this report is to optimize the stalagmite function by coding the program in MATLAB and explain the concept of generic algorithm and also explain the concept of ga syntax in MATLAB
THEORY:
STALAGMITE FUNCTION:
Stalagmite function is the mathematical model that helps to generate maximas and minimas.Global maxima is a maximum pek value in entire function and global minima is a minimum peak value in entire function. But local maxima and local minima are multiple number of values.
Optimization is finding of maxima and minima in a particular function but in generic algorithm its only to find maxima.
GENERIC ALGORITHM:
A generic algorithm developed by charles darwin theory of natural evolution.This algorithm reflects the process of election where the fittest individuals are selected for reproduction in order to the next generation.

In MATLAB , generic algorith generates a population of points at each iteration. The best point in the population is approaches an optimal solution selects the next population by computation which uses random number generators.
Generic algorithm solves smooth or ninsmooth optimization problems with any types of constraints , including iteration and constraint. It is a stochastic, population based algorithm that searches randomly by mutation and crossover among the population members
Generic algorithm uses three main types of rules, at each step it creates the next generation for current population.
- Selection rules which selects the individuals called the parents that contributes the next generation from the current population.
- Crossover rules in which it combines two parents to form children for the next generation.
- Mutation rules apply random changes to individual parents to form a children.
MATHEMATICAL EQUATION FOR STALAGMITE FUNCTION:

PROGRAM CODING:
FUNCTION PROGRAM:
CODE EXPLANATION:
The above program is written to optimize the stalagmite function and finding thr global maxima, by giving numerous generic algorithm runs upto 70 times and calculate the study time of 70 iterations. In this program we have calculated the cases to copile it:
CASE STUDY 1:
In this case, we have calculated the statistical behaviour of stalagmite function by using for loop as ga(stalagmite), calculate the time using tic and toc commands.
CASE STUDY 2:
In this case we have calculated the statistical behaviour of stalagmite function by setting upper and lower bounds ,where lower bound(x1,y1) is (0,0) and the upper bound(x2,y2) is (1,1) with which we can notice the decrease in studytime because of boundaries.
CASE STUDY 3:
In this case we have calculated the statistical behaviour of increasing the ga iterations.Population size has been increased. ga starts with random variables as we increase the population it creates 70 set of 2 random variables, through which we get the global maxima.
OUTPUTS:




STOPPING CRITERIA:
The genric algorithm uses the following criteria to determine when to stop:
- GENERATIONS: The algorithm stops when the number of count reached the values of generations.
- TIME LIMIT: The algorithm stops after running for an amount of time in seconds.
- FITNESS TIME:The algorithm stops when the value of the fitness function reaches the best point in the current population either less than or equal to.
The algorithm stops once it met with any one of the above criteria.
CONCLUSION:
When multiple number of iteration runs generic algorithm becomes optimum or linear. Where the number of cases is to check the over consistency of output values of ga. it gives the same output for all iterations, so that it can undergo optimum value global maxima can be found
Where as running the program with lesser iterations. ga may or maynot find the global maxima. But no of iteration increases probability of finding global maxima will also increses to optimize global maxima.
RESULT:
Thus the code for stalagmite function is been done and explained.