我不知道我是否来到了正确的地方,但我现在正试图在64位Windows上运行程序,Python 3.5.1需要PyGMO。
我下载了1.1.7的msi版本(已下载here),运行安装程序,并尝试运行该程序,此错误如下:
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.
progam是这样的单个脚本:
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 ...
答案 0 :(得分:0)
您的问题可能是由与msi预期的python版本不匹配的python版本创建的。
无论如何,新的pagmo(https://github.com/esa/pagmo2)通过pip
和conda
为大多数python版本和osx提供二进制文件(这最后是建议的选择,因为它避免了多个库之间的库不兼容使用boost :: python的包
conda install pygmo
要么,
pip install pygmo
现在应该解决你的问题。请注意,新的pagmo语法已更改,请参阅更新的文档。