Simple example of genetic algorithm for optimization problems

It is used to generate useful solutions to optimization and search problems.
6.2K Downloads
Updated 9 Dec 2011

View License

It is used to generate useful solutions to optimization and search problems. Genetic algorithms belong to the larger class of evolutionary algorithms, which generate solutions to optimization problems using techniques inspired by natural evolution, such as inheritance, mutation, selection, and crossover.

function [p_min, iter, f]=genetic_algorithm (func, numMaxInd, numF, numMaxGen, pRepr, pRecom, pMut, pImm, numVariabili, limLow, limUp, tolerance)

% Output variables:
% - p_min: it's the minimum point of the objective function;
% - iter: it's the final iteration number;
% - f: it's the objective function value in the minimum point.
%
% Input variables:
% - func: it's the handle of the objective function to minimize (example: f_obj=@(x) function(x) where x is the variables vector);
% - numMaxInd: Number of individuals (number of initial points);
% - numF: Number of sons for each generation;
% - numMaxGen: Max number of generations (number of max iterations);
% - pRepr: Reproduction probability;
% - pRecom: Ricombination probability;
% - pMut: Mutation probability;
% - pImm: Immigration probability;
% - numVariabili: it's the number of the function variables.
% - limLow: it's the low bound for the initial points;
% - limUp: it's the high bound for the initial points;
% - tolerance: it's the tolerance error for the stop criterion.

Cite As

Andrea Cirillo (2024). Simple example of genetic algorithm for optimization problems (https://www.mathworks.com/matlabcentral/fileexchange/34144-simple-example-of-genetic-algorithm-for-optimization-problems), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0