What is a particle?

One of the main components we are going to be dealing with is what is known as a particle—hence, Particle Swarm Optimization. To briefly provide an analogy as to what a particle is, let's look at it this way. Let's say that we see a flock of birds flying in the sky. Each bird in this flock is a particle. We see a school of fish swimming in the water. Each fish is a particle. We knocked down that bee hive and were attacked by hundreds of bees. Each bee that attacked us was, you got it, a particle!

Each particle has fitness values which, once evaluated by the fitness function to be optimized, will tell us how it ranks in the swarm. Additionally, we also have velocities that direct the flying of each particle. The particles, like the birds, fly through our problem space by following the optimum particle, which would be the leader of the flock of birds.

Now that we know exactly what a particle is, how do we describe it in computational terms? We will define a structure like the following:

/// <summary> A particle. </summary>
public struct Particle
{
/// <summary> The position of the particle. </summary>
public double[] Position;
/// <summary> The speed of the particle. </summary>
public double[] Speed;
/// <summary> The fitness value of the particle. </summary>
public double FitnessValue;
/// <summary> The best position of the particle. </summary>
public double[] BestPosition;
/// <summary> The best fitness value of the particle. </summary>
public double BestFitnessValue;
}

With that behind us, let's go ahead and create our project. You should have Microsoft Visual Studio installed and open. If you have not installed Microsoft Visual Studio yet, you can install the free Community Version from the Microsoft web site. Once this is complete, open Microsoft Visual Studio and create a Windows Forms project as shown in the following screenshot. In our instance we are using .NET version 4.7.1. Feel free to use whatever version you have, but it needs to be at least version 4.5.2 or higher:

 

New Project Window

Next, let me mention that our user interface is created with a third-party product called DotNetBar. This is a fantastic, light weight user-interface library. It can be found here: http://www.devcomponents.com/dotnetbar/. We are now free to begin to focus on the formulation of our project. We will need to initialize some general areas of our program, such as the Swarm, the Chart, and the State.

..................Content has been hidden....................

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