コード例 #1
0
def test_solve_1():
    '''
    Test function  'my_solver.solve_1'
    '''

    initial_state = load_state('workbenches/wb_05_i.txt')
    goal_state_no = load_state('workbenches/wb_01_i.txt')

    goal_state_yes = load_state('workbenches/wb_05_g.txt')

    display_state(initial_state, 'Initial state')

    display_state(goal_state_no, '\nUnreachable goal state')

    La_no = solve_1(initial_state, goal_state_no)
    print('\n\n')

    display_state(goal_state_yes, '\nReachable goal state')
    La_yes = solve_1(initial_state, goal_state_yes)
    #    print(La_yes)

    test_passed = (  #1  
        La_no == 'no solution' and (  #2
            La_yes == [(((5, 5, 5), ), ((1, 1, 3, 1, 0), (0, 1, 0, 1, 1)), 1),
                       (((1, 1, 3, 1, 0), (0, 1, 0, 1, 1), (0, 5, 5, 5, 0)),
                        ((1, 2), ), -2)]
            or La_yes == [(((1, 1, 3, 1, 0), (0, 1, 0, 1, 1)), ((1, 2), ), -2),
                          (((5, 5, 5), ), ((0, 0, 1, 2, 0), (1, 1, 3, 1, 0),
                                           (0, 1, 0, 1, 1)), 1)])  #2
    )  #1

    return test_passed
コード例 #2
0
def test_solve1():
    initial_state = load_state('workbenches/wb_05_i.txt')

    goal_state_yes = load_state('workbenches/wb_05_g.txt')

    La_yes = solve_1(initial_state, goal_state_yes)

    print(La_yes)
コード例 #3
0
def test_solve_1():
    '''
    Test function  'my_solver.solve_1'
    '''

    initial_state = load_state('workbenches/wb_05_i.txt')        
    goal_state_no = load_state('workbenches/wb_01_i.txt')        

    goal_state_yes = load_state('workbenches/wb_05_g.txt')        
    
    display_state(initial_state,'Initial state')
    
    display_state(goal_state_no,'\nUnreachable goal state')
    t0 = time.time()
    
    La_no = solve_1(initial_state,goal_state_no)
    t1 = time.time()
    print ('Unreachable Search solve_1 took {0} seconds'.format(t1-t0))
    print('\n\n')
    

    display_state(goal_state_yes,'\nReachable goal state')
    t0 = time.time()
    La_yes = solve_1(initial_state,goal_state_yes)
    t1 = time.time()
    print ('Successful Search solve_1 took {0} seconds'.format(t1-t0))
#    print(La_yes)
#    print(La_no)
    
    test_passed =  (#1  
            La_no == 'no solution'
            and 
            (#2
                    La_yes ==  [(((5, 5, 5),), ((1, 1, 3, 1, 0), (0, 1, 0, 1, 1)), 1), 
                        (((1, 1, 3, 1, 0), (0, 1, 0, 1, 1), (0, 5, 5, 5, 0)), ((1, 2),), -2)]
                or
                    La_yes ==  [
                                ( ((1, 1, 3, 1, 0),(0, 1, 0, 1, 1)), ((1, 2),), -2) ,                            
                                ( ((5, 5, 5),),  ((0, 0, 1, 2, 0),(1, 1, 3, 1, 0),(0, 1, 0, 1, 1)), 1)
                                ]                
            )#2
        )#1
    
    
    return test_passed
コード例 #4
0
def test_solve_rand_1():
    '''
    Generate a problem and attempt to solve it
    
    '''
    initial_state = load_state('workbenches/wb_09_i.txt')
    ap_1 = AssemblyProblem_1(initial_state)

    # num_op=3 is fine
    goal_state = gen_prob(ap_1, num_op=4)

    t0 = time.time()

    La = solve_1(initial_state, goal_state)

    t1 = time.time()

    print('Search solve_1 took {0} seconds'.format(t1 - t0))
コード例 #5
0
def test_solve_1a():
    '''

    Run 'solve_1' on  
        initial_state : 'workbenches/wb_09_i.txt'
        goal_state : 'workbenches/wb_09_g1.txt'
    
    Computation takes about 20 minutes on my aging PC
    
    '''
    initial_state = load_state('workbenches/wb_09_i.txt')

    goal_state = load_state('workbenches/wb_09_g1.txt')

    t0 = time.time()

    La = solve_1(initial_state, goal_state)

    t1 = time.time()

    print('Search solve_1 took {0} seconds'.format(t1 - t0))