Skip to content

Commit 9c3bce4

Browse files
committed
version 0.5.4
1 parent 63cec13 commit 9c3bce4

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,12 @@ More: Plot the animation:
401401

402402

403403
## 5. ACA (Ant Colony Algorithm) for tsp
404-
-> Demo code: [examples/demo_aca_tsp.py#s2](https://github.com/guofei9987/scikit-opt/blob/master/examples/demo_aca_tsp.py#L23)
404+
-> Demo code: [examples/demo_aca_tsp.py#s2](https://github.com/guofei9987/scikit-opt/blob/master/examples/demo_aca_tsp.py#L17)
405405
```python
406406
from sko.ACA import ACA_TSP
407407

408-
aca = ACA_TSP(func=cal_total_distance, n_dim=8,
409-
size_pop=10, max_iter=20,
408+
aca = ACA_TSP(func=cal_total_distance, n_dim=num_points,
409+
size_pop=50, max_iter=200,
410410
distance_matrix=distance_matrix)
411411

412412
best_x, best_y = aca.run()

docs/en/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,12 @@ More: Plot the animation:
381381

382382

383383
## 5. ACA (Ant Colony Algorithm) for tsp
384-
-> Demo code: [examples/demo_aca_tsp.py#s2](https://github.com/guofei9987/scikit-opt/blob/master/examples/demo_aca_tsp.py#L23)
384+
-> Demo code: [examples/demo_aca_tsp.py#s2](https://github.com/guofei9987/scikit-opt/blob/master/examples/demo_aca_tsp.py#L17)
385385
```python
386386
from sko.ACA import ACA_TSP
387387

388-
aca = ACA_TSP(func=cal_total_distance, n_dim=8,
389-
size_pop=10, max_iter=20,
388+
aca = ACA_TSP(func=cal_total_distance, n_dim=num_points,
389+
size_pop=50, max_iter=200,
390390
distance_matrix=distance_matrix)
391391

392392
best_x, best_y = aca.run()

docs/make_doc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
需要从py文件中解析出:
1313
1. # %% 做断点后赋予index值,然后插入readme
1414
'''
15+
import os
16+
import sys
1517

1618
import re
1719

@@ -93,3 +95,5 @@ def make_doc(origin_file):
9395
docs_new = make_doc(origin_file=i)
9496
with open(i, encoding='utf-8', mode="w") as f:
9597
f.writelines(docs_new)
98+
99+
sys.exit()

docs/zh/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ print(best_points, best_distance, cal_total_distance(best_points))
350350
## 5. 蚁群算法
351351
蚁群算法(ACA, Ant Colony Algorithm)解决TSP问题
352352

353-
-> Demo code: [examples/demo_aca_tsp.py#s2](https://github.com/guofei9987/scikit-opt/blob/master/examples/demo_aca_tsp.py#L23)
353+
-> Demo code: [examples/demo_aca_tsp.py#s2](https://github.com/guofei9987/scikit-opt/blob/master/examples/demo_aca_tsp.py#L17)
354354
```python
355355
from sko.ACA import ACA_TSP
356356

357-
aca = ACA_TSP(func=cal_total_distance, n_dim=8,
358-
size_pop=10, max_iter=20,
357+
aca = ACA_TSP(func=cal_total_distance, n_dim=num_points,
358+
size_pop=50, max_iter=200,
359359
distance_matrix=distance_matrix)
360360

361361
best_x, best_y = aca.run()

examples/demo_aca_tsp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pandas as pd
44
import matplotlib.pyplot as plt
55

6-
np.random.seed(6)
76
num_points = 25
87

98
points_coordinate = np.random.rand(num_points, 2) # generate coordinate of points
@@ -25,8 +24,9 @@ def cal_total_distance(routine):
2524
best_x, best_y = aca.run()
2625

2726
# %% Plot
28-
fig, ax = plt.subplots(1, 1)
27+
fig, ax = plt.subplots(1, 2)
2928
best_points_ = np.concatenate([best_x, [best_x[0]]])
3029
best_points_coordinate = points_coordinate[best_points_, :]
31-
ax.plot(best_points_coordinate[:, 0], best_points_coordinate[:, 1], 'o-r')
30+
ax[0].plot(best_points_coordinate[:, 0], best_points_coordinate[:, 1], 'o-r')
31+
pd.DataFrame(aca.y_best_history).cummin().plot(ax=ax[1])
3232
plt.show()

0 commit comments

Comments
 (0)