Challenge

Week 4.1 - Genetic Algorithm

Aim:- to optimise the gives stalagmite function and find the global maxima of the function.

INTRODUCTION:-

“stalactites” are structures formed from mineral deposits that hand from caves. These formation hold tightly to the ceiling and hang down. As opposed to hanging from the ceiling , “stalagmite” structures are formed from the cave floor that point upward.stalagmite and stalactite function.

INTRODUCTION:-

the GENETIC ALGORITHM (GA) is a optimization technique used to solve non linear optimization problems. It uses concept of evolutionary biology(darwin theory of evolution) to find the global minima for optimization a problem. An initial set of solution is tested against the objective function.

genetic algorithm is done in 3 steps:

SELECTION:- a number of individuals is selected from the population in the mating pool. Based on the previously calculated fitness value, the best individuals based on a threshold are selected. After that step, we will end selection a subset of the population in the mating pool.

CROSSOVER:- crossover in GA generates new generation the same as natural mutation. By mutating, the new generation of print comes by carrying jeans from both parents the amount of genes carried from each parent is random.

MUTATION:- For each offspring, select same genes and change its value. Mutation prevents the solution from falling into a local minima.

SYNTAX:-

x= ga (fun, nvars)

find a local unconditional minimum , x, to the objective function function, fun. Nvars is the number of design variable of function, fun.

CODE EXPLANATION:-

Firstly a random array of x & y values were created and the corresponding 2D array was obtained using mesh grid function. A nested loop used to assign value from this array into an array named input_vector. input_vector is the input to the stalagmite function. The stalagmite is written as separate. Minus(-) sign is given to the output of stalagmite function so that, after the ga process if we get the global maxima (normally ga output global minimum). Tic-tok commands are used to get the running time of each case. In the first case the bounds were not defined and the plots were made negative sign is given in case so that the number of solution approaches more accuracy. The population is increased in the subsequent cases and plotting is done. The global maxima is found in the last case. The x & y values for which the function has maximum value is also displayed. The iterations were decreased to such a value that the result didn’t vary and the program consumed minimum time to execute.

ERRORS:-

this error happened due to the mistake of executing the function stalagmite(x,y)

after giving the apropriate function the error was removed.

In one case, plot command was used instead of plot3 command to plot 3 axes.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.