version 1.22.0.0 (125 KB) by
George Evers

Gbest PSO, Lbest PSO, RegPSO, GCPSO, MPSO, OPSO, Cauchy mutation, and hybrid combinations

The Particle Swarm Optimization Research Toolbox was written to assist with thesis research combating the premature convergence problem of particle swarm optimization (PSO). The control panel offers ample flexibility to accommodate various research directions; after specifying your intentions, the toolbox will automate several tasks to free up time for conceptual planning.

EXAMPLE FEATURES

+ Choose from Gbest PSO, Lbest PSO, RegPSO, GCPSO, MPSO, OPSO, Cauchy mutation of global best, and hybrid combinations.

+ The benchmark suite consists of Ackley, Griewangk, Quadric, noisy Quartic, Rastrigin, Rosenbrock, Schaffer's f6, Schwefel, Sphere, and Weighted Sphere.

+ Each trial uses its own sequence of pseudo-random numbers to ensure both replicability and uniqueness of data.

+ Choose a maximum number of function evaluations or iterations. Terminate early if the threshold for success is reached or premature convergence is detected.

+ Choose a static or linearly varying inertia weight.

+ Activate velocity clamping and specify the percentage.

+ Choose symmetric or asymmetric initialization.

+ A suite of pre-made graph types facilitates understanding of swarm behavior.

-- Automated Graph Features --

> Specify where on the screen to generate figures.

> Automatically generate titles, legends, and labels.

> Automatically save figures to any supported format.

-- Graph Types--

> Phase plots trace each particle's path across a contour map of the search space with iteration numbers overlaid.*

> Swarm trajectory snapshots capture the swarm state in intervals with optional tags marking global and personal bests. *

> The global bests's function value vs iteration shows how solution quality progresses and stagnates over the course of the search.

> The global best vs iteration shows how each decision variable progresses and stagnates with time.

> Each particle's function value vs iteration shows how its own solution quality oscillates with time.

> Each particle's position vector vs iteration shows how its decision variables oscillate toward the local or global minimizer.

> Each particle's velocity vector vs iteration shows how velocity components diminish with time.

> Each particle's personal best vs iteration shows how regularly and significantly each personal best updates.

* Note: Graph types marked with an asterisk are for 2D optimization problems by nature of the contour map.

+ Confine particles to the initialization space when physical limitations or a priori knowledge mandate doing so; but if the initialization space is merely an educated guess at an unfamiliar application problem, particles can be allowed to roam outside.

+ Activate or de-activate the following histories to control execution speed and the size of automatically saved workspaces.

ITERATIVE HISTORIES

> Global bests

> Function values of global bests

> Personal bests

> Function values of personal bests

> Positions

> Function values of positions

> Velocities

> Cognitive velocity components

> Social velocity components

Note: Disabling lengthy histories is recommended except when generating data to be published or verifying proper toolbox functioning, in which case histories should be analyzed.

+ Automatic input validation assertively corrects conflicting settings and displays changes made.

+ Automatically save the workspace after each trial and set of trials.

+ Automatically generate statistics.

+ Free yourself from the computer with a progress meter estimating completion time. A "choo choo" sound conveniently signals completion.

+ An Introductory Walk-through in the documentation teaches the basic functionalities of the toolbox, including how to analyze workspace variables.

ADD-IN

+ ANN Training Add-in by Tricia Rambharose

http://www.mathworks.com/matlabcentral/fileexchange/29565-neural-network-add-in-for-psort

HELPFUL LINKS

+ A history of toolbox updates is available at www.georgeevers.org/pso_research_toolbox.htm, where you can subscribe to be notified of future updates.

+ An introduction to the particle swarm algorithm is available at www.georgeevers.org/particle_swarm_optimization.htm.

+ A well-maintained list of PSO toolboxes is available at www.particleswarm.info/Programs.html.

+ My research on: (i) regrouping the swarm to liberate particles from the state of premature convergence for continued progress, and (ii) empirically searching for high-quality PSO parameters, is available at www.georgeevers.org/publications.htm.

