2. Description: Capacitated VRP
• Objectives: Minimize the distance travelled by vehicles.
• We have in this problem, a depot and set of customers.
Conditions:
Vehicles with limited and equal capacity.
Each customer is to be visited exactly once.
Each vehicle must start from depot and must return back to depot
4. Sample example of Solution:
The main focus of the project is to solve the capacitated VRP using
particle swarm optimization, and find an optimal route which is the
minimized distance.
Considering 2 vehicles:
Depot
1
6
2
5
3
4
5. Particle Swarm Optimization
• PSO is a population- based search method proposed by Kennedy
and Eberhart in 1995.
• The main motivation or focus here is on a group of birds. This
group of birds is termed as “Swarm”. Here each particle is
considered like a bird in the swarm.
• These particles are allowed to move around and explore the
search space
6. Finding Particles (Solution):
Particles(Swarm) move in a direction which is
guided by-
1. The particle’s own position and velocity
2. Distance from the individual particle’s best
known position. (Pbest)
3. Distance from the swarms best known
position. (Gbest).
7. Flowchart of PSO:
START
Initialize the population, Particles.
Find the personal best
Find the Global best
Update Velocity, Particle position
Evaluate Fitness
STOPPING
CONDITION
END
FALSE
TRUE
8. Equations and formulas
• Position matrix:
Initially:𝑷 𝒊, 𝒋 = 𝑿 𝒎𝒂𝒙 − 𝑿 𝒎𝒊𝒏 ∗ 𝒓𝒂𝒏𝒅 𝟏 + 𝑿 𝒎𝒊𝒏
For updating: 𝑷 𝒊, 𝒋 = 𝑷 𝒊, 𝒋 + 𝑽 𝒊, 𝒋
• Velocity matrix:
Initially:𝑽 𝒊, 𝒋 = 𝑽 𝒎𝒂𝒙 − 𝑽 𝒎𝒊𝒏 ∗ 𝒓𝒂𝒏𝒅 𝟐 + 𝑿 𝒎𝒊𝒏
For updating: 𝑽 𝒊, 𝒋 = 𝒘 ∗ 𝑽 𝒊, 𝒋 + 𝑪 𝟏 ∗ 𝒓 ∗ 𝑷𝒃(𝒊, 𝒋) – 𝒑(𝒊, 𝒋) + 𝑪 𝟐 ∗ 𝒓 ∗ (𝑮𝒃(𝒊) – 𝑷(𝒊, 𝒋))
Where, i:particle,j:population;
Xmax=1,Xmin=-1; rand is random number between 0 and 1
Vmax=1,Vmin=-1,
pb: the best position values for each particle searched so far,
gb:the best particle’s searched among pb;
W =inertia constant
C1=Cognitive acceleration constant
C2=Social acceleration constant
9. Proposed Solution of VRP using PSO
Let us consider that there are 10 customers, with some demand and their distance from
depot and from each other is given, we have ‘4’ identical vehicles with capacity 200.
CUSTOMER DEMAND Coordinates( Distance
from depot)
Depot -
1 20 1
2 70 3
3 50 5
4 80 7
5 100 3
6 30 4
7 10 2
8 40 10
9 20 6
10 60 3
13. Encoding Scheme:
Particle-Vehicle Mapping
Calculation of γ : For dividing the Range into equal interval we will use γ, and it is calculated using the below
formula:
γ = (Pmax - Pmin)/ no. of vehicles
γ = (0.94+0.38/4)
γ = 0.33
Calculation of Interval Ranges: Since we are considering 4 vehicles , interval ranges are 4.
[Pmin,Pmin+γ],[Pmin+γ,Pmin+2γ),[Pmin+2γ,Pmin+3γ),[Pmin+4γ]
[-0.38,-0.05),[-0.05,0.28),[0.28,0.61),(0.61,0.94]
15. Calculation of fitness value (Distance)
2 7 4 6 1 8 3 10 5 9
Vehicle 1 Vehicle 2 Vehicle 4Vehicle 3
1. Distance travelled by vehicle 1= d(0,2)+d(2,7)+d(7,4)+d(4,0)=3+2+6+7=18
2. Distance travelled by vehicle 2= d(0,6)+d(6,1)+d(1,0)=4+5+1=10
3. Distance travelled by vehicle 3= d(0,6)+d(8,0)=4+10=14
4. Distance travelled by vehicle 4=
d(0,3)+d(3,10)+d(10,5)+d(5,9)+d(9,0)=5+7+6+8+6=32
16. • FitnessValue1=D1=18+10+14+32=74
• This way we will evaluate fitness value every time till the
condition is false and loop terminates.
• Fitness value (minimized distance ) calculated in the end is the
potential solution to the problem .