Skip to content

Commit 1cbc417

Browse files
committed
Adds scenarios and benchmarks
1 parent 36fd336 commit 1cbc417

File tree

9 files changed

+851
-263
lines changed

9 files changed

+851
-263
lines changed

medium.csv

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,43 @@ cust,x,y,demand,from,to,service
3333
32,10.00,35.00,20.00,200.00,237.00,90.00
3434
33,10.00,40.00,30.00,31.00,100.00,90.00
3535
34,8.00,40.00,40.00,87.00,158.00,90.00
36+
35,8.00,45.00,20.00,751.00,816.00,90.00
37+
36,5.00,35.00,10.00,283.00,344.00,90.00
38+
37,5.00,45.00,10.00,665.00,716.00,90.00
39+
38,2.00,40.00,20.00,383.00,434.00,90.00
40+
39,0.00,40.00,30.00,479.00,522.00,90.00
41+
40,0.00,45.00,20.00,567.00,624.00,90.00
42+
41,35.00,30.00,10.00,264.00,321.00,90.00
43+
42,35.00,32.00,10.00,166.00,235.00,90.00
44+
43,33.00,32.00,20.00,68.00,149.00,90.00
45+
44,33.00,35.00,10.00,16.00,80.00,90.00
46+
45,32.00,30.00,10.00,359.00,412.00,90.00
47+
46,30.00,30.00,10.00,541.00,600.00,90.00
48+
47,30.00,32.00,30.00,448.00,509.00,90.00
49+
48,30.00,35.00,10.00,1054.00,1127.00,90.00
50+
49,28.00,30.00,10.00,632.00,693.00,90.00
51+
50,28.00,35.00,10.00,1001.00,1066.00,90.00
52+
51,26.00,32.00,10.00,815.00,880.00,90.00
53+
52,25.00,30.00,10.00,725.00,786.00,90.00
54+
53,25.00,35.00,10.00,912.00,969.00,90.00
55+
54,44.00,5.00,20.00,286.00,347.00,90.00
56+
55,42.00,10.00,40.00,186.00,257.00,90.00
57+
56,42.00,15.00,10.00,95.00,158.00,90.00
58+
57,40.00,5.00,30.00,385.00,436.00,90.00
59+
58,40.00,15.00,40.00,35.00,87.00,90.00
60+
59,38.00,5.00,30.00,471.00,534.00,90.00
61+
60,38.00,15.00,10.00,651.00,740.00,90.00
62+
61,35.00,5.00,20.00,562.00,629.00,90.00
63+
62,50.00,30.00,10.00,531.00,610.00,90.00
64+
63,50.00,35.00,20.00,262.00,317.00,90.00
65+
64,50.00,40.00,50.00,171.00,218.00,90.00
66+
65,48.00,30.00,10.00,632.00,693.00,90.00
67+
66,48.00,40.00,10.00,76.00,129.00,90.00
68+
67,47.00,35.00,10.00,826.00,875.00,90.00
69+
68,47.00,40.00,10.00,12.00,77.00,90.00
70+
69,45.00,30.00,10.00,734.00,777.00,90.00
71+
70,45.00,35.00,10.00,916.00,969.00,90.00
72+
71,95.00,30.00,30.00,387.00,456.00,90.00
73+
72,95.00,35.00,20.00,293.00,360.00,90.00
74+
73,53.00,30.00,10.00,450.00,505.00,90.00
75+
74,92.00,30.00,10.00,478.00,551.00,90.00

out.csv

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1 @@
1-
name,demand,service,from_,to,coord,is_depot,step
2-
3,17,90.0,825.0,870.0,"(45.0, 70.0)",False,4
3-
16,35,90.0,384.0,429.0,"(20.0, 80.0)",False,6
4-
28,15,90.0,261.0,316.0,"(23.0, 52.0)",False,8
5-
13,26,90.0,652.0,721.0,"(25.0, 85.0)",False,9
6-
27,19,90.0,622.0,701.0,"(25.0, 55.0)",False,12
7-
6,20,90.0,15.0,67.0,"(42.0, 65.0)",False,13
8-
9,39,90.0,255.0,324.0,"(38.0, 68.0)",False,14
9-
21,5,90.0,10.0,73.0,"(30.0, 50.0)",False,16
10-
33,22,90.0,31.0,100.0,"(10.0, 40.0)",False,18
11-
18,19,90.0,99.0,148.0,"(18.0, 75.0)",False,19
12-
25,7,90.0,65.0,144.0,"(25.0, 50.0)",False,20
13-
22,29,90.0,914.0,965.0,"(30.0, 52.0)",False,21
14-
18,26,90.0,99.0,148.0,"(18.0, 75.0)",False,22
15-
20,15,90.0,278.0,345.0,"(15.0, 80.0)",False,23
16-
24,12,90.0,732.0,777.0,"(28.0, 55.0)",False,24
17-
26,6,90.0,169.0,224.0,"(25.0, 52.0)",False,26
18-
22,2,90.0,914.0,965.0,"(30.0, 52.0)",False,27
19-
20,20,90.0,278.0,345.0,"(15.0, 80.0)",False,28
20-
10,22,90.0,534.0,605.0,"(38.0, 70.0)",False,30
21-
18,21,90.0,99.0,148.0,"(18.0, 75.0)",False,32
22-
3,24,90.0,825.0,870.0,"(45.0, 70.0)",False,34
23-
16,38,90.0,384.0,429.0,"(20.0, 80.0)",False,35
24-
17,40,90.0,475.0,528.0,"(20.0, 85.0)",False,37
25-
25,36,90.0,65.0,144.0,"(25.0, 50.0)",False,38
26-
11,38,90.0,357.0,410.0,"(35.0, 66.0)",False,40
27-
21,26,90.0,10.0,73.0,"(30.0, 50.0)",False,41
28-
8,11,90.0,170.0,225.0,"(40.0, 66.0)",False,42
29-
34,25,90.0,87.0,158.0,"(8.0, 40.0)",False,43
30-
28,20,90.0,261.0,316.0,"(23.0, 52.0)",False,44
31-
12,2,90.0,448.0,505.0,"(35.0, 69.0)",False,46
32-
33,0,90.0,31.0,100.0,"(10.0, 40.0)",False,49
33-
33,36,90.0,31.0,100.0,"(10.0, 40.0)",False,50
34-
22,12,90.0,914.0,965.0,"(30.0, 52.0)",False,52
35-
5,4,90.0,727.0,782.0,"(42.0, 68.0)",False,53
36-
4,2,90.0,65.0,146.0,"(42.0, 66.0)",False,54
37-
3,19,90.0,825.0,870.0,"(45.0, 70.0)",False,55
38-
20,27,90.0,278.0,345.0,"(15.0, 80.0)",False,58
39-
21,8,90.0,10.0,73.0,"(30.0, 50.0)",False,60
40-
4,11,90.0,65.0,146.0,"(42.0, 66.0)",False,61
41-
10,26,90.0,534.0,605.0,"(38.0, 70.0)",False,64
42-
8,21,90.0,170.0,225.0,"(40.0, 66.0)",False,65
43-
14,39,90.0,30.0,92.0,"(22.0, 75.0)",False,68
44-
3,5,90.0,825.0,870.0,"(45.0, 70.0)",False,69
45-
3,21,90.0,825.0,870.0,"(45.0, 70.0)",False,70
46-
28,27,90.0,261.0,316.0,"(23.0, 52.0)",False,71
47-
14,26,90.0,30.0,92.0,"(22.0, 75.0)",False,72
48-
17,19,90.0,475.0,528.0,"(20.0, 85.0)",False,73
49-
32,3,90.0,200.0,237.0,"(10.0, 35.0)",False,79
50-
17,23,90.0,475.0,528.0,"(20.0, 85.0)",False,80
51-
13,37,90.0,652.0,721.0,"(25.0, 85.0)",False,81
52-
25,9,90.0,65.0,144.0,"(25.0, 50.0)",False,82
53-
30,38,90.0,358.0,405.0,"(20.0, 50.0)",False,83
54-
21,36,90.0,10.0,73.0,"(30.0, 50.0)",False,84
55-
14,28,90.0,30.0,92.0,"(22.0, 75.0)",False,85
56-
23,6,90.0,812.0,883.0,"(28.0, 52.0)",False,86
57-
2,35,90.0,912.0,967.0,"(45.0, 68.0)",False,87
58-
22,25,90.0,914.0,965.0,"(30.0, 52.0)",False,88
59-
32,12,90.0,200.0,237.0,"(10.0, 35.0)",False,89
60-
10,11,90.0,534.0,605.0,"(38.0, 70.0)",False,90
61-
34,30,90.0,87.0,158.0,"(8.0, 40.0)",False,91
62-
3,17,90.0,825.0,870.0,"(45.0, 70.0)",False,92
63-
24,9,90.0,732.0,777.0,"(28.0, 55.0)",False,94
64-
24,0,90.0,732.0,777.0,"(28.0, 55.0)",False,96
65-
19,6,90.0,179.0,254.0,"(15.0, 75.0)",False,97
1+

scenario.csv

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,66 @@
11
name,demand,service,from_,to,coord,is_depot,step
2-
3,17,90.0,825.0,870.0,"(45.0, 70.0)",False,4
3-
16,35,90.0,384.0,429.0,"(20.0, 80.0)",False,6
4-
28,15,90.0,261.0,316.0,"(23.0, 52.0)",False,8
5-
13,26,90.0,652.0,721.0,"(25.0, 85.0)",False,9
6-
27,19,90.0,622.0,701.0,"(25.0, 55.0)",False,12
7-
6,20,90.0,15.0,67.0,"(42.0, 65.0)",False,13
8-
9,39,90.0,255.0,324.0,"(38.0, 68.0)",False,14
9-
21,5,90.0,10.0,73.0,"(30.0, 50.0)",False,16
10-
33,22,90.0,31.0,100.0,"(10.0, 40.0)",False,18
11-
18,19,90.0,99.0,148.0,"(18.0, 75.0)",False,19
12-
25,7,90.0,65.0,144.0,"(25.0, 50.0)",False,20
13-
22,29,90.0,914.0,965.0,"(30.0, 52.0)",False,21
14-
18,26,90.0,99.0,148.0,"(18.0, 75.0)",False,22
15-
20,15,90.0,278.0,345.0,"(15.0, 80.0)",False,23
16-
24,12,90.0,732.0,777.0,"(28.0, 55.0)",False,24
17-
26,6,90.0,169.0,224.0,"(25.0, 52.0)",False,26
18-
22,2,90.0,914.0,965.0,"(30.0, 52.0)",False,27
19-
20,20,90.0,278.0,345.0,"(15.0, 80.0)",False,28
20-
10,22,90.0,534.0,605.0,"(38.0, 70.0)",False,30
21-
18,21,90.0,99.0,148.0,"(18.0, 75.0)",False,32
22-
3,24,90.0,825.0,870.0,"(45.0, 70.0)",False,34
23-
16,38,90.0,384.0,429.0,"(20.0, 80.0)",False,35
24-
17,40,90.0,475.0,528.0,"(20.0, 85.0)",False,37
25-
25,36,90.0,65.0,144.0,"(25.0, 50.0)",False,38
26-
11,38,90.0,357.0,410.0,"(35.0, 66.0)",False,40
27-
21,26,90.0,10.0,73.0,"(30.0, 50.0)",False,41
28-
8,11,90.0,170.0,225.0,"(40.0, 66.0)",False,42
29-
34,25,90.0,87.0,158.0,"(8.0, 40.0)",False,43
30-
28,20,90.0,261.0,316.0,"(23.0, 52.0)",False,44
31-
12,2,90.0,448.0,505.0,"(35.0, 69.0)",False,46
2+
3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,100
3+
16,0,90.0,384.0,429.0,"(20.0, 80.0)",False,6
4+
28,0,90.0,261.0,316.0,"(23.0, 52.0)",False,8
5+
13,0,90.0,652.0,721.0,"(25.0, 85.0)",False,9
6+
27,0,90.0,622.0,701.0,"(25.0, 55.0)",False,12
7+
6,0,90.0,15.0,67.0,"(42.0, 65.0)",False,13
8+
9,0,90.0,255.0,324.0,"(38.0, 68.0)",False,14
9+
21,0,90.0,10.0,73.0,"(30.0, 50.0)",False,16
10+
33,0,90.0,31.0,100.0,"(10.0, 40.0)",False,18
11+
18,0,90.0,99.0,148.0,"(18.0, 75.0)",False,19
12+
25,0,90.0,65.0,144.0,"(25.0, 50.0)",False,20
13+
22,0,90.0,914.0,965.0,"(30.0, 52.0)",False,21
14+
18,0,90.0,99.0,148.0,"(18.0, 75.0)",False,22
15+
20,0,90.0,278.0,345.0,"(15.0, 80.0)",False,23
16+
24,0,90.0,732.0,777.0,"(28.0, 55.0)",False,24
17+
26,0,90.0,169.0,224.0,"(25.0, 52.0)",False,26
18+
22,0,90.0,914.0,965.0,"(30.0, 52.0)",False,27
19+
20,0,90.0,278.0,345.0,"(15.0, 80.0)",False,28
20+
10,0,90.0,534.0,605.0,"(38.0, 70.0)",False,30
21+
18,0,90.0,99.0,148.0,"(18.0, 75.0)",False,32
22+
3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,34
23+
16,0,90.0,384.0,429.0,"(20.0, 80.0)",False,35
24+
17,0,90.0,475.0,528.0,"(20.0, 85.0)",False,37
25+
25,0,90.0,65.0,144.0,"(25.0, 50.0)",False,38
26+
11,0,90.0,357.0,410.0,"(35.0, 66.0)",False,40
27+
21,0,90.0,10.0,73.0,"(30.0, 50.0)",False,41
28+
8,0,90.0,170.0,225.0,"(40.0, 66.0)",False,42
29+
34,0,90.0,87.0,158.0,"(8.0, 40.0)",False,43
30+
28,0,90.0,261.0,316.0,"(23.0, 52.0)",False,44
31+
12,0,90.0,448.0,505.0,"(35.0, 69.0)",False,46
3232
33,0,90.0,31.0,100.0,"(10.0, 40.0)",False,49
33-
33,36,90.0,31.0,100.0,"(10.0, 40.0)",False,50
34-
22,12,90.0,914.0,965.0,"(30.0, 52.0)",False,52
35-
5,4,90.0,727.0,782.0,"(42.0, 68.0)",False,53
36-
4,2,90.0,65.0,146.0,"(42.0, 66.0)",False,54
37-
3,19,90.0,825.0,870.0,"(45.0, 70.0)",False,55
38-
20,27,90.0,278.0,345.0,"(15.0, 80.0)",False,58
39-
21,8,90.0,10.0,73.0,"(30.0, 50.0)",False,60
40-
4,11,90.0,65.0,146.0,"(42.0, 66.0)",False,61
41-
10,26,90.0,534.0,605.0,"(38.0, 70.0)",False,64
42-
8,21,90.0,170.0,225.0,"(40.0, 66.0)",False,65
43-
14,39,90.0,30.0,92.0,"(22.0, 75.0)",False,68
44-
3,5,90.0,825.0,870.0,"(45.0, 70.0)",False,69
45-
3,21,90.0,825.0,870.0,"(45.0, 70.0)",False,70
46-
28,27,90.0,261.0,316.0,"(23.0, 52.0)",False,71
47-
14,26,90.0,30.0,92.0,"(22.0, 75.0)",False,72
48-
17,19,90.0,475.0,528.0,"(20.0, 85.0)",False,73
49-
32,3,90.0,200.0,237.0,"(10.0, 35.0)",False,79
50-
17,23,90.0,475.0,528.0,"(20.0, 85.0)",False,80
51-
13,37,90.0,652.0,721.0,"(25.0, 85.0)",False,81
52-
25,9,90.0,65.0,144.0,"(25.0, 50.0)",False,82
53-
30,38,90.0,358.0,405.0,"(20.0, 50.0)",False,83
54-
21,36,90.0,10.0,73.0,"(30.0, 50.0)",False,84
55-
14,28,90.0,30.0,92.0,"(22.0, 75.0)",False,85
56-
23,6,90.0,812.0,883.0,"(28.0, 52.0)",False,86
57-
2,35,90.0,912.0,967.0,"(45.0, 68.0)",False,87
58-
22,25,90.0,914.0,965.0,"(30.0, 52.0)",False,88
59-
32,12,90.0,200.0,237.0,"(10.0, 35.0)",False,89
60-
10,11,90.0,534.0,605.0,"(38.0, 70.0)",False,90
61-
34,30,90.0,87.0,158.0,"(8.0, 40.0)",False,91
62-
3,17,90.0,825.0,870.0,"(45.0, 70.0)",False,92
63-
24,9,90.0,732.0,777.0,"(28.0, 55.0)",False,94
33+
33,0,90.0,31.0,100.0,"(10.0, 40.0)",False,50
34+
22,0,90.0,914.0,965.0,"(30.0, 52.0)",False,52
35+
5,0,90.0,727.0,782.0,"(42.0, 68.0)",False,53
36+
4,0,90.0,65.0,146.0,"(42.0, 66.0)",False,54
37+
3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,55
38+
20,0,90.0,278.0,345.0,"(15.0, 80.0)",False,58
39+
21,0,90.0,10.0,73.0,"(30.0, 50.0)",False,60
40+
4,0,90.0,65.0,146.0,"(42.0, 66.0)",False,61
41+
10,0,90.0,534.0,605.0,"(38.0, 70.0)",False,64
42+
8,0,90.0,170.0,225.0,"(40.0, 66.0)",False,65
43+
14,0,90.0,30.0,92.0,"(22.0, 75.0)",False,68
44+
3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,69
45+
3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,70
46+
28,0,90.0,261.0,316.0,"(23.0, 52.0)",False,71
47+
14,0,90.0,30.0,92.0,"(22.0, 75.0)",False,72
48+
17,0,90.0,475.0,528.0,"(20.0, 85.0)",False,73
49+
32,0,90.0,200.0,237.0,"(10.0, 35.0)",False,79
50+
17,0,90.0,475.0,528.0,"(20.0, 85.0)",False,80
51+
13,0,90.0,652.0,721.0,"(25.0, 85.0)",False,81
52+
25,0,90.0,65.0,144.0,"(25.0, 50.0)",False,82
53+
30,0,90.0,358.0,405.0,"(20.0, 50.0)",False,83
54+
21,0,90.0,10.0,73.0,"(30.0, 50.0)",False,84
55+
14,0,90.0,30.0,92.0,"(22.0, 75.0)",False,85
56+
23,0,90.0,812.0,883.0,"(28.0, 52.0)",False,86
57+
2,0,90.0,912.0,967.0,"(45.0, 68.0)",False,87
58+
22,0,90.0,914.0,965.0,"(30.0, 52.0)",False,88
59+
32,0,90.0,200.0,237.0,"(10.0, 35.0)",False,89
60+
10,0,90.0,534.0,605.0,"(38.0, 70.0)",False,90
61+
34,0,90.0,87.0,158.0,"(8.0, 40.0)",False,91
62+
3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,92
63+
24,0,90.0,732.0,777.0,"(28.0, 55.0)",False,94
6464
24,0,90.0,732.0,777.0,"(28.0, 55.0)",False,96
65-
19,6,90.0,179.0,254.0,"(15.0, 75.0)",False,97
65+
19,0,90.0,179.0,254.0,"(15.0, 75.0)",False,97
66+

small.csv

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,31 @@ cust,x,y,demand,from,to,service
55
4,42.00,66.00,10.00,65.00,146.00,90.00
66
5,42.00,68.00,10.00,727.00,782.00,90.00
77
6,42.00,65.00,10.00,15.00,67.00,90.00
8+
7,40.00,69.00,20.00,621.00,702.00,90.00
9+
8,40.00,66.00,20.00,170.00,225.00,90.00
10+
9,38.00,68.00,20.00,255.00,324.00,90.00
11+
10,38.00,70.00,10.00,534.00,605.00,90.00
12+
11,35.00,66.00,10.00,357.00,410.00,90.00
13+
12,35.00,69.00,10.00,448.00,505.00,90.00
14+
13,25.00,85.00,20.00,652.00,721.00,90.00
15+
14,22.00,75.00,30.00,30.00,92.00,90.00
16+
15,22.00,85.00,10.00,567.00,620.00,90.00
17+
16,20.00,80.00,40.00,384.00,429.00,90.00
18+
17,20.00,85.00,40.00,475.00,528.00,90.00
19+
18,18.00,75.00,20.00,99.00,148.00,90.00
20+
19,15.00,75.00,20.00,179.00,254.00,90.00
21+
20,15.00,80.00,10.00,278.00,345.00,90.00
22+
21,30.00,50.00,10.00,10.00,73.00,90.00
23+
22,30.00,52.00,20.00,914.00,965.00,90.00
24+
23,28.00,52.00,20.00,812.00,883.00,90.00
25+
24,28.00,55.00,10.00,732.00,777.00,90.00
26+
25,25.00,50.00,10.00,65.00,144.00,90.00
27+
26,25.00,52.00,40.00,169.00,224.00,90.00
28+
27,25.00,55.00,10.00,622.00,701.00,90.00
29+
28,23.00,52.00,10.00,261.00,316.00,90.00
30+
29,23.00,55.00,20.00,546.00,593.00,90.00
31+
30,20.00,50.00,10.00,358.00,405.00,90.00
32+
31,20.00,55.00,10.00,449.00,504.00,90.00
33+
32,10.00,35.00,20.00,200.00,237.00,90.00
34+
33,10.00,40.00,30.00,31.00,100.00,90.00
35+
34,8.00,40.00,40.00,87.00,158.00,90.00

swarmlib_/aco4tsp/aco_algorithm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def solve(self):
8181
]
8282

8383
for i in range(1, self._num_iterations):
84+
print('Iteration: ', i)
8485
shortest_distance = float('inf')
8586
self._run_ants(ants)
8687
self._decay_pheromone()

swarmlib_/aco4tsp/dynamic_vrp_env/env.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ class ChangeDetails:
1313

1414

1515
class DynamicVrpEnv:
16-
def __init__(self, data_file: Path, scenario_input_file = None) -> None:
16+
def __init__(self, data_file: Path, scenario_input_file=None) -> None:
1717
super().__init__()
1818
self._counter = 0
1919
self._next_step = None
2020
self._initial_df = pd.read_csv(data_file)
2121
if scenario_input_file:
2222
self._scenario = pd.read_csv(scenario_input_file)
2323
self._node_name_history = list(self._scenario['name'].to_list())
24-
self._node_demand_history = list(self._scenario['demand'].to_list())
24+
self._node_demand_history = list(
25+
self._scenario['demand'].to_list())
2526
self._steps_history = list(self._scenario['step'].to_list())
2627
self._next_step = self._steps_history.pop(0)
2728
else:
@@ -43,15 +44,16 @@ def step(self):
4344
else:
4445
if (self._next_step is not None) and self._counter == self._next_step:
4546
change = self._change_routes_graph()
46-
self._next_step = self._steps_history.pop(0) if len(self._steps_history) else None
47-
47+
self._next_step = self._steps_history.pop(
48+
0) if len(self._steps_history) else None
49+
4850
self._counter = self._counter + 1
4951
return self._routes_graph, change
50-
52+
5153
def prepare_scenario_file(self):
52-
filepath = Path('./out.csv')
53-
filepath.parent.mkdir(parents=True, exist_ok=True)
54-
self._history.to_csv(filepath, index=False)
54+
filepath = Path('./out.csv')
55+
filepath.parent.mkdir(parents=True, exist_ok=True)
56+
self._history.to_csv(filepath, index=False)
5557

5658
def _change_routes_graph(self):
5759
change = self._update_demand
@@ -73,9 +75,18 @@ def _update_demand(self):
7375
node = random.choice(self._routes_graph.get_nodes())
7476
else:
7577
new_demand = self._node_demand_history.pop(0)
76-
node = self._routes_graph.get_node(self._node_name_history.pop(0))
78+
try:
79+
node = self._routes_graph.get_node(
80+
self._node_name_history.pop(0))
81+
except:
82+
return ChangeDetails('no_change', node, None)
83+
if new_demand == 0:
84+
# self._routes_graph.remove_node(node.name)
85+
return ChangeDetails('no_change', node, None)
86+
7787
new_node = Node(**(asdict(node) | {'demand': new_demand}))
78-
self._history = pd.concat([self._history, pd.DataFrame([new_node]).assign(step=self._counter)], ignore_index=True)
88+
self._history = pd.concat([self._history, pd.DataFrame(
89+
[new_node]).assign(step=self._counter)], ignore_index=True)
7990
self._routes_graph.update_node(node.name, new_node)
8091
return ChangeDetails('increase_demand', from_node=node, to_node=new_node)
8192

0 commit comments

Comments
 (0)