当前位置: 首页>>代码示例>>Python>>正文


Python Optimizer.solveSA方法代码示例

本文整理汇总了Python中optimizer.Optimizer.solveSA方法的典型用法代码示例。如果您正苦于以下问题:Python Optimizer.solveSA方法的具体用法?Python Optimizer.solveSA怎么用?Python Optimizer.solveSA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在optimizer.Optimizer的用法示例。


在下文中一共展示了Optimizer.solveSA方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: salesman

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import solveSA [as 别名]
def salesman(undirectedgraph, checkpoints):
    print("call to salesman")
    #TODO: Make a distance Dict
    distances = {}
    path = {}
    #TODO: iterate through all to all checkpoints
    for checkpoint in checkpoints:
        print("enter iteration")
        distances[checkpoint[0]] = {}
        distances[checkpoint[0]]['lat'] = checkpoint[1]
        distances[checkpoint[0]]['long'] = checkpoint[2]
        path[checkpoint[0]] = {}
        for check in checkpoints:
            if check[0] == checkpoint[0]:
                #TODO: is NAN
                print("did nothing")
            else:
                print("made a node")
                #TODO: Make nodes
                #print (checkpoint[1], checkpoint[2], check[1], check[2])
                sourcenode = Node(checkpoint[1], checkpoint[2])
                targetnode = Node(check[1], check[2])
                
                #TODO: calculate shortest path with dijkstra
                pathstack, distancefromsource = dijkstra(undirectedgraph, sourcenode, targetnode)
                
                #TODO: Add to distance dict
                print (distancefromsource)
                distances[checkpoint[0]][check[0]] = distancefromsource
                path[checkpoint[0]][check[0]] = pathstack
    #TODO: Thus we optimize
    travellingsolver = Optimizer(distances)
    travellingsolution = travellingsolver.solveSA()
    print ("made it!")
    print(path)
    return path, travellingsolution
开发者ID:N35N0M,项目名称:Project-Aham,代码行数:38,代码来源:salesman.py


注:本文中的optimizer.Optimizer.solveSA方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。