我不知道我是否来对了地方,但我现在正试图在 64 位 Windows 上运行一个需要 PyGMO 的 Python 3.5.1 程序。
我下载了 1.1.7 的 msi 版本(在此处下载),运行安装程序,然后尝试运行程序,出现以下错误:
Traceback (most recent call last):
File "Desktop\test-1.py", line 4, in <module>
from PyGMO import *
File "C:\Users\ycl\Anaconda3\lib\site-packages\PyGMO\__init__.py", line 57, in <module>
from PyGMO import core, algorithm, migration, problem, topology, test, util
File "C:\Users\ycl\Anaconda3\lib\site-packages\PyGMO\core\__init__.py", line 2, in <module>
from PyGMO.core._core import *
ImportError: DLL load failed: The specified module could not be found.
该程序是这样的单个脚本:
import matplotlib.pyplot as plt
from matplotlib import animation
import numpy as np
from PyGMO import *
edge_weights = np.loadtxt("ir33_weight_matrix.txt", delimiter=',')
print(edge_weights[0])
areas = np.loadtxt("ir33_areas.txt", delimiter=',')
print(areas)
N = len(areas)
node_weights = [int(round(10000*areas[i])) for i in range(N)]
capacity = 1000
prob = problem.tsp(edge_weights, node_weights, capacity, type = 'cities')
pop = population(prob, 100)
steps = 3000
stepsize = 100
algo = algorithm.inverover(gen=stepsize,ri=0.05,type="random")
c = []
g = []
prev_f = 0
for i in range(steps):
pop = algo.evolve(pop)
f = pop.champion.f[0]
if prev_f != f:
c.append(pop.champion.x)
g.append((i+1)*stepsize)
prev_f = f
f, _, id1, id2 = prob.find_city_subsequence(pop.champion.x)
f = f*0.0001
if id1 <= id2:
visited_cities = c[-1][id1:(id2 + 1) % N]
else:
visited_cities = c[-1][id1:] + c[-1][:id2 + 1]
print("The fitness of the of the best found tour is: %f " % f)
print("The according removal sequence is: ")
print(visited_cities)
fig = plt.figure()
ax = plt.axes(xlim=(-10,N+10), ylim=(-0.05,1))
plt.ylabel('cross section area')
plt.xlabel('debris piece index')
line1, = ax.plot([],[], marker='o',markersize=10, alpha=0.7, linestyle='', color='r')
line2, = ax.plot([],[], marker='o',markersize=6, alpha=0.4, linestyle='', color='b')
generations_text = ax.text(0.05, 0.95, '', transform=ax.transAxes)
fitness_text = ax.text(0.40, 0.95, '', transform=ax.transAxes)
length_text = ax.text(0.75, 0.95, '', transform=ax.transAxes)
def init():
line1.set_data([], [])
line2.set_data([], [])
generations_text.set_text('')
fitness_text.set_text('')
length_text.set_text('')
return line1, line2, generations_text, fitness_text, length_text
def animate(ll):
f, _, id1, id2 = prob.find_city_subsequence(c[ll])
f = 0.0001*f
if id1 <= (id2 +1) % N:
visited_cities = c[ll][id1:(id2 + 1)]
else:
visited_cities = c[ll][id1:] + c[ll][:(id2 + 1) % N]
area_visited = [areas[i] for i in visited_cities]
not_visited_cities = [i for i in range(N) if i not in visited_cities]
area_not_visited = [areas[i] for i in not_visited_cities]
line1.set_data(visited_cities, area_visited)
line2.set_data(not_visited_cities, area_not_visited)
generations_text.set_text('generations = %d' % g[ll])
fitness_text.set_text('fitness = %.4f' % f)
length_text.set_text('tour length = %d' % len(visited_cities))
return line1, line2, generations_text, fitness_text, length_text
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=len(g), interval=150, blit=True, repeat=False)
plt.show()
有没有人有这方面的经验?
我根本不知道在哪里可以找到 DLL...