예제 #1
0
def greedy_val(task):
    name, order = task
    from pygrout import VrptwSolution, VrptwTask, build_first
    VrptwTask.sort_order = order
    sol = VrptwSolution(VrptwTask(name))
    build_first(sol)
    return sol.val()
예제 #2
0
파일: test.py 프로젝트: gitmokelok/pygrout
def test_find_pos():
    """Check consistency of finding the best position in a route."""
    from pygrout import (VrptwSolution, VrptwTask, build_first,
        print_like_Czarnas, find_bestpos_on, find_allpos_on, R_EDG)
    sol = VrptwSolution(VrptwTask('solomons/rc206.txt'))
    build_first(sol)
    for i in xrange(sol.k):
        for c in sol.r[i][R_EDG][1:]:
            for j in xrange(sol.k):
                if i <> j:
                    best = find_bestpos_on(sol, c[0], j)
                    allp = list(find_allpos_on(sol, c[0], j))
                    print "Best:", best, "all:", allp
                    if best == (None, None):
                        assert allp == []
                    else:
                        assert best in allp
                        assert best == max(allp)
예제 #3
0
파일: test.py 프로젝트: gitmokelok/pygrout
def test_flattening():
    """Checks the format for interchange with other programs, like grout."""
    from pygrout import (VrptwSolution, VrptwTask, build_first,
        print_like_Czarnas)
    task = VrptwTask('solomons/rc208.txt')
    s1 = VrptwSolution(task)
    build_first(s1)
    print_like_Czarnas(s1)
    data1 = s1.flatten()
    print data1
    s2 = VrptwSolution(task)
    s2.inflate(data1)
    print "Ok, inflated... Let's see:"
    print_like_Czarnas(s2)
    print s2.flatten()
    assert s2.check()
    assert s2.flatten()==data1
    _rec_assert_simmilar(s1.get_essence(), s2.get_essence())
예제 #4
0
파일: test.py 프로젝트: gitmokelok/pygrout
 def check_one(test):
     s = VrptwSolution(VrptwTask(test))
     build_first(s)
     assert s.check()==True, 'Benchmark %s failed at initial solution' % test