Skip to content

Commit

Permalink
all snake_case
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulCombal committed Jul 5, 2019
1 parent 45dc911 commit 1369a21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
21 changes: 10 additions & 11 deletions report.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
iterations,temps,distance,temperature,memory
5000,27.38643765449524,30585.351928539098,0.6721111959865606,57221120
10000,34.95672869682312,24959.320052117782,0.4520495689035214,78159872
15000,42.36410355567932,22355.65496850863,0.3038679424228721,78770176
20000,49.582820653915405,20586.442074826,0.20426018026358692,79192064
25000,57.07359457015991,19330.841251950715,0.13730379357770844,79192064
30000,64.29938006401062,18378.562686813006,9.23079397837336,79192064
35000,71.69990468025208,17738.866524289828,6.204944249678936,79630336
40000,78.93442893028259,17125.53794647948,4.170966574687698,79630336
45000,86.24125695228577,16833.02906081847,2.8037257817525405,79630336
50000,93.65385031700134,16518.501560679957,1.8846658486714118,79896576
55000,101.00880336761475,16066.872733874745,1.2668733098884215,80166912
5000,1.199178695678711,493.3990958005079,0.6721111959865606,56467456
10000,1.9728262424468994,422.7406518985165,0.4520495689035214,70680576
15000,2.555943727493286,422.7406518985165,0.3038679424228721,70975488
20000,3.1493828296661377,419.07264385271634,0.20426018026358692,71512064
25000,3.7523446083068848,419.07264385271634,0.13730379357770844,71782400
30000,4.338656902313232,419.07264385271634,9.23079397837336,71782400
35000,4.923287868499756,419.07264385271634,6.204944249678936,71782400
40000,5.569959878921509,419.07264385271634,4.170966574687698,72101888
45000,6.152648687362671,419.07264385271634,2.8037257817525405,72101888
50000,6.784815311431885,419.07264385271634,1.8846658486714118,72368128
14 changes: 7 additions & 7 deletions sa.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,22 @@ def SA(cities, temperatures):
[i,j] = sorted(random.sample(range(city_count),2))
newTour = tour[:i] + tour[j:j+1] + tour[i+1:j] + tour[i:i+1] + tour[j+1:]

oldDistances = distance_between(tour, cities, i, j)
newDistances = distance_between(newTour, cities, i, j)
newTotalDist = distance(newTour, cities)
old_distances = distance_between(tour, cities, i, j)
new_distances = distance_between(newTour, cities, i, j)
new_tour_distance = distance(newTour, cities)

if math.exp( (oldDistances - newDistances) / temperature) > random.random():
if math.exp( (old_distances - new_distances) / temperature) > random.random():
tour = copy.copy(newTour)

if newTotalDist < lowest_distance:
lowest_distance = newTotalDist
if new_tour_distance < lowest_distance:
lowest_distance = new_tour_distance
lowest_tour = copy.copy(tour)

if(iteration % 5000 == 0):
seconds_elapsed = time.time() - time_start
print("Iteration: " + str(iteration))
print("Elapsed: {:10.4f}s".format(seconds_elapsed))
print("New distance: {:10.4f}".format(newTotalDist))
print("New distance: {:10.4f}".format(new_tour_distance))
print("Best distance: {:10.4f}".format(lowest_distance))
print("Temperature: " + str(temperature))
print("Memory used: " + str(memory().rss))
Expand Down

2 comments on commit 1369a21

@ChaymaARAAR
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonjour Mr Paul,
Je voulais savoir si c'est possible de prendre en considération les capacites qi des véhicules.
Et merci

@PaulCombal
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonjour,
Ce dépôt est le résultat d'un projet que j'ai dû faire dans le cadre de mes études, je n'y ai pas touché depuis la fin du projet il y a maintenant deux ans. Il fait office d'archive et je n'ai malheureusement plus le temps ni le besoin de l'entretenir. Il est bien sûr libre de droit, n'hésitez pas à fork et PR.
Thanks!

Please sign in to comment.