In [1]:
import numpy as np
from plotPSO import plotPSO_2D, plotPSO_1D
from optitestfuns import ackley, griewangk, rastrigin, salomon, odd_square, schwefel, rana

In [2]:
# Testing 2D plot ackley

limits=([-5,5],
        [-5,5])

x_lo = limits[0][0]
x_up = limits[0][1]
y_lo = limits[1][0]
y_up = limits[1][1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = (x_particles, y_particles)

fig, ax = plotPSO_2D(ackley, limits, particle_xycoordinates)



In [3]:
# Testing 1D plot

limits=(-5,5)

x_lo = limits[0]
x_up = limits[1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = x_particles

fig, ax = plotPSO_1D(ackley, limits, particle_xycoordinates )



In [4]:
# Testing 2D plot Griewangk

limits=([-100,100],
        [-100,100])
0
x_lo = limits[0][0]
x_up = limits[0][1]
y_lo = limits[1][0]
y_up = limits[1][1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = (x_particles, y_particles)

fig, ax = plotPSO_2D(griewangk, limits, particle_xycoordinates)



In [5]:
# Testing 1D plot griewangk

limits=(-100,100)

x_lo = limits[0]
x_up = limits[1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = x_particles

fig, ax = plotPSO_1D(griewangk, limits, particle_xycoordinates )



In [6]:
# Testing 2D plot Rastrigin

limits=([-5.12,5.12],
        [-5.12,5.12])

x_lo = limits[0][0]
x_up = limits[0][1]
y_lo = limits[1][0]
y_up = limits[1][1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = (x_particles, y_particles)

fig, ax = plotPSO_2D(rastrigin, limits, particle_xycoordinates)



In [7]:
# Testing 1D plot Rastrigin

limits=(-5.12,5.12)

x_lo = limits[0]
x_up = limits[1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = x_particles

fig, ax = plotPSO_1D(rastrigin, limits, particle_xycoordinates )



In [8]:
# Testing 2D plot Salomon

limits=([-2,2],
        [-2,2])

x_lo = limits[0][0]
x_up = limits[0][1]
y_lo = limits[1][0]
y_up = limits[1][1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = (x_particles, y_particles)

fig, ax = plotPSO_2D(salomon, limits, particle_xycoordinates)



In [9]:
# Testing 1D plot Salomon

limits=(-2,2)

x_lo = limits[0]
x_up = limits[1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = x_particles

fig, ax = plotPSO_1D(salomon, limits, particle_xycoordinates )



In [10]:
# Testing 2D plot Odd Square

limits=([-5,5],
        [-5,5])

x_lo = limits[0][0]
x_up = limits[0][1]
y_lo = limits[1][0]
y_up = limits[1][1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = (x_particles, y_particles)

fig, ax = plotPSO_2D(odd_square, limits, particle_xycoordinates)



In [11]:
# Testing 1D plot Odd_square

limits=(-5,5)

x_lo = limits[0]
x_up = limits[1]

n_particles = 10

x_particles = np.random.uniform(x_lo, x_up, size=n_particles)
y_particles = np.random.uniform(y_lo, y_up, size=n_particles)

particle_xycoordinates = x_particles

fig, ax = plotPSO_1D(odd_square, limits, particle_xycoordinates )