Пример #1
0
def main():
    print "Start"
    flow = MainFlow()
    
    rooms_for_test = dict(room_problems.all_static_rooms.items()[:2]) 
    alogrithm = BestFirstGraphSearch()
    heuristic = heuristics.PowerHeuristic() 
    
    agent = MeasureAgent(alogrithm, heuristic)       
    table = flow.runSeries(agent, rooms_for_test,3)
    
    lens  = column_of(table, 1) # [ line[1] for line in table ]
    times = column_of(table, 2) # [ line[2] for line in table ]
    
    lens_dict = dict([ (line[0], line[1]) for line in table ])
    lens_dict = dict([ (line[0], line[1]) for line in table ])
    
    
    print lens
    print times
    
    pylab.hist(lens)
    pylab.show()
 
    pylab.hist(times)
    pylab.show()   
    
    for line in table: print line
    print "End"          
Пример #2
0
        def BeamSolve(beam_width):
            algorithm = beam_search.BeamSearch(beam_width, max_depth)
            heuristic = heuristics.PowerHeuristic()
            agent = measure_agent.MeasureAgent(algorithm, heuristic)

            def solution_len(*args, **kwrds):
                solution = agent.solve(*args, **kwrds)
                if solution is None: solution = []
                return [len(solution)]

            return solution_len
Пример #3
0
    def rumBeamWithWidth(self, beam_width, series_limit):
        ''' beam_width => solved_percent
        '''
        #trace
        delta = time.clock() - self.run_start_time
        self.run_start_time = time.clock()
        print 'rumBeamWithWidth: %d  [delta=%03f sec] ' % (beam_width,
                                                           float(delta))

        #mss
        max_depth = self.max_depth
        algorithm = beam_search.BeamSearch(beam_width, max_depth)
        heuristic = heuristics.PowerHeuristic()
        agent = measure_agent.MeasureAgent(algorithm, heuristic)
        table = self.runSeries(agent, self.rooms, series_limit)
        return table
Пример #4
0
 def Beam(beam_width):
     algorithm = beam_search.BeamSearch(beam_width, max_depth)
     heuristic = heuristics.PowerHeuristic()
     agent = measure_agent.MeasureAgent(algorithm, heuristic)
     return agent
Пример #5
0
problem = problems.randomRoom2((10, 12), (10, 12), (3, 4), (3, 4), (10, 15),
                               (1, 2), (6, 10), 4)
#problem = rooms.randomRoom(9, 9, 6, 15, 20, 3)  very interesting room
#problem = rooms.complexRoom2()

print "Start"
print problem

agent = SolveAgent()
start = time.clock()
solution = agent.solve(problem, 10)[0]
run_time = time.clock() - start

if solution == None:
    print 'Running time:', run_time
    print "No solution found"
else:

    h = heuristics.PowerHeuristic()
    print " -------------------Solving "
    print 'steps: '
    for step in solution:
        problem.nextState(step)
        print "eval=", h.evaluate(problem)
        print step
        print problem

    print 'Solution:', solution
    print 'Solution length:', len(solution)
    print 'Running time:', run_time