Skip to content

Commit

Permalink
Merge pull request #1225 from BenHBLiu/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
cbtxs authored Oct 17, 2024
2 parents d74b52d + c09f089 commit b39eb42
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 1,771 deletions.
37 changes: 30 additions & 7 deletions example/opt/Levy_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
levy_steps_tensor = bm.array(levy_steps, device=device, dtype=bm.float32)
bround_steps_tensor = bm.array(bround_steps, device=device, dtype=bm.float32)

L[n * i : (i + 1) * n, :, :] = bm.cumsum(levy_steps_tensor, axis=0)
B[n * i : (i + 1) * n, :, :] = bm.cumsum(bround_steps_tensor, axis=0)
L[1 : 1 + n + 1, :, :] = bm.cumsum(levy_steps_tensor, axis=0)
B[1 : 1 + n + 1, :, :] = bm.cumsum(bround_steps_tensor, axis=0)

end_time = time.perf_counter()
running_time = end_time - start_time
Expand All @@ -38,15 +38,38 @@
L_cpu = L.cpu().numpy()
B_cpu = B.cpu().numpy()

for particle in range(0, 1):
L_x_vals = L_cpu[:, 0, particle]
L_y_vals = L_cpu[:, 1, particle]
B_x_vals = B_cpu[:, 0, particle]
B_y_vals = B_cpu[:, 1, particle]

plt.scatter(L_cpu[0, 0, 0], L_cpu[0, 0, 0], marker=MarkerStyle('*'), color='red', s=500)
plt.xticks([])
plt.yticks([])

for i in range(1, 16):
if i < 6:
step = 50
elif i < 11:
step = 150
else:
step = 300
L_x_vals = L_cpu[ : step * i, 0, 0]
L_y_vals = L_cpu[ : step * i, 1, 0]
B_x_vals = B_cpu[ : step * i, 0, 0]
B_y_vals = B_cpu[ : step * i, 1, 0]
plt.figure()
plt.plot(L_x_vals, L_y_vals, '-', color = 'blue')
plt.plot(B_x_vals, B_y_vals, '-', color = 'black')
plt.scatter(L_x_vals[0], L_y_vals[0], marker=MarkerStyle('*'), color='red', s=500)
plt.xticks([])
plt.yticks([])

particle = 0
L_x_vals = L_cpu[ : , 0, particle]
L_y_vals = L_cpu[ : , 1, particle]
B_x_vals = B_cpu[ : , 0, particle]
B_y_vals = B_cpu[ : , 1, particle]
plt.figure()
plt.plot(L_x_vals, L_y_vals, '-', color = 'blue')
plt.plot(B_x_vals, B_y_vals, '-', color = 'black')
plt.scatter(L_x_vals[0], L_y_vals[0], marker=MarkerStyle('*'), color='red', s=500)
plt.xticks([])
plt.yticks([])
plt.show()
78 changes: 0 additions & 78 deletions fealpy/iopt/ANT_TSP.py

This file was deleted.

Loading

0 comments on commit b39eb42

Please sign in to comment.