Challenge

Week 5 - Genetic Algorithm

1. What is Optimisation?

ANS-:Optimisation is a decision making process, it helps to find the best results under a set of prioritized criteria or constraints. It is a procedure which is executed iteratively by comparing various solutions till an optimum or a satisfactory solution is found.

2. What is GA?

ANS-:Genetic algorithm is one of the optimisation processes.

Genetic Algorithm (GA) is a search-based optimization technique based on the principles of Genetics and Natural Selection. It is frequently used to find optimal or near-optimal solutions.

It is frequently used to solve optimization problems, in research, and in machine learning.

clear all 
close all
clc

% Defining our Search Space
x = linspace(0,0.6,150);
y = linspace(0,0.6,150);

% Creating 2-d Array
[xx,yy] = meshgrid(x,y)

% Calculating Fitting Function
for i = 1:length(xx);
    for j = 1:length(yy);
        input(1) = xx(i,j);
        input(2) = yy(i,j);
        f(i,j) = stalagmite_func(input);
    end
end

% Converting Fitting Function to change the graph upwards
F = -f;

% Plotting Stalagmite Function
surface(xx,yy,F);
% shading interp;
hold on;

% Performing the Genetic Algorithm
[output , fval] = ga(@stalagmite_func,2,[],[],[],[],[0,0],[0.6,0.6])

% Plotting Global Maxima
x_max = output(:,1);
y_max = output(:,2);
f_max = -fval;
plot3(x_max,y_max,f_max,'marker','o','markersize',5,'markerfacecolor','r');
xlabel ('X-value');
ylabel ('y-value');
title('GLOBAL MAXIMA');
legend('STALAGMITE','GLOBAL MAXIMA')
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.