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

change fitness to throughput

parent 04875458
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,7 @@ def ACO(Me, NbP, comm, alpha, rho, Q, nb_ants, tau_0, n_iter, n1=256, n2=256, n3
comm.Gather(costs, all_costs, root=0)
if Me == 0:
tau, best_p, best_cost = compute_tau.compute_tau(tau, all_paths, all_costs, Q, rho, n1, n2, n3)
tau, best_p, best_cost = compute_tau.compute_tau(tau, all_paths, all_costs, Q, rho, n1, n2, n3, fancy_strategy, sub_threshold, sup_threshold)
if best_cost < cost_opti:
cost_opti = best_cost
path_opti = best_p
......@@ -90,9 +90,9 @@ if __name__ == "__main__":
# Initialization of hyperparameters
alpha = 1
rho = 0.1
Q = 10
Q = 0.1
nb_ants = 2
tau_0 = Q/nb_ants
tau_0 = Q*100
n_iter = 1
# Parameters for compilation and execution of iso3dfd
......@@ -113,8 +113,9 @@ if __name__ == "__main__":
path_opti, cost_opti = ACO(Me, NbP, comm, alpha, rho, Q, nb_ants, tau_0, n_iter,
n1=n1, n2=n2, n3=n3, fancy_strategy=fancy_strategy,
nb_threads=nb_threads, reps=reps)
print(path_opti)
print(cost_opti)
print(f"Le chemin optimal est {path_opti}.")
print(f"Le throughput associé est alors {-1*cost_opti}.")
else:
ACO(Me, NbP, comm, alpha, rho, Q, nb_ants, tau_0, n_iter,
n1=n1, n2=n2, n3=n3, fancy_strategy=fancy_strategy,
......
......@@ -32,16 +32,16 @@ def compute_tau(tau, all_paths, all_costs, Q, rho, n1, n2, n3, fancy_strategy='A
if fancy_strategy == "AS" or fancy_strategy == 'ElitistAS':
#Classic Ant System : each path is rewarded according to its length
#Elitist Ant System : each path is rewarded according to its length
tau[0,p[0]] += Q/cost
tau[p[0],n1//16+p[1]] += Q/cost
tau[n1//16+p[1],n1//16+n2+p[2]] += Q/cost
tau[0,p[0]] += Q*(-1)*cost
tau[p[0],n1//16+p[1]] += Q*(-1)*cost
tau[n1//16+p[1],n1//16+n2+p[2]] += Q*(-1)*cost
if fancy_strategy == 'ElitistAS' or fancy_strategy == "MMAS":
#Elitist Ant System : The best ant is rewarded a second time
#Max-Min Ant System : Only the winner ant is rewarded but the pheromon are limited within a minimal and a maximal threshold
tau[0,best_p[0]] += Q/best_cost
tau[best_p[0],n1//16+best_p[1]] += Q/best_cost
tau[n1//16+best_p[1],n1//16+n2+best_p[2]] += Q/best_cost
tau[0,best_p[0]] += Q*(-1)*best_cost
tau[best_p[0],n1//16+best_p[1]] += Q*(-1)*best_cost
tau[n1//16+best_p[1],n1//16+n2+best_p[2]] += Q*(-1)*best_cost
if fancy_strategy == "MMAS":
#verification of the threshold constraint
......
......@@ -41,12 +41,12 @@ def deploySUBP(n1, n2, n3, nb_threads, reps, cbx, cby, cbz):
times, throughputs, gflops, runs = tools.commandLineExtract(res)
# Fitness calculation
fitness = 0.
for time in times:
fitness += time
for throughput in throughputs:
fitness += throughput
if res:
fitness /= len(times)
fitness /= len(throughputs)
return fitness
return -1*fitness
#-----------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment