Genetic Algorithm MATLAB here our major aim of this project is to identify the least of the Rastrigin function.We work on any types of coding and algorithms. We provide an explicit Rastrigin function, procedures of genetic algorithm and also MATLAB code in an elaborate manner. For optimization methods, this is examined as a usual evaluation function.

__Rastrigin Function__

The Rastrigin function is defined as: f(x)=10n+∑i=1n[xi2−10cos(2πxi)]f(x) = 10n + \sum_{i=1}^{n} \left[x_i^2 – 10 \cos(2 \pi x_i)\right]f(x)=10n+∑i=1n[xi2−10cos(2πxi)] where nnn is the dimension of the input vector xxx.

__Genetic Algorithm Procedures__

**Initialization:**It is significant to produce the primary population of findings.**Evaluation:**The capability of every individual in the population has to be evaluated.**Selection:**Generally, individuals must be chosen in such a manner on the basis of their capability to recreate.**Crossover:**As a means to create offspring, our team plans to incorporate sets of individuals.**Mutation:**For few individuals, we need to initiate irregular modifications.**Replacement:**On the basis of the offspring and few previous individuals, focus on creating a novel population.**Termination:**When an ending condition is attained, we intend to terminate the method.

__MATLAB Code__

Applying a basic Genetic Algorithm, the following is the MATLAB code:

% Genetic Algorithm to minimize the Rastrigin function

clc; clear; close all;

% Parameters

popSize = 50; % Population size

maxGen = 100; % Maximum number of generations

pc = 0.8; % Crossover probability

pm = 0.01; % Mutation probability

nVar = 2; % Number of variables (dimensions)

varRange = [-5.12 5.12]; % Variable range

% Initialize population

pop = varRange(1) + (varRange(2) – varRange(1)) * rand(popSize, nVar);

fitness = evaluatePopulation(pop);

% Main GA loop

for gen = 1:maxGen

% Selection (Roulette Wheel Selection)

selectedPop = selectPopulation(pop, fitness);

% Crossover

offspring = crossoverPopulation(selectedPop, pc, varRange);

% Mutation

offspring = mutatePopulation(offspring, pm, varRange);

% Evaluate offspring

offspringFitness = evaluatePopulation(offspring);

% Replacement

[pop, fitness] = replacePopulation(pop, fitness, offspring, offspringFitness);

% Display best fitness in current generation

disp([‘Generation ‘, num2str(gen), ‘: Best Fitness = ‘, num2str(min(fitness))]);

end

% Best solution

[bestFitness, bestIdx] = min(fitness);

bestSolution = pop(bestIdx, :);

disp(‘Best Solution:’);

disp(bestSolution);

disp([‘Best Fitness: ‘, num2str(bestFitness)]);

% Functions

function fitness = evaluatePopulation(pop)

% Evaluate fitness of each individual in the population

fitness = arrayfun(@rastrigin, pop(:,1), pop(:,2));

end

function selectedPop = selectPopulation(pop, fitness)

% Roulette Wheel Selection

cumFitness = cumsum(1./fitness);

totalFitness = cumFitness(end);

selectedPop = pop;

for i = 1:size(pop, 1)

r = rand * totalFitness;

selectedIdx = find(cumFitness >= r, 1, ‘first’);

selectedPop(i, 🙂 = pop(selectedIdx, :);

end

end

function offspring = crossoverPopulation(pop, pc, varRange)

% Uniform Crossover

offspring = pop;

for i = 1:2:size(pop, 1)-1

if rand < pc

alpha = rand(size(pop, 2), 1);

offspring(i, 🙂 = alpha .* pop(i, 🙂 + (1 – alpha) .* pop(i+1, :);

offspring(i+1, 🙂 = alpha .* pop(i+1, 🙂 + (1 – alpha) .* pop(i, :);

% Ensure offspring are within the variable range

offspring(i, 🙂 = max(min(offspring(i, :), varRange(2)), varRange(1));

offspring(i+1, 🙂 = max(min(offspring(i+1, :), varRange(2)), varRange(1));

end

end

end

function mutatedPop = mutatePopulation(pop, pm, varRange)

% Mutation

mutatedPop = pop;

for i = 1:size(pop, 1)

for j = 1:size(pop, 2)

if rand < pm

mutatedPop(i, j) = varRange(1) + (varRange(2) – varRange(1)) * rand;

end

end

end

end

function [newPop, newFitness] = replacePopulation(pop, fitness, offspring, offspringFitness)

% Combine population and offspring

combinedPop = [pop; offspring];

combinedFitness = [fitness; offspringFitness];

% Select the best individuals to form the new population

[~, sortedIdx] = sort(combinedFitness);

newPop = combinedPop(sortedIdx(1:size(pop, 1)), :);

newFitness = combinedFitness(sortedIdx(1:size(pop, 1)));

end

function f = rastrigin(x, y)

% Rastrigin function

n = length([x, y]);

f = 10 * n + (x^2 – 10 * cos(2 * pi * x)) + (y^2 – 10 * cos(2 * pi * y));

end

**Important 50 genetic algorithms list for research**

There are many genetic algorithms, but some are determined as effective. We suggest a set of 50 significant genetic algorithm topics and uses for investigation:

__Basic Genetic Algorithms__

- Binary-Coded Genetic Algorithm
- Steady-State Genetic Algorithm
- Micro Genetic Algorithm
- Hybrid Genetic Algorithm
- Distributed Genetic Algorithm
- Standard Genetic Algorithm
- Real-Coded Genetic Algorithm
- Generational Genetic Algorithm
- Adaptive Genetic Algorithm
- Parallel Genetic Algorithm

__Advanced Genetic Algorithms__

- Multi-Objective Genetic Algorithm (MOGA)
- Strength Pareto Evolutionary Algorithm (SPEA)
- Elitist Genetic Algorithm
- Island Model Genetic Algorithm
- Memetic Algorithm
- Genetic Programming
- Niched Pareto Genetic Algorithm (NPGA)
- Non-dominated Sorting Genetic Algorithm (NSGA-II)
- Hierarchical Genetic Algorithm
- Cellular Genetic Algorithm

__Specialized Genetic Algorithms__

- Genetic Algorithms for Constraint Satisfaction Problems
- Genetic Algorithms for Function Optimization
- Genetic Algorithms for Neural Network Training
- Genetic Algorithms for Traveling Salesman Problem (TSP)
- Genetic Algorithms for Job Shop Scheduling
- Genetic Algorithms for Dynamic Environments
- Genetic Algorithms for Combinatorial Optimization
- Genetic Algorithms for Feature Selection
- Genetic Algorithms for Scheduling Problems
- Genetic Algorithms for Vehicle Routing Problem (VRP)

__Genetic Algorithms in Engineering__

- Genetic Algorithms in Control System Design
- Genetic Algorithms in Power System Optimization
- Genetic Algorithms in Communication Network Optimization
- Genetic Algorithms in Biomedical Engineering
- Genetic Algorithms in Environmental Engineering
- Genetic Algorithms in Structural Optimization
- Genetic Algorithms in Signal Processing
- Genetic Algorithms in Robotics Path Planning
- Genetic Algorithms in Image Processing
- Genetic Algorithms in Chemical Engineering

__Genetic Algorithms in Computer Science__

- Genetic Algorithms for Data Mining
- Genetic Algorithms for Software Testing
- Genetic Algorithms for Game Playing
- Genetic Algorithms for Bioinformatics
- Genetic Algorithms for Automated Design
- Genetic Algorithms for Machine Learning
- Genetic Algorithms for Pattern Recognition
- Genetic Algorithms for Cryptography
- Genetic Algorithms for Natural Language Processing
- Genetic Algorithms for Artificial Life

We have offered Rastrigin function, genetic algorithm procedures, and MATLAB code, to identify the smallest of the Rastrigin function which is the major goal of this project. Also, a collection of 50 major genetic algorithm topics and uses for exploration are provided by us in a detailed way. The above-mentioned information will be beneficial as well as helpful.phdtopic.com team will provide you with thesis writing services and will share ides and topics on your interested area.