Skip to content

Commit

Permalink
meme depot
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulCombal committed Jul 3, 2019
1 parent fed0df6 commit b9d4a4a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python : Fichier actuel",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": ["-d", "france", "-k", "2"]
}
]
}
22 changes: 9 additions & 13 deletions report.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
iterations,temps,distance,temperature
5000,0.6915416717529297,443.7492402983678,0.6721111959865606
10000,1.3146755695343018,443.7492402983678,0.4520495689035214
15000,1.7231664657592773,439.9078521514258,0.3038679424228721
20000,2.1277782917022705,439.9078521514258,0.20426018026358692
25000,2.5334930419921875,435.0390435921546,0.13730379357770844
30000,2.973337411880493,435.0390435921546,9.23079397837336
35000,3.3832550048828125,435.0390435921546,6.204944249678936
40000,3.7914462089538574,435.0390435921546,4.170966574687698
45000,4.204490900039673,435.0390435921546,2.8037257817525405
50000,4.610482931137085,435.0390435921546,1.8846658486714118
55000,5.0188446044921875,435.0390435921546,1.2668733098884215
60000,5.4173479080200195,435.0390435921546,0.8515928616412607
65000,5.86414647102356,435.0390435921546,0.572441140197534
5000,0.6726222038269043,394.0393228983444,0.6721111959865606
10000,1.224958896636963,388.92345886053005,0.4520495689035214
15000,1.6406912803649902,357.8642383206773,0.3038679424228721
20000,2.0548038482666016,357.8642383206773,0.20426018026358692
25000,2.5010344982147217,357.8642383206773,0.13730379357770844
30000,2.9658334255218506,357.8642383206773,9.23079397837336
35000,3.3777987957000732,357.8642383206773,6.204944249678936
40000,3.7791998386383057,357.8642383206773,4.170966574687698
45000,4.1899638175964355,357.8642383206773,2.8037257817525405
19 changes: 10 additions & 9 deletions sa.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def SA(cities, temperatures):
try:
for temperature in temperatures():
iteration = iteration + 1

[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:]

Expand Down Expand Up @@ -139,6 +140,7 @@ def SA(cities, temperatures):


# Initialisation des données

plt.ion()
plt.show()
external_dataset = dataset_name()
Expand Down Expand Up @@ -166,22 +168,21 @@ def SA(cities, temperatures):
explain_tour(tour, cities)

# Division en k camions
print("\nDivision en camions\n")
k = int(args.k)
tour_distance = distance(tour, cities)
i = 0
position_first_city = tour.index(0)
position_relative_next_stop_city = 0
initial_tour = copy.copy(tour)

for truck in range(k-1):
distance_cumulee = 0
while distance_cumulee < (tour_distance / k):
curr = tour[i % city_count]
next = tour[(i + 1) % city_count]
distance = distance_to_next(tour, cities, i)

curr = initial_tour[(position_first_city + position_relative_next_stop_city) % city_count]
distance = distance_to_next(initial_tour, cities, position_first_city + position_relative_next_stop_city)
distance_cumulee += distance
i += 1
position_relative_next_stop_city += 1

tour.insert(i, tour[0])
tour.insert(i+1, tour[i+1])
tour.insert((position_first_city + position_relative_next_stop_city) % city_count, 0)

live_plot(tour, cities)

Expand Down

0 comments on commit b9d4a4a

Please sign in to comment.