Thank you. I encountered the following problem.
Traceback (most recent call last):
File " in
ea.optimize(solver = "cpso", sync = True)
File "/site-packages/stochopy/evolutionary_algorithm.py", line 293, in optimize
xstart = xstart, sync = sync)
File "/stochopy/evolutionary_algorithm.py", line 755, in _cpso
pbest[idx] = np.array(X[idx])
IndexError: boolean index did not match indexed array along dimension 1; dimension is 80 but corresponding boolean dimension is 1
func = "rastrigin"
# mpi_comm = MPI.COMM_WORLD
# mpi_rank = mpi_comm.Get_rank()
n_dim = 80
popsize = 4 + np.floor(3.*np.log(n_dim))
lower = np.full(n_dim, -40)
upper = np.full(n_dim, -20)
# Initialize solver; calc_cost calculates the residual after running a FEM problem.
ea = Evolutionary(calc_cost, lower = lower, upper = upper, eps1 = 1e-2, popsize = popsize, max_iter = 2000, mpi = False, random_state = -1)
# Solve
starttime = time()
ea.optimize(solver = "cpso", sync = True)
print(ea)
print("Elapsed time: %.2f seconds" % (time() - starttime))