Visualizations.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:GoodEnoughAlgs 作者: elsander 项目源码 文件源码
def PlotMultipleRuns(Alg, nruns=20, fname=None):
    '''Plot "nruns" runs of a given algorithm to show performance
    and variability across runs.'''
    if fname:
        runs = scipy.genfromtxt(fname)
    else:
        runs = []
        for i in range(nruns):
            bestSol, fitHistory = tsp.TSP(200, Alg, 3000, 30, seed=None,
                                          coordfile='tmp.txt')
            runs.append(fitHistory)
        fname = 'MultRuns-' + str(Alg) + '.txt'
        runs = scipy.array(runs)
        scipy.savetxt(fname, runs)

    # plotting
    Xs = scipy.linspace(0, runs.shape[1] * 1000, runs.shape[1])
    for i in range(runs.shape[0]):
        pl.plot(Xs, runs[i, :])
    pl.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号