Report For Problem Set 4: Thinh On - 900352973
Report For Problem Set 4: Thinh On - 900352973
Thinh On - 900352973
1. Problem 1
Find the minimas for the McCormick function:
f (x, y) = sin(x+y)+(x−y)2 −1.5x+2.5y+1 within the range of: −1.5 ≤ x ≤ 4 and −3 ≤ y ≤ 4.
(1) Hyperparameters:
• Inertia weight w = 0.25
• Personalized weight c1 = 0.45
• Socialized weight c2 = 0.70
• Target minimum value = -1.9132229. This value was obtained from many trial runs
and selected the smallest possible value.
• Population or number of particles = 50 particles.
• Tolerance = 1 × 10−6 . This value is used to check for convergence.
• Maximum number of iterations = 50 iterations.
• There are also two random numbers r1 and r2 within range (0, 1).
(2) Figure 1 shows the value of global minimum found by PSO algorithm at each iteration.
After many trial runs, the minimum value that the PSO optimizer can give is -1.9132229, which
can be used as the target value of the PSO algorithm so that it can converge faster.
1
Figure 1: Global minimum versus iteration.
(3) If we try to run the model five times, the results are always different because we used random
number generators to initialize the particles. Also, there are coefficients r1 and r2 which are
also random numbers within range (0,1). Random number generator may give different outputs
if we don’t control the randomness by seeding. Figure 2 to 6 illustrate the disparities between
five runs of the PSO algorithm.
2
Figure 3: Run #2.
3
Figure 5: Run #4.
4
2. Problem 2
Find minimas of the function:
f (x, y) = (x2 + y − 11)2 + (x + y 2 − 7)2 , within the range of −5 ≤ x ≤ 5 and −5 ≤ y ≤ 5.
(1) Figure 7 and 8 illustrate the values of f (x, y) at different values of x and y. Resolution of
the figures is 0.5 for both x and y as shown in the heatmap and the surface plot.
(2) From the 2D heatmap and the 3D surface plot, there are four local minimas within the
contraint range.
(3) After implementing PSO optimizer, one of the local minimas can be obtained at x = 3.585
and y = −1.848, the value of that local minimum is appoximately zero. Hyperparameters that
were used in this PSO optimizer:
5
• Inertia weight w = 0.35
• Personalized weight c1 = 0.45
• Socialized weight c2 = 0.55
• Target minimum value = 0.
• Population or number of particles = 100 particles.
• Tolerance = 1 × 10−6 . This value is used to check for convergence.
• Maximum number of iterations = 50 iterations.
(4) In order to find all the local minimas within the given range of x and y, the number of
particles and their distribution should be adjusted so that their initial position (initial x
and y) can cover most of the search space. We can increase the number of particles to ensure
there is ”enough” population to cover the search space, but note that too many particles may
result in longer runtime.
On the other hand, if there are too many particles but unluckily all of them are too far away from
a local minimum, the algorithm cannot search for that local minimum. In order to increase
the possibility that the population can cover all the local minimas, we can apply uniform
distribution or normal distribution with high variance into the random number generators
during initializing the position of particles. These types of distribution can help cover most of
the search space and increase the possibility to find all of the local minimas.