Exemple #1
0
 def h_pg_setlevel(self, node: Node):
     # uses the planning graph set-level heuristic calculated
     # from this node to the goal
     # requires implementation in PlanningGraph
     pg = PlanningGraph(self, node.state)
     pg_setlevel = pg.h_setlevel()
     return pg_setlevel
 def h_pg_setlevel(self, node: Node):
     '''
     Similar to the above, but using the set-level heuristic described in
     chapter 11 of AIMA 2E.
     '''
     pg = PlanningGraph(self, node.state)
     level = pg.h_setlevel()
     if level == False: return float("-inf")
     return level
class TestPlanningGraphHeuristics(unittest.TestCase):
    def setUp(self):
        self.p = have_cake()
        self.pg = PlanningGraph(self.p, self.p.initial)

    def test_levelsum(self):
        self.assertEqual(self.pg.h_levelsum(), 1)

    def test_setlevel(self):
        self.assertEqual(self.pg.h_setlevel(), 2)
Exemple #4
0
 def h_pg_setlevel(self, node: Node):
     '''
     This heuristic uses a planning graph representation of the problem
     state space to estimate the minimum number of actions that must be
     carried out from the current state in order to satisfy all of the goal
     conditions.
     '''
     # TODO: Complete the implmentation of this heuristic in the 
     # PlanningGraph class
     pg = PlanningGraph(self, node.state)
     pg_setlevel = pg.h_setlevel()
     return pg_setlevel
Exemple #5
0
    def h_pg_setlevel(self, node):
        """ This heuristic uses a planning graph representation of the problem
        to estimate the level cost in the planning graph to achieve all of the
        goal literals such that none of them are mutually exclusive.

        See Also
        --------
        Russell-Norvig 10.3.1 (3rd Edition)
        """
        pg = PlanningGraph(self, node.state, serialize=True)
        score = pg.h_setlevel()
        return score
 def h_pg_setlevel(self, node: Node):
     # uses the planning graph setlevel heuristic calculated
     # from this node to the goal
     pg = PlanningGraph(self, node.state)
     pg_setlevel = pg.h_setlevel()
     return pg_setlevel