View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Simple example of genetic algorithm for optimization problems

4.3 | 3 ratings Rate this file 71 Downloads (last 30 days) File Size: 2.75 KB File ID: #34144 Version: 1.0

Simple example of genetic algorithm for optimization problems


Andrea Cirillo (view profile)


It is used to generate useful solutions to optimization and search problems.

| Watch this File

File Information

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.

MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
18 Dec 2016 Felicia Wong

Can someone explain how I might choose a suitable value for the immigration probability?
and also how immigration probability is different from mutation probability?

Comment only
25 Apr 2016 denemerido

mesela genetic_algorithm(@(x)x.^2,10,10,10,10,10,10,10,1,3,6,.01) girince
ans =


Comment only
29 Sep 2015 Milad Abdollahi

01 Dec 2013 David

David (view profile)

how do you input values to see the results? how can you use that to optimize a wind farm with a simple unidirection wind? thanks

22 Aug 2013 bhagyesh

plz give example of how to give inputs to it!!!

Comment only
28 Oct 2012 elsayed adawy

k bl.k bk

Comment only
19 Dec 2011 Giacomo

Contact us