def __init__(self, domain_path, problem_path):
     self.task = Planner()
     self.task.load(domain_path, problem_path)
     self.task.setup()
     self.sig_to_index = dict()
     for i in range(0, self.task.num_actions()):
         self.sig_to_index[self.task.get_action_signature(i)] = i
Esempio n. 2
0
class TrackedSuccessor(object):
    """
    this class keeps uses liblapkt inorder to keep track of the state of the problem
    this allows for swift calculation of the valid next actions
    """
    def __init__(self, domain_path, problem_path):
        self.task = Planner()
        self.task.load(domain_path, problem_path)
        self.task.setup()
        self.sig_to_index = dict()
        for i in range(0, self.task.num_actions()):
            self.sig_to_index[self.task.get_action_signature(i)] = i

    def next(self):
        return self.task.next_actions_from_current()

    def proceed(self, action_signature):
        self.task.proceed_with_action(
            self.sig_to_index[action_signature.upper()])
Esempio n. 3
0
class TrackedSuccessorValidActions():

    """
    Use the TrackedSuccessor to query for valid actions at the current state
    This successor is tracked because LAPKT needs to keep track of the state
    """

    def __init__(self, domain_path, problem_path):
        self.task = Planner()
        self.task.load(domain_path, problem_path)
        self.task.setup()
        self.sig_to_index = dict()
        for i in range(0, self.task.num_actions()):
            self.sig_to_index[self.task.get_action_signature(i)] = i

    def get(self):
        return map(str.lower, self.task.next_actions_from_current())

    def on_action(self, action_signature):
        self.task.proceed_with_action(
            self.sig_to_index[action_signature.upper()])
class TrackedSuccessorValidActions():
    """
    Use the TrackedSuccessor to query for valid actions at the current state
    This successor is tracked because LAPKT needs to keep track of the state
    """
    def __init__(self, domain_path, problem_path):
        self.task = Planner()
        self.task.load(domain_path, problem_path)
        self.task.setup()
        self.sig_to_index = dict()
        for i in range(0, self.task.num_actions()):
            self.sig_to_index[self.task.get_action_signature(i)] = i

    def get(self):
        return map(str.lower, self.task.next_actions_from_current())

    def on_action(self, action_signature):
        """
        This is called by the SimulatorServices to notify that an action has been selected
        It is necessary because TrackedSuccessors keeps track of it's own state
        """
        self.task.proceed_with_action(
            self.sig_to_index[action_signature.upper()])
Esempio n. 5
0
class Planner_Wrapper(object):
    def __init__(self):
        self.task = Planner()

    def setup(self):
        self.task.setup()

    def create_state(self, encoded):
        return self.task.create_state(encoded)

    def next_actions(self, state):
        return self.task.next_actions(state)

    def encode(self, atoms, atom_table):
        return self.task.encode(atoms, atom_table)

    def next_actions_from_atoms(self, atoms, atom_table):
        return self.task.next_actions_from_atoms(atoms, atom_table)
Esempio n. 6
0
 def __init__(self):
     self.task = Planner()