From 6ba82fa28fb68644b2cee16976fd69d834709001 Mon Sep 17 00:00:00 2001 From: zStupan <48752988+zStupan@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:12:50 +0200 Subject: [PATCH] fixed numpy compatibility errors --- niapy/algorithms/modified/shade.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/niapy/algorithms/modified/shade.py b/niapy/algorithms/modified/shade.py index d753e677..deefd65b 100644 --- a/niapy/algorithms/modified/shade.py +++ b/niapy/algorithms/modified/shade.py @@ -271,7 +271,7 @@ def evolve(self, pop, hist_cr, hist_f, archive, arc_ind_cnt, task, **_kwargs): """ new_pop = objects_to_array([self.gen_ind_params(xi, hist_cr, hist_f) for xi in pop]) - p_num = np.int_(np.around(len(pop) * self.pbest_factor)) + p_num = round(len(pop) * self.pbest_factor) if p_num < 2: p_num = 2 # cr and f for mutation are computed @@ -309,7 +309,7 @@ def selection(self, pop, new_pop, archive, arc_ind_cnt, best_x, best_fitness, ta success_f = np.asarray([]) # array for storing successful f values success_cr = np.asarray([]) # array for storing successful cr values fitness_diff = np.asarray([]) # array for storing the difference of fitness of new individuals - archive_size = np.int_(np.around(len(pop) * self.extern_arc_rate)) + archive_size = round(len(pop) * self.extern_arc_rate) arr = np.copy(pop) for i, vi in enumerate(new_pop): if vi.f == pop[i].f: @@ -380,7 +380,7 @@ def init_population(self, task): h_mem_f = np.full(self.hist_mem_size, 0.5) # all values in the historical memory for parameters f and cr are initialized to 0.5 k = 0 # the starting memory position is set to 1 - arc_size = np.int_(np.around(self.population_size * self.extern_arc_rate)) + arc_size = round(self.population_size * self.extern_arc_rate) archive = np.zeros((arc_size, task.dimension)) # the external archive of max size pop_size * arc_rate is initialized arc_ind_cnt = 0 # the number of archive elements is set to 0 @@ -514,7 +514,7 @@ def post_selection(self, pop, arc, arc_ind_cnt, task, xb, fxb, **kwargs): max_nfe = task.max_evals nfe = task.evals - next_pop_size = np.int_(np.around((((4.0 - self.population_size) / np.float_(max_nfe)) * nfe) + self.population_size)) + next_pop_size = round((((4.0 - self.population_size) / max_nfe) * nfe) + self.population_size) if next_pop_size < 4: next_pop_size = 4 @@ -529,7 +529,7 @@ def post_selection(self, pop, arc, arc_ind_cnt, task, xb, fxb, **kwargs): worst = j if e.f > pop[worst].f else worst pop = np.delete(pop, worst) - next_arc_size = np.int_(next_pop_size * self.extern_arc_rate) # the size of the new archive + next_arc_size = int(next_pop_size * self.extern_arc_rate) # the size of the new archive if arc_ind_cnt > next_arc_size: arc_ind_cnt = next_arc_size