Skip to content
Snippets Groups Projects
Commit 553fb84f authored by Matthieu Oberon's avatar Matthieu Oberon
Browse files

fix MMAS

parent 25e82dad
Branches
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment