import random import math import matplotlib.pyplot as plt import numpy as np import time def init(b_=700,xSize_=200,iteration_=1000,c1_=0.5,c2_=0.5,w_=0.8): global a,c,b,Dim,xSize,iteration,c1,c2,w,A,C,x,v,xbest,fxbest,gbest,fgbest a = [90, 33, 94, 6…