George Evers (2021). Particle Swarm Optimization Research Toolbox (https://www.mathworks.com/matlabcentral/fileexchange/28291-particle-swarm-optimization-research-toolbox), MATLAB Central File Exchange. Retrieved .

Created with
R2009a

Compatible with any release

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

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

Idris jaeHello Evers,

thank you for this great work. How can I get the multi-objective version of the PSO toolbox?.

Vladimir KovalevDear Dr. Evers,

i use PSO in Matlab to calculate a diet. Is it possible to calculate a diet using your toolbox?

Regards, Vladimir.

Julian Grodzickyeduardo avilaKalaRathi Mpreksha pareekDear sir,

I need to tune extreme learning machine parameters using PSO, can you please provide guidance on how to implement that in Matlab?

vijay barethiyaDear sir

I need to optimize and tune fuzzy logic controller (fuzzy membership function and gain values) using pso. I use simulink for modeling purpose. Now how I can use pso toolbox for tunning of fuzzy and call the fuction in simulink? Pls let me know.

Thanks and regards

Yanming PEISravani NagasamudramGeorge EversEliazar, since I wasn't the author of the artificial neural network add-in for the PSO Research Toolbox, I don't support it.

mindfieldI am having a problem with ANN-PSO Add-In. I am getting error messages as shown below:

Error using trainpso (line 54)

Unrecognized code.

Error in network/subsasgn>getDefaultParam (line

2045)

param =

struct(feval(fcn,'defaultParam'));

Error in network/subsasgn>setTrainFcn (line

2015)

net.trainParam = getDefaultParam(trainFcn);

Error in network/subsasgn>network_subsasgn

(line 482)

if isempty(err),

[net,err]=setTrainFcn(net,trainFcn);

end

Error in network/subsasgn (line 10)

net =

network_subsasgn(net,subscripts,v,netname);

Error in NN_training_demo (line 58)

net.trainFcn='trainpso';

krishna chandraThank u for uploading the file sir.. I am new to matlab.. I am working with pso based upqc system... so plz can u guide me in above..If relevant file kindly mail me at krishnamraju03@gmail.com

George EversShaista, to optimize the characteristics of your fuzzy system, you need to write the objective function to be evaluated. Each dimension will represent one characteristic to be optimized, and each particle will represent one candidate solution. Please refer to section "Writing Your Function" in chapter "IV. Guide to Conducting Your Own Research" of the PSO Research Toolbox documentation for guidance. You may always download the most recent version of the documentation:

(i) in PDF format from http://www.georgeevers.org/pso_research_toolbox_documentation.pdf

(ii) or in Word format from http://www.georgeevers.org/pso_research_toolbox_documentation.doc

shaistaI am using anfisedit function in matlab and generate anfis structure using training data now i want to optimize it using PSO method how can i do it. please guide me using an example. I am new in this field.

George EversArif, you'd just need to write the function to be optimized - as per the users' guide - and any constraints and constraint method into the toolbox.

Since research involves doing something new, there should always be code for a researcher to write. By starting with a good toolbox, you would minimize the amount to be written.

If you're interested in contributing to the toolbox, I might be able to provide some feedback on occasion.

Arif RizviDear George Evers very good code !!

I want to use PSO for the optimal DG placement to minimize the reactive power loss, for the testing i am using Matlab. Is it possible to use this code ?

Ahmed@George Evers

Is it possible to use this code for model order reduction problems and minimize the error between systems?

If yes, can you help me in that?

Ahmed@George Evers

Is it possible to use this code for model order reduction problems and minimize the error between systems?

If you can you help me in that?

nadjouaHello

Where can I find Opposition PSO?

Thanks

Nesrullah SalmanThanks

Drazen TubicCan the problem of optimal placement and sizing of distributed generation in distribution system for voltage improvement be solved with this toolbox(free version)?

Thank you for answers

RAJARSHI MONDALDear sir

I want to optimize nontraditional machining response using desirability based PSO.I have 6 parameter of 3level and 11 response.I have conducted 54 experiment.kindly help me how I make this.I am new in MATLAB.

utmcan anyone explain to use this coding..

my project is about finding the optimal size of distributed generator on 14 bus system using pso coding. I'm newbies please help me.thank you

AstutyThank You very much

arudhraCan any one explain me how can i use this tool box,as i am new to matlab.

Ahmad TaherAhmad Taheryan yuThank you very much!

SampadaHello George, can I use this toolbox for object detection n tracking in video? If yes, Pl. help me how to do it.

Muhammad BilalHi george i work with GA to get best result for different differntianal equation. But now i listen about PSO i want to work with it. how is this possible to use PSO. please tell me may i use the same met file which i make for GA use for PSO. thanks

George EversNarin, to perform a controlled experiment, the number of layers, number of neurons per layer, bias connections, input connections, layer connections, output connections, target connections, transfer functions, and performance functions need to be set identically for backpropagation and RegPSO. I have an alpha version of the next release I could email you that allows you to set these values in the control panel: my email address is at http://www.georgeevers.org

George EversChen, opposition-based PSO is activated in the control panel via switch OnOff_OPSO. When active, gbest_core_loop.m or lbest_core_loop.m will implement it. Just open the appropriate file, press Ctrl + F, and type OPSO to jump straight to that chunk of code.

George EversMotaz, it's available at http://www.georgeevers.org

Feel free to contact me through that site.

George EversIbrahim, switches appear in the first section of the control panel. You can add yours there along with a comment about how to use it. The user's guide contains the remaining steps.

User's guide in pdf format: http://www.georgeevers.org/pso_research_toolbox_documentation.pdf

User's guide in doc format: http://www.georgeevers.org/pso_research_toolbox_documentation.doc

George EversAnjaneya, no, it works quite well on asymmetric functions as well. Sorry I don't have time to look up the data and post it right now. Feel free to email me if you'd like to see it.

Narin SovannDear George,

I am using Nueral Network add-in for PSORT. it works very well when it trains networks with RegPSO algorithm (George Evers) for the NN_train_demo.m. But when i apply it for my project, the error of output is quit high (the same input variables for ANNs training by BP algorithms is 1.81% but ANNs training by PSO(RegPSO algorithm) is more than 20% not acceptable).

any suggestions, please help me

regards,

Narin

rajaePlz help me , I need the code for the method of particle swarm

chenDear George, I want to know is there opso file in the toolbox? I didn't find the opso m file. Thx!

sehrishHI, I want to train Neural Network using Bat algorithm.....Bat algorithm is provided on mathworks....But i dont know how to use bat algorithm as training algorithm???? plz Guide me how i can do the same NN training as done by PSO?????

Motaz AmerDear George

i'd like to ask if i want the full version of the PSO toolbox how can i download and where i find it?

IBRAHIM MTOLERAsorry i am new in using PSO ,How can I Create switch OnOff_Constraints in the control panel’s

anjaneyahi george!

does RegPSO work good for symmetric cost functions only?

RohitGeorge EversRohit,

Rather than copying the syntax and functionality of the GA toolbox, I wrote the Particle Swarm Optimization Research Toolbox from the ground up. Among other benefits, this provides the convenience of setting parameters via the control panel without needing to learn how to use a lot of functions. While there is still a learning curve required to harness the many capabilities, it should not be steep for users specialized in particle swarm, who should find the toolbox quite capable and versatile enough to support a myriad of research directions.

The documentation contains a section called “Adding Your Problem to the Toolbox”, which describes how to apply the PSO Research Toolbox to solve new problems*. Should you encounter any difficulty, just let me know.

Regards,

George

* http://www.georgeevers.org/pso_research_toolbox_documentation.pdf

RohitRespected Sir,

I really appreciate your work on Optimization toolbox.

It is really a great help to college students like me.

Presently,I'm in final semester of B.Tech and my project topic

is "Optimization of PID controller using PSO".

I tried to use your toolbox and tried calling my objective function but

it is showing error on "feedback" syntax.

Same objective function worked for Genetic algorithm toolbox

then why it is not working for this ??

When I called the "pidobj":function:

>> pso_Trelea_vectorized('pidobj',3)

PSO: 1/2000 iterations, GBest = 1.008433808145666e-007.

??? Error using ==> plot3

Vectors must be the same lengths.

Error in ==> goplotpso at 23

plot3(pos(:,1),pos(:,D),out,'b.','Markersize',7)

Error in ==> pso_Trelea_vectorized at 344

eval(plotfcn); % defined at top of script

ehsmany thanks

George EversAbdul,

Hu and Eberhart designed an approach for implementing PSO with constraints [1], which should work fine with "randn" in lieu of "rand". Section "Adding Constraints" within Chapter "IV. Guide to Conducting Your Own Research" of the documentation explains how to implement it.

Sampling from a normal distribution at initialization alone would probably affect overall performance negligibly. It would standardize the initial velocities a bit more, but since initialization is only one 'iteration', any difference in behavior would most likely be diluted over the course of the entire search. Realizing a sustainable difference might require applying the same distribution to velocity updates as well.

To conveniently switch between “randn” and "rand" for comparison purposes, simply (i) create a switch, (ii) use its status to select which code to implement at velocity initialization, and (iii) use either the same switch or a unique one to select which code to implement during velocity updates. These steps are elaborated below.

(i) Create switch "OnOff_randn_velocity" at a relevant location within the control panel (e.g. below switch “OnOff_v_reset”), and set it to "logical(1)".

(ii) At lines 20 and 23 of "gbest_initialization.m" and "lbest_initialization.m" respectively, replace

"v = 2*vmax.*rand(np, dim) - vmax;"

with

"if OnOff_randn_velocity

v = 2*vmax.*randn(np, dim) - vmax;

else

v = 2*vmax.*rand(np, dim) - vmax;

end".

(iii) At line 41 of "gbest_core_loop.m" and "lbest_core_loop.m", replace each occurrence of

"r1 = rand(np, dim);

r2 = rand(np, dim);"

with

"if OnOff_randn_velocity

r1 = randn(np, dim);

r2 = randn(np, dim);

else

r1 = rand(np, dim);

r2 = rand(np, dim);

end".

The traditional uniform distribution has a mean of 1/2, which stochastically models the kinematic physics equation for translating a particle: x_f = x_0 + v_0*t + 1/2*a*t^2 [2: pp. 1-2]. To preserve this mean, "1/2 + randn(np, dim)" could be used in place of "randn(np, dim)" at each mention above. Going a step further, different standard deviations, D, could be experimented with by using "1/2 + D*randn(np, dim)"; and D could be set in the control panel for easy access. Personal experimentation has shown that performance deteriorates if stochasm is removed from PSO altogether by using the static 1/2 of the aforementioned kinematics equation in lieu of pseudo-random numbers; hence, poor behavior should be expected as the standard deviation approaches zero.

Chapter III of thesis prompts the question, "What mechanism would most effectively grant particles a healthy degree of distrust by which to avoid converging too quickly?" [3] Sampling random numbers from a normal distribution for velocity updates would be one candidate mechanism. Using a standard deviation of 1 and mean 1/2, for example, particles would 'trust' personal and global bests 69% of the time and 'distrust' them 31% of the time - positive accelerations toward the bests occurring over twice as often as negative accelerations away from them. Positive accelerations would also generally be of greater magnitude than negative accelerations since positive random numbers would generally be larger than negative random numbers due to the shift of the bell curve in the positive direction.

It stands to reason that if PSO can encapsulate a healthy degree of distrust, particles should not prematurely converge nearly as quickly, which should increase overall solution quality. In summary, do not be afraid to try sampling from a normal distribution for velocity updates as well as for velocity initialization even though doing so would occasionally produce negative random numbers: the small negative numbers might beneficially model a healthy degree of 'distrust'.

Feel free to contact me personally through my website with any further questions.

Regards,

George

http://www.georgeevers.org

[1] X. Hu and R. C. Eberhart, "Solving constrained nonlinear optimization problems with particle swarm optimization," in Proceedings of the Sixth World Multiconference on Systemics, Cybernetics and Informatics (SCI 2002), Orlando, 2002.

[2] G. Evers, “The No Free Lunch Theorem Does not Apply to Continuous Optimization,” 2011 International Conference on Swarm Intelligence, Cergy, France.

http://icsi11.eisti.fr/papers/paper_25.pdf

[3] G. Evers, “An Automatic Regrouping Mechanism to Deal with Stagnation in Particle Swarm Optimization,” M.S. thesis, The University of Texas – Pan American, Edinburg, TX, 2009

http://www.georgeevers.org/thesis.pdf

> To see that a healthy degree of distrust can be beneficial, compare Gbest PSO tested with: (i) a positive, static inertia weight for Table II-1 (Adobe p. 42), (ii) a linearly decreasing inertia weight for Table II-2 (Adobe p. 44), and (iii) a slightly negative inertia weight with predominantly social acceleration for Table III-3 (Adobe p. 68). All PSO parameters are inter-related (e.g. w, c1, c2, vmax) such that the ideal choice of any one parameter depends on the values of the other parameters, but for Gbest PSO with a negative inertia weight to significantly outperform even more complicated PSO models certainly warrants further investigations on the topics of distrust and parameter selection.

Abdul HameedDear George,

I am working with PSO for optimizing controller parameters within constraints for a system.I have used randn command for generating initial velocities.it converges with a solution out of the constraints.Can we limit the velocity with in a constraint ? if we can do so.. what will be the limit for it?

thank you,

Hameed

George EversTroy,

Without evaluating the quality of each position visited, the optimization process would not work. You should be able to access your Simulink model from within the objective function for this purpose.

Regards,

George

troy limhi George,

i have tried to understand and read through the pso documentation so that i can implement ur pso toolbox into my college project.

my project is about designing a queuing system to control the service time(output) according to entity flow rate(input 1) and queue length(input 2)using flc and the system was developed in slimulink and running well.

until now i come to last part of my project as to optimize the flc mfs parameters(total 63) so that the waiting time could be minimized.

from the pso documentation i found that objective function could be the waiting time but i realize that i need to formulate the objfunc according to my system in simulink seems like very tough.

is it possible i can achieve my goal without the objfunc? i have the data of waiting time from the simulation, can i utilize it to do optimization?

i wish u can help me out or give me some idea as this is the last part of my project towards the end....thx

George EversRishi, I've responded at the thread started at [1]. Feel free to post more questions there on the topic, and thank you for investing the time to digest the documentation.

If you encounter any errors, please zip the folder with the containing files (i.e. minus the Data folder), and send the whole thing to me. This will make it quicker and easier to debug.

Regards,

George

[1] http://www.mathworks.com/matlabcentral/newsreader/view_thread/312084

RishiThe only problem now remaining is the graphing_options that I had to switch off as it could not recognise the variable Z

in mesh(X1,X2,Z)

RishiHi George,

I solved my previous problem (Link:http://www.mathworks.com/matlabcentral/newsreader/view_thread/312084) by changing my objective function as follows,

*******************************************

function [f] = ObjFun_Zeta_Projection ( position_matrix, num_particles_2_evaluate )

load KG_106.mat

SET_1=M(1:26,:);

Dynset = SET_1;

Run_SET=[Dynset(:,1),Dynset(:,2),Dynset(:,3),Dynset(:,4),Dynset(:,5)];

xp=Run_SET(:,3);

yp=Run_SET(:,4);

for j=1:26

% Returns the difference between the simulated

% equation and the experimental data.

theta1 = position_matrix(1:num_particles_2_evaluate,1);

theta2 = position_matrix(1:num_particles_2_evaluate,2);

theta3 = position_matrix(1:num_particles_2_evaluate,3);

theta4 = position_matrix(1:num_particles_2_evaluate,4);

y_calc(j,:) = theta1.*(1-exp(-theta2.*xp(j,:))) + ...

theta3.*(exp(theta4.*xp(j,:))-1);

y_min(j,:)=100.*y_calc(j,:);

diffmat(j,:) = (y_min(j,:)-yp(j,:)).^2;

end

f=sum(diffmat);

*******************************************

where j is basically the size of xdata and ydata.

My second problem is now clamping the variables to my desired space.I tried to implement the Hu&Eberhart's approach but am receiving the following error,

??? Undefined function or method 'Satisfied' for input arguments of type 'double'.

Error in ==> gbest_core_loop at 167

if (Satisfied(Internal_i) && (f(Internal_i) <= fp(Internal_i))) %if the new function value is

better

I have sent you some files by mail though for verification.

Thanks,

Regards,

Rishi

George EversMark, since Jongwon is new to the community, he probably had the impression that a rating was required to leave a comment.

Your balancing perspective more than offsets the rating. Thanks!

Mark Shorejongwon chae, do you think it is appropriate to give a mediocre rating to a submission that you clearly have not tested in any way?

I have not had the opportunity to use this PSO submission in any detail yet, and will avoid giving a rating until such time as it might be a meaningful one. The extensive documentation George Evers provides suggests that the software will be of at least moderately high quality.

George EversJongwon, the optimization functionality is built from the ground up to avoid any such dependency, so it does not require any other products.

If you encounter any ambiguities in the documentation, please let me know so I can address them: I value your feedback. Minor improvements to the documentation made between toolbox versions are uploaded at [1, 2], depending on which format you prefer.

Regards,

George

http://www.georgeevers.org

[1] http://www.georgeevers.org/pso_research_toolbox_documentation.doc

[2] http://www.georgeevers.org/pso_research_toolbox_documentation.pdf

jongwon chaeDo I have to buy Matlab Optimization toolbox and Matlab Global Optimization toolbox to run PSO toolbox?

Can it run without them?

Thank you for your works

Yen HanningTricia RambharoseGood day users,

An add-in for this PSO toolbox is now available that allows a Neural Network (NN) to be trained by PSO. It can be found at the following file on MathWorks

http://www.mathworks.com/matlabcentral/fileexchange/29565-neural-network-add-in-for-psort

Regards,

Tricia

George EversKhalid, the README included in the zip will introduce you to the toolbox and walk you through some example simulations. Afterward, section "Conducting Your Own Research" will explain how to write your problem as a compatible function. At that point, if you require additional functionalities and are knowledgeable of your research area, I will provide some guidance as time permits to help you contribute the functionality (e.g. as done at http://www.mathworks.com/matlabcentral/newsreader/view_thread/154538 ).

khalid qorais it easy to use pso in medical image segmentation and can you help me in that ?

George EversEric,

The most restricting part of the agreement is probably, "You are expressly prohibited from doing the following with or to the PSO Research Toolbox: ... duplicating, reproducing, copying, or modifying it or otherwise creating derivative works from it **AND** either (1) claiming the resulting program as the intellectual property of any person, organization, or entity other than George Evers or (2) calling the resulting program by any name other than PSO Research Toolbox...." The Toolbox Use Agreement strives to protect and respect the intellectual property of authors of PSO Research Toolbox Add-ins and myself. Given the extensive amount of work that has gone into developing the code, I don't believe that anyone who modifies it should reasonably expect either to claim it as one's own intellectual property or to distribute it under a different name.

The main idea is to allow other researchers to contribute functionality in a structured manner that facilitates the evolution of the toolbox - much as MATLAB itself has evolved through the structured accumulation of an immense number of functions. As a very simple example, if any toolbox functionality is found to be inconsistent with a researcher's particular goals, I expect the researcher to be able to add a simple switch to de-activate the functionality rather than deleting it entirely, thus enabling modifications to move in a consistent direction and improve for the good of the community. This should be viewed as an attempt to organize contributions rather than as a restriction - i.e. as a request to channel creative energies in a common direction rather than merely seeing them spent in different directions. MATLAB is the perfect example of what can be accomplished by the organized development of functions, and the Particle Swarm Optimization Research Toolbox Community-Based Development Project is merely a specialized implementation of a similar thought process.

Other researchers are modifying the code to suit their own research while giving back to the community from which they downloaded the code. As the agreement states, "New code contributed either as a new file or as a new section of code within an existing file shall be referred to as a PSO Research Toolbox Add-in and shall be deemed the intellectual property of its author or authors"; hence, users are encouraged to improve the code and, furthermore, can expect formal acknowledgement of their contributions.

As for the reserved right to improve the terms of use, this is solely to allow the quick resolution of any flaws that might evidence themselves in the future. It has been some time since I made any substantial changes, and I have no plans to do so in the future; but I certainly expect the right to resolve promptly any problems that might come to light.

Sincerely,

George Evers

EricThis looks to be a complete and ready-to-use PSO implementation, however, do note that the downloaded package includes additional terms of use which appear contrary to the BSD License claimed on this File Exchange page. The rights to modify the code appear to be heavily restricted, and the author claims the right to change the terms of use without notice. Consequently, I don't think this really belongs here on the File Exchange, where it implied that submissions are not encumbered with additional restrictions.