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 h_pg_levelsum(self, node: Node):
     # uses the planning graph level-sum heuristic calculated
     # from this node to the goal
     # requires implementation in PlanningGraph
     pg = PlanningGraph(self, node.state)
     pg_levelsum = pg.h_levelsum()
     return pg_levelsum
 def h_pg_levelsum(self, node: Node):
     """This heuristic uses a planning graph representation of the problem
     state space to estimate the sum of all actions that must be carried
     out from the current state in order to satisfy each individual goal
     condition.
     """
     # requires implemented PlanningGraph class
     pg = PlanningGraph(self, node.state)
     pg_levelsum = pg.h_levelsum()
     return pg_levelsum
示例#4
0
 def h_pg_levelsum(self, node: Node):
     """This heuristic uses a planning graph representation of the problem
     state space to estimate the sum of all actions that must be carried
     out from the current state in order to satisfy each individual goal
     condition.
     """
     # requires implemented PlanningGraph class
     time_in = time()
     pg = PlanningGraph(self, node.state)
     time_mid = time()
     pg_levelsum = pg.h_levelsum()
     time_out = time()
     print("LSH Timing: {}   {}   {}".format(time_in, time_mid, time_out))
     print("LSH Create PG: {}".format(time_mid - time_in))
     print("LSH Call LS: {}".format(time_out - time_mid))
     return pg_levelsum
    def h_pg_levelsum(self, node):
        """ This heuristic uses a planning graph representation of the problem
        state space to estimate the sum of the number of actions that must be
        carried out from the current state in order to satisfy each individual
        goal condition.

        See Also
        --------
        Russell-Norvig 10.3.1 (3rd Edition)
        """
        pg = PlanningGraph(self,
                           node.state,
                           serialize=True,
                           ignore_mutexes=True)
        score = pg.h_levelsum()
        return score
        state space to estimate the sum of all actions that must be carried
        out from the current state in order to satisfy each individual goal
        condition.
<<<<<<< HEAD
<<<<<<< HEAD
        """
>>>>>>> dc9e870... Base Code
=======
        '''
>>>>>>> 8d1ef1b... Submission_01
=======
        '''
>>>>>>> a7568d9f54a58f4956b458fc6a3732a6565cdda0
        # requires implemented PlanningGraph class
        pg = PlanningGraph(self, node.state)
        pg_levelsum = pg.h_levelsum()
        return pg_levelsum

<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> a7568d9f54a58f4956b458fc6a3732a6565cdda0
    def h_ignore_preconditions(self, node: Node):
        '''
        This heuristic estimates the minimum number of actions that must be
        carried out from the current state in order to satisfy all of the goal
        conditions by ignoring the preconditions required for an action to be
        executed.
        '''
        # TODO implement (see Russell-Norvig Ed-3 10.2.3  or Russell-Norvig Ed-2 11.2)
示例#7
0
    def h_pg_levelsum(self, node: Node):

        pg = PlanningGraph(self, node.state)
        pg_levelsum = pg.h_levelsum()
        return pg_levelsum