示例#1
0
def search_tour(cfg, env):
    test_input = env.get_nodes(cfg.seed)

    random_tour = env.get_random_tour()
    env.show(test_input, random_tour)
    print('random tour')

    t1 = time()
    pred_tour = sampling(cfg, env, test_input)
    env.show(test_input, pred_tour)
    t2 = time()
    print('sampling: %dmin %1.2fsec\n' % ((t2 - t1) // 60, (t2 - t1) % 60))

    t1 = time()
    pred_tour = active_search(cfg, env, test_input)
    env.show(test_input, pred_tour)
    t2 = time()
    print('active search: %dmin %1.2fsec\n' % ((t2 - t1) // 60,
                                               (t2 - t1) % 60))
示例#2
0
def search_tour(cfg, env):
    test_input = env.get_nodes(cfg.seed)

    # random
    print('generate random tour...')
    random_tour = env.get_random_tour()
    env.show(test_input, random_tour)

    # simplest way
    print('sampling ...')
    t1 = time()
    pred_tour = sampling(cfg, env, test_input)
    t2 = time()
    print('%dmin %1.2fsec\n' % ((t2 - t1) // 60, (t2 - t1) % 60))
    env.show(test_input, pred_tour)

    # active search, update parameters during test
    print('active search ...')
    t1 = time()
    pred_tour = active_search(cfg, env, test_input)
    t2 = time()
    print('%dmin %1.2fsec\n' % ((t2 - t1) // 60, (t2 - t1) % 60))
    env.show(test_input, pred_tour)
    """