-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.py
More file actions
23 lines (23 loc) · 1.2 KB
/
update.py
File metadata and controls
23 lines (23 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
def update(routes, liste, dico, rho, alpha, Q):
for route, number, scores in routes:
if scores != -99:
for i in range(len(route)):
if i == 0:
dico["mat1"][liste["liste1"].index(route[i])] **= 1 / alpha
dico["mat1"][liste["liste1"].index(route[i])] *= rho
dico["mat1"][liste["liste1"].index(route[i])] += number * Q
dico["mat1"][liste["liste1"].index(route[i])] **= alpha
else:
dico[f"mat{i+1}"][liste[f"liste{i}"].index(route[i - 1])][
liste[f"liste{i+1}"].index(route[i])
] **= (1 / alpha)
dico[f"mat{i+1}"][liste[f"liste{i}"].index(route[i - 1])][
liste[f"liste{i+1}"].index(route[i])
] *= rho
dico[f"mat{i+1}"][liste[f"liste{i}"].index(route[i - 1])][
liste[f"liste{i+1}"].index(route[i])
] += (number * Q)
dico[f"mat{i+1}"][liste[f"liste{i}"].index(route[i - 1])][
liste[f"liste{i+1}"].index(route[i])
] **= alpha