Skip to content

Commit

Permalink
version 0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
guofei9987 committed Dec 26, 2019
1 parent 63cec13 commit 9c3bce4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,12 @@ More: Plot the animation:


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

aca = ACA_TSP(func=cal_total_distance, n_dim=8,
size_pop=10, max_iter=20,
aca = ACA_TSP(func=cal_total_distance, n_dim=num_points,
size_pop=50, max_iter=200,
distance_matrix=distance_matrix)

best_x, best_y = aca.run()
Expand Down
6 changes: 3 additions & 3 deletions docs/en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,12 @@ More: Plot the animation:


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

aca = ACA_TSP(func=cal_total_distance, n_dim=8,
size_pop=10, max_iter=20,
aca = ACA_TSP(func=cal_total_distance, n_dim=num_points,
size_pop=50, max_iter=200,
distance_matrix=distance_matrix)

best_x, best_y = aca.run()
Expand Down
4 changes: 4 additions & 0 deletions docs/make_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
需要从py文件中解析出:
1. # %% 做断点后赋予index值,然后插入readme
'''
import os
import sys

import re

Expand Down Expand Up @@ -93,3 +95,5 @@ def make_doc(origin_file):
docs_new = make_doc(origin_file=i)
with open(i, encoding='utf-8', mode="w") as f:
f.writelines(docs_new)

sys.exit()
6 changes: 3 additions & 3 deletions docs/zh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,12 @@ print(best_points, best_distance, cal_total_distance(best_points))
## 5. 蚁群算法
蚁群算法(ACA, Ant Colony Algorithm)解决TSP问题

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

aca = ACA_TSP(func=cal_total_distance, n_dim=8,
size_pop=10, max_iter=20,
aca = ACA_TSP(func=cal_total_distance, n_dim=num_points,
size_pop=50, max_iter=200,
distance_matrix=distance_matrix)

best_x, best_y = aca.run()
Expand Down
6 changes: 3 additions & 3 deletions examples/demo_aca_tsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pandas as pd
import matplotlib.pyplot as plt

np.random.seed(6)
num_points = 25

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

# %% Plot
fig, ax = plt.subplots(1, 1)
fig, ax = plt.subplots(1, 2)
best_points_ = np.concatenate([best_x, [best_x[0]]])
best_points_coordinate = points_coordinate[best_points_, :]
ax.plot(best_points_coordinate[:, 0], best_points_coordinate[:, 1], 'o-r')
ax[0].plot(best_points_coordinate[:, 0], best_points_coordinate[:, 1], 'o-r')
pd.DataFrame(aca.y_best_history).cummin().plot(ax=ax[1])
plt.show()

0 comments on commit 9c3bce4

Please sign in to comment.