Beispiel #1
0
def test_solve_2():
    '''
    Test function  'my_solver.solve_2'
    '''

    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, 'Goal state "no"')

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

    display_state(goal_state_yes, 'Goal state "yes"')
    La_yes = solve_2(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
def test_solve_2a():
    '''

    Run 'solve_2' on  
        initial_state : 'workbenches/wb_09_i.txt'
        goal_state : 'workbenches/wb_09_g1.txt'
    
 
    Computation takes about a tenth of a second on my aging PC
   
    '''
    initial_state = load_state('workbenches/wb_08_i.txt')    

    goal_state  = load_state('workbenches/wb_08_g1.txt')
    ap_2 = AssemblyProblem_2(initial_state, goal_state)
    display_state(initial_state, "INITIAL: ")
    display_state(goal_state, "Goal: ")
    
    t0 = time.time()
    
    La = solve_2(initial_state, goal_state)
    
    t1 = time.time()
    
    print ('Search solve_2 took {0} seconds'.format(t1-t0))
def test_solve_rand_2():
    '''
    Generate a problem
    
    '''
    initial_state = load_state('workbenches/wb_09_i.txt')
    ap_2 = AssemblyProblem_1(initial_state)

    goal_state = gen_prob(ap_2, num_op=2)
    t0 = time.time()
    La = solve_2(initial_state, goal_state)
    t1 = time.time()

    #    sum = 0
    #    for i in range(0,5):
    #        t0 = time.time()
    #        La = solve_2(initial_state, goal_state)
    #        t1 = time.time()
    #        sum = sum + (t1-t0)
    #        print(sum)
    #
    #
    #    print ('Search solve_2 took {0} seconds'.format(sum/5))

    print('Search solve_rand2 took {0} seconds'.format(t1 - t0))
    print(La)
Beispiel #4
0
def test_solve2():
    initial_state = load_state('workbenches/wb_05_i.txt')

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

    La_yes = solve_2(initial_state, goal_state_yes)

    print(La_yes)
Beispiel #5
0
def test_solve_rand_2():
    '''
    Generate a problem
    
    '''
    initial_state = load_state('workbenches/wb_09_i.txt')
    ap_2 = AssemblyProblem_2(initial_state)

    goal_state = gen_prob(ap_2, num_op=2)

    La = solve_2(initial_state, goal_state)
def test_solve_rand_2():
    '''
    Generate a problem
    
    '''
    initial_state = load_state('workbenches/wb_09_i.txt')        
    ap_2 = AssemblyProblem_2(initial_state)
    print("\n\nNumber of Actions: ", len(ap_2.actions(initial_state)))

    goal_state = gen_prob(ap_2, num_op=3)
    
    La = solve_2(initial_state, goal_state)
Beispiel #7
0
def test_solve_rand_2():
    '''
    Generate a problem
    
    '''
    initial_state = load_state('workbenches/wb_09_i.txt')
    ap_2 = AssemblyProblem_2(initial_state)

    ap_1 = AssemblyProblem_1(initial_state)

    goal_state = gen_prob(ap_1, num_op=4)

    t0 = time.time()

    La = solve_2(initial_state, goal_state)
    print(La)

    t1 = time.time()

    print('Search solve_1 took {0} seconds'.format(t1 - t0))
def test_solve_rand_2a(): #USER ADDED
    '''
    Generate a random goal using ap1 
    
    '''
    initial_state = load_state('workbenches/wb_08_i.txt')        
    ap_1 = AssemblyProblem_1(initial_state)
    goal_state = gen_prob(ap_1, num_op=6)
    
    ap_2 = AssemblyProblem_2(initial_state, goal=goal_state)
    print("\n\nNumber of Actions: ", len(ap_2.actions(initial_state)))
    
    
    t0 = time.time()

    La = solve_2(initial_state, goal_state)

    t1 = time.time()
    
    print ('Search solve_1 took {0} seconds'.format(t1-t0))
Beispiel #9
0
def test_solve_2a():
    '''

    Run 'solve_2' on  
        initial_state : 'workbenches/wb_09_i.txt'
        goal_state : 'workbenches/wb_09_g1.txt'
    
 
    Computation takes about a tenth of a second 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_2(initial_state, goal_state)

    t1 = time.time()

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