Code covered by the BSD License  

Highlights from
Optimization using Particle Swarm

Be the first to rate this file! 112 Downloads (last 30 days) File Size: 5.37 KB File ID: #40609

Optimization using Particle Swarm

by Swapnil Gaul

 

04 Mar 2013 (Updated 04 Mar 2013)

Auther : Gaul Swapnil Narhari, Developed @ IIT Kharagpur, India. By - TaraNG,emsolutions,India.

| Watch this File

File Information
Description

A set of codes used for finding minimum of a problem. By defining appropriate fitness function desired goal can be accomplished say, finding optimum design parameters so that much more beautiful solution can be achieved! :)

About Function:
[El,fval] = pso(PROBLEM) finds the minimum for PROBLEM. PROBLEM is a structurethat has the following inputs,
 
INPUT fields:
  fitnessfcn: <Fitness function>
   nvars: <Number of design variables>
      lb: <Lower bound on X>
      ub: <Upper bound on X>
 Genrations: <Number of iterations>
Population: <Number of swarms (particles) used for optimization>
 DispWB: <whether to disply waitbar or not '1' to display>
 OUTPUT fields:
 EL: < The values of optimized parameters>
fval: <Fitness value after optimization>
 
Example:
First, create a file to evaluate fitness function say, 'simple_fitness.m' as follows:
 
   function y = simple_fitness(x)
   y = 100*(x(1)^2 - x(2))^2 + (1 - x(3))^2 + abs(0.4 - x(2));
 
To minimize the fitness function, user need to pass a function handle to the fitness function as the first argument to the pso function, as well as other parameters of PROBLEM as stated above in pso(PROBLEM),
 
ObjectiveFunction = @simple_fitness;
nvars = 3; % Number of variables
LB = [0 0 0]; % Lower bound
UB = [3 5 10]; % Upper bound
Popln=200; % Number of particles
Genrtn=50; % Number of %iterations
WByn=1; % '1' = waitbar is ON
[x,fvalue]= pso(ObjectiveFunction, 'NumVar',nvars,'LowerBound',LB,'UpperBound',UB,'Population', ... Popln, 'Genrations', Genrtn, 'IncludeWB', WByn);
disp(x);
disp(fvalue);

After running code will get optimum parameter values more closer to, x(1)=0.6325; x(2)=0.4; x(3)=1;

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File  
Everyone's Tags
optimization
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
13 Apr 2013 Quang Hung

dear sir, If i want to use your code to optimize the function with more than 50 variables, is it possible? and what i have to change in your source code?

04 Mar 2013 Swapnil Gaul

PARTICLE (* misspelled as PARICLE)

Updates
04 Mar 2013

Spelling of particle & outcome of code

Contact us