From 553fb84fc98d5ca2b64a24be79a95d8047f7ed85 Mon Sep 17 00:00:00 2001 From: alberich <matthieu.oberon@student-cs.fr> Date: Mon, 5 Apr 2021 17:30:25 +0200 Subject: [PATCH] fix MMAS --- Appli-iso3dfd/ACO.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Appli-iso3dfd/ACO.py b/Appli-iso3dfd/ACO.py index 3770648..f84501b 100644 --- a/Appli-iso3dfd/ACO.py +++ b/Appli-iso3dfd/ACO.py @@ -103,8 +103,9 @@ def ACO(Me, NbP, comm, alpha, rho, Q, nb_ants, tau_0, n_iter, n1_max=256, n2_max best_p = paths[np.argmin(costs), :] #we compare the best paths of all process and we save only the best one - recv_table = np.empty(2) - comm.Allreduce(np.array([best_cost, Me]), recv_table, OP=MPI.MINLOC) + recv_table = (0., 0) + send_table = (best_cost, Me) + recv_table = comm.allreduce(send_table, op=MPI.MINLOC) best_cost = recv_table[0] best_p = comm.bcast(best_p, root=recv_table[1]) @@ -113,13 +114,7 @@ def ACO(Me, NbP, comm, alpha, rho, Q, nb_ants, tau_0, n_iter, n1_max=256, n2_max tau = tools.add_pheromones(tau, np.array([best_p]), np.array([[best_cost]]), Q, n1_size, n2_size, n3_size, n_cbx, n_cby) #verification of the threshold constraint - size = np.size(tau) - for i in range(size[0]): - for j in range(size[1]): - if tau[i][j] < sub_threshold: - tau[i][j] = sub_threshold - if tau[i][j] > sup_threshold: - tau[i][j] = sup_threshold + np.clip(tau, sub_threshold, sup_threshold) #we update the best path on all iteration if best_cost < cost_opti: -- GitLab