optimization Method (PSO)

ahmedluss's picture

Dear All,

   i want to used optimizatiom method in Maple ( Paritcal Swarm optimization) , i have the algorithm but i can to write the codes in Maple, vuold any one help for that.

      Thanks and best regards.

 

Ahmed

 

 

alex_01's picture

sound interesting...could

sound interesting...could you please post the algorithm ?  

It might be picked up by some smart Maple person :-)  

ahmedluss's picture

PSO

 

DEAR,

                     The algorithm of Partical Swarm Optimization:

In PSO a number of simple entities—the particles—are placed in the search space ofsome problem or function, and each evaluates the objective function at its current location.Each particle then determines its movement through the search space by combining some aspect of the history of its own current and best (best-fitness) locations with those of one or more members of the swarm, with some random perturbations. The next iteration takes place after all particles have been moved. Eventually the swarm as a whole, like a flock of birds collectively foraging for food, is likely to move close to an optimum of the fitness function.

Each individual in the particle swarm is composed of three

D-dimensional vectors, where

D best position pi , and the velocity vi . The current position xi can be considered as a set of coordinates describing a point in space. On each iteration of the algorithm, the current position is evaluated as a problem solution. If that position is better than any that has been found so far, then the coordinates are stored in the second vector, pi . The value of the best function result so far is stored in a variable that can be called pbesti (for “previous best”), for comparison on later iterations. The objective, of course, is to keep finding better positions and updating pi and pbesti. New points are chosen by adding vi coordinates to xi , and the algorithm operates by adjusting vi , which can effectively be seen as a step size.

 of the particles through their interactions. In any case, populations are organized according to some sort of communication structure or topology, often thought of as a social network. The topology typically consists of bidirectional edges connecting pairs of particles, so that if j is in i’s neighborhood, i is also in j ’s. Each particle communicates with some other particles and is affected by the best point found by any member of its topological neighborhood. his is just the vector pi for that best neighbor, which we will denote with pg . The potential kinds of population “social networks” are hugely varied, but in practice certain types have been used more frequently.In the particle swarm optimization process, the velocity of each particle is iteratively adjusted so that the particle stochastically oscillates around pi and pg locations. The (original) process for implementing PSO is as in Algorithm

 Original PSO.D dimensions in the search space.loop

3: For each particle, evaluate the desired optimization fitness function in

4: Compare particle’s fitness evaluation with its

5: Identify the particle in the neighborhood with the best success so far, and assign itsindex to the variable

D variables.pbesti . If current value is better than pbesti, then set pbesti equal to the current value, and pi equal to the current location xi in D-dimensional space.

6: Change the velocity and position of the particle according to the following equation:

 

 

vi ← vi + U(0,φ1)⊗( pi − xi )+ U(0,φ2)⊗( pg − xi ),

 

7: If a criterion is met (usually a sufficiently good fitness or a maximum number ofiterations), exit loop.

8:

xi ← xi + vi .                    (1)end loop

Notes:

randomly generated at each iteration and for each particle.

– In the original version of PSO, each component of

U(0,φi ) represents a vector of random numbers uniformly distributed in [0,φi ] which is⊗ is component-wise multiplication.vi is kept within the range

[−

Vmax,+Vmax]

thanks.

Algorithm 

1: Initialize a population array of particles with random positions and velocities on

2:

The particle swarm is more than just a collection of particles. A particle by itself hasalmost no power to solve any problem; progress occurs only when the particles interact. Problem solving is a population-wide phenomenon, emerging from the individual behaviors

ahmedluss's picture

PSO

Dear, 

 I have a program written using Matlab for Partical Swarm Optimization, how can I change it into a program written using Maple.

the program:

% THE
% MATLAB

function [xmin, fxmin, iter] = PSO

%%%
success = 0;      

PopSize = 20;        
MaxIt = 5000;        
iter = 0;           

fevals = 0;      
maxw = 1.2;        

minw = 0.1;      

weveryit = floor(0.75*MaxIt); 
c1 = 0.5; 
c2 = 0.5; 
inertdec = (maxw-minw)/weveryit;
w = maxw;                    
f = “DeJong”;               
dim = 2;                     

upbnd = 5;                    

wbnd = –5;       
GM = 0;             
ErrGoal = 1e–3;                

% Initializing 
popul = rand(dim, PopSize)*(upbnd-lwbnd) + lwbnd;
vel = rand(dim, PopSize);

%Evaluate 
for i = 1:PopSize,
fpopul(i) = feval(f, popul(:,i));
fevals = fevals + 1;
end

% Initializing 
% values
bestpos = popul;
fbestpos = fpopul;

% Finding
[fbestpart,g] = min(fpopul);
lastbpf = fbestpart;

% SWARM EVOLUTION LOOP ? START ?
while (success == 0) & (iter < MaxIt),
iter = iter + 1;
% Update the value of the inertia weight w
if (iter<=weveryit)
w = maxw – (iter–1)?inertdec;
end

% VELOCITY UPDATE
for i=1:PopSize,
A(:,i) = bestpos(:,g);
end
R1 = rand(dim, PopSize);
R2 = rand(dim, PopSize);
vel = w?vel + c1?R1.?(bestpos-popul) + c2?R2.?(A-popul);

%

popul = popul + vel;

% Evaluate the new swarm
for i = 1:PopSize,
fpopul(i) = feval(f,popul(:, i));
fevals = fevals + 1;
end

% Updating 
changeColumns = fpopul < fbestpos;
fbestpos = fbestpos.*(~changeColumns) + fpopul.*changeColumns;
bestpos(:, find(changeColumns)) = popul(:, find(changeColumns));

% Updating
[fbestpart, g] = min(fbestpos);

% Checking 
%if 
if abs(fbestpart-GM) <= ErrGoal
success = 1;
else
lastbpf = fbestpart;
end
end
%  LOOP ? END ?
% Output
xmin = popul(:,g);
fxmin = fbestpos(g);

function DeJong=DeJong(x)
DeJong = sum(x.?2);
 

Thank you so much

Ahmed

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}