kellenf / tsp_collection Goto Github PK
View Code? Open in Web Editor NEWTSP算法全复现:遗传(GA)、粒子群(PSO)、模拟退火(SA)、禁忌搜索(ST)、蚁群算法(ACO)、自自组织神经网络(SOM)
TSP算法全复现:遗传(GA)、粒子群(PSO)、模拟退火(SA)、禁忌搜索(ST)、蚁群算法(ACO)、自自组织神经网络(SOM)
best_path = tmp_path.copy(),这里应该这样写,不然返回的路径不是全局想对最优解,是最后一个epoch的
No module named 'matplotlib'
随机找一个新解时,实际上不是交换两个元素的位置,切片没有考虑左值小于右值,有可能不进行操作,貌似也不影响
PSO.py Line 118是不是该返回one2, l2? 但是修改之后的最佳值反而更差?
# 粒子交叉
def cross(self, cur, best):
one = cur.copy()
l = [t for t in range(self.num_city)]
t = np.random.choice(l,2)
x = min(t)
y = max(t)
cross_part = best[x:y]
tmp = []
for t in one:
if t in cross_part:
continue
tmp.append(t)
# 两种交叉方法
one = tmp + cross_part
l1 = self.compute_pathlen(one, self.dis_mat)
one2 = cross_part + tmp
l2 = self.compute_pathlen(one2, self.dis_mat)
if l1<l2:
return one, l1
else:
(Line 118) return one, l2
更新信息素代码部分,a->b的信息素和b->a的信息素都应该更新,代码中只更新了单向
能否分析一下各个实现方法的时间和空间复杂度?
FileNotFoundError: [Errno 2] No such file or directory: 'data/bayg29.tsp'
能够提供一下bayg29.tsp这个文件嘛?
蚁群算法的初始信息素设置有问题,虽然作者写了设置初始信息素的函数,但是代码中,并没有使用,并且设置初始信息素的函数也有bug。
当前情况是,初始信息素全为0,在使用轮盘赌函数的时候注定会出现bug,导致收敛速度变慢,甚至出错
移动加入禁忌表的时候应当反向后加入,直接禁忌移动的话就相当于减小了后续搜索的广度
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.