Running Particle Swarm Optimization

With our main functions in place and everything initialized from our hyperparameters, we can now focus on being able to run higher level functions. One of our PSO functions is the PSORun method. This method is executed once the user clicks on the Run button . Let's walk through this higher-level function now.

The first thing that we do is to initialize our state by calling our InitState function:

InitState();

After this we will clear out our information tree, create a new stopwatch responsible for timing our function, then run our Swarm_Run method. This will perform the actual function optimization behind the scenes, which usually will happen in just milliseconds depending upon the swarm size, iterations, and dimensions:

advTree1.Nodes.Clear();
SW = new Stopwatch();
SW.Start();
Swarm_Run();
SW.Stop();

Next, we create the variables responsible for tracking the global and individual positions of the entire swarm:

plotSwarmPositions = (double[,,])PlotSwarm.Clone();
plotGlobalPositions = (double[,])PlotGlobal.Clone();
maxIter = plotSwarmPositions.GetLength(0);
maxSwarm = plotSwarmPositions.GetLength(1);

And finally, we initialize our charts, and play back the swarm's plot at a much slower pace so the end user can see what has transpired. We do this via a call to the three methods as follows:

InitChart();
InitializeMeshSurfaceChart();
PlaybackPlot();
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset