Exemple #1
0
 def get_actions_objects(self):
     """Return a set of Objects represents Actions"""
     if self.__actions_objects == None:
         self.__actions_objects = list()
         mapper = PDDLMapper.get_instance()
         for a in self.get_actions():
             obj = mapper.get_object(a.get_name())
             if obj != None:
                 self.__actions_objects.append(obj)
     return self.__actions_objects
    def test(self):

        instance = PDDLMapper.get_instance()

        try:
            instance.register_class(PickUp)

            obj = instance.get_object("(pick-up b)")

            self.assertTrue(isinstance(obj, PickUp))

            self.assertEqual("b", obj.get_block())

        except Exception as e:
            self.fail(str(e))
    def test(self):

        instance = PDDLMapper.get_instance()

        try:
            instance.register_class(PickUp)

            obj = instance.get_object("(pick-up b)")

            self.assertTrue(isinstance(obj, PickUp))

            self.assertEqual("b", obj.get_block())

        except Exception as e:
            self.fail(str(e))
Exemple #4
0
    def core(self, results_sizes, base_path):

        print("Testing " + str(len(results_sizes)) + " files for " + base_path)

        for i in range(1, len(results_sizes) + 1):
            try:
                plan = None

                handler = DesktopHandler(SPDDesktopService())

                input_program_domain = PDDLInputProgram(PDDLProgramType.DOMAIN)

                input_program_domain.add_files_path(base_path + "domain.pddl")

                inputProgramProblem = PDDLInputProgram(PDDLProgramType.PROBLEM)

                if i < 10:
                    problem = base_path + "p" + "0" + str(i) + ".pddl"
                else:
                    problem = base_path + "p" + str(i) + ".pddl"

                self.assertTrue(os.path.isfile(problem),
                                "File not found: " + problem)

                inputProgramProblem.add_files_path(problem)

                handler.add_program(input_program_domain)

                handler.add_program(inputProgramProblem)

                PDDLMapper.get_instance().register_class(PickUp)

                self.assertIsNone(plan)

                mc = MyCallback()

                handler.start_async(mc)

                mc. await ()

                plan = mc.get_output()

                self.assertIsNotNone(plan)

                tmp = ""
                for action in plan.get_actions():
                    tmp = tmp + action.get_name() + ","
                print(tmp)

                if results_sizes[i - 1] != 0:
                    self.assertTrue(
                        not plan.get_errors(), "Found error in the Plan " +
                        problem + "\n" + plan.get_errors())

                self.assertEqual(results_sizes[i - 1], len(plan.get_actions()))

                for obj in plan.get_actions_objects():
                    if isinstance(obj, PickUp):
                        print(obj.get_block())

                time.sleep(0.5)

            except Exception as e:
                self.fail("Exception " + str(e))
Exemple #5
0
handler = DesktopHandler(SPDDesktopService())

inputProgramDomain = PDDLInputProgram(PDDLProgramType.DOMAIN)

inputProgramDomain.add_files_path(
    "app/src/test/resources/pddl/blocksworld/domain.pddl")

inputProgramProblem = PDDLInputProgram(PDDLProgramType.PROBLEM)

inputProgramProblem.add_files_path(
    "app/src/test/resources/pddl/blocksworld/p35.pddl")

handler.add_program(inputProgramDomain)
handler.add_program(inputProgramProblem)

PDDLMapper.get_instance().register_class(PickUp)

mc = MyCalback()

handler.start_async(mc)

print("asincrono")

lock. await ()

res = mc.get_output()

# res = handler.start_sync()

for x in res.get_actions():
    print(x.get_name())
    def core(self, results_sizes, base_path):

        print("Testing " + str(len(results_sizes)) + " files for " + base_path)

        for i in range(1, len(results_sizes) + 1):
            try:
                plan = None

                handler = DesktopHandler(SPDDesktopService())

                input_program_domain = PDDLInputProgram(PDDLProgramType.DOMAIN)

                input_program_domain.add_files_path(base_path + "domain.pddl")

                inputProgramProblem = PDDLInputProgram(PDDLProgramType.PROBLEM)

                if i < 10:
                    problem = base_path + "p" + "0" + str(i) + ".pddl"
                else:
                    problem = base_path + "p" + str(i) + ".pddl"

                self.assertTrue(os.path.isfile(problem),
                                "File not found: " + problem)

                inputProgramProblem.add_files_path(problem)

                handler.add_program(input_program_domain)

                handler.add_program(inputProgramProblem)

                PDDLMapper.get_instance().register_class(PickUp)

                self.assertIsNone(plan)

                mc = MyCallback()

                handler.start_async(mc)

                mc.await()

                plan = mc.get_output()

                self.assertIsNotNone(plan)

                tmp = ""
                for action in plan.get_actions():
                    tmp = tmp + action.get_name() + ","
                print(tmp)

                if results_sizes[i - 1] != 0:
                    self.assertTrue(not plan.get_errors(
                    ), "Found error in the Plan " + problem + "\n" + plan.get_errors())

                self.assertEqual(results_sizes[i - 1], len(plan.get_actions()))

                for obj in plan.get_actions_objects():
                    if isinstance(obj, PickUp):
                        print(obj.get_block())

                time.sleep(0.5)

            except Exception as e:
                self.fail("Exception " + str(e))