Exemple #1
0
    def __init__(self,
                 SubAgentClass,
                 agent_params={},
                 state_abstr=None,
                 action_abstr=None,
                 name_ext="-abstr"):
        '''
        Args:
            SubAgentClass (simple_rl.AgentClass)
            agent_params (dict): A dictionary with key=param_name, val=param_value,
                to be given to the constructor for the instance of @SubAgentClass.
            state_abstr (StateAbstraction)
            state_abstr (ActionAbstraction)
            name_ext (str)
        '''

        # Setup the abstracted agent.
        self.agent = SubAgentClass(**agent_params)
        self.action_abstr = action_abstr
        self.state_abstr = state_abstr
        all_actions = self.action_abstr.get_actions(
        ) if self.action_abstr is not None else self.agent.actions

        Agent.__init__(self,
                       name=self.agent.name + name_ext,
                       actions=all_actions)
Exemple #2
0
    def __init__(self,
                 SubAgentClass,
                 actions,
                 agent_params={},
                 state_abstr=None,
                 action_abstr=None,
                 name_ext="abstr"):
        '''
        Args:
            SubAgentClass (simple_rl.AgentClass)
            actions (list of str)
            agent_params (dict): A dictionary with key=param_name, val=param_value,
                to be given to the constructor for the instance of @SubAgentClass.
            state_abstr (StateAbstraction)
            state_abstr (ActionAbstraction)
            name_ext (str)
        '''

        # Setup the abstracted agent.
        self.agent = SubAgentClass(actions=actions, **agent_params)
        self.action_abstr = ActionAbstraction(
            prim_actions=self.agent.actions
        ) if action_abstr is None else action_abstr
        self.state_abstr = StateAbstraction(
            {}) if state_abstr is None else state_abstr

        Agent.__init__(self,
                       name=self.agent.name + "-" + name_ext,
                       actions=self.action_abstr.get_actions())
Exemple #3
0
    def __init__(self,
                 SubAgentClass,
                 actions,
                 state_abstr=None,
                 action_abstr=None,
                 name_ext="abstr"):
        '''
        Args:
            SubAgentClass (simple_rl.AgentClass)
            actions (list of str)
            state_abstr (StateAbstraction)
            state_abstr (ActionAbstraction)
            name_ext (str)
        '''

        # Setup the abstracted agent.
        self.agent = SubAgentClass(actions=actions)
        self.action_abstr = ActionAbstraction(
            options=self.agent.actions, prim_actions=self.agent.actions
        ) if action_abstr is None else action_abstr
        self.state_abstr = StateAbstraction(
            {}) if state_abstr is None else state_abstr

        Agent.__init__(self,
                       name=self.agent.name + "-" + name_ext,
                       actions=self.action_abstr.get_actions())
    def __init__(self,
                 SubAgentClass,
                 actions,
                 mdp_name,
                 max_option_steps=0,
                 state_abstr=None,
                 action_abstr=None,
                 name_ext="abstr"):
        '''
        Args:
            SubAgentClass (simple_rl.AgentClass)
            actions (list of str)
            mdp_name (str)
            state_abstr (StateAbstraction)
            state_abstr (ActionAbstraction)
            name_ext (str)
        '''

        # Setup the abstracted agent.
        self._create_default_abstractions(actions, state_abstr, action_abstr)
        self.agent = SubAgentClass(actions=self.action_abstr.get_actions())
        self.exp_directory = os.path.join(os.getcwdu(), "results", mdp_name,
                                          "options")
        self.reward_since_tracking = 0
        self.max_option_steps = max_option_steps
        self.num_option_steps = 0
        Agent.__init__(self,
                       name=self.agent.name + "-" + name_ext,
                       actions=self.action_abstr.get_actions())
        self._setup_files()
Exemple #5
0
 def __init__(self, SubAgentClass, sa_stack, aa_stack, cur_level=0, name_ext=""):
     '''
     Args:
         sa_stack (StateAbstractionStack)
         aa_stack (ActionAbstractionStack)
         cur_level (int): Must be in [0:len(state_abstr_stack)]
     '''
     # Setup the abstracted agent.
     self.state_abstr_stack = sa_stack
     self.action_abstr_stack = aa_stack
     self.cur_level = cur_level
     self.agent = SubAgentClass(actions=self.get_cur_actions())
     Agent.__init__(self, name=self.agent.name + "-hierarch" + name_ext, actions=self.get_cur_actions())
    def __init__(self,
                 SubAgentClass,
                 agent_params={},
                 state_abstr=None,
                 action_abstr=None,
                 name_ext="-abstr",
                 n_ops=4,
                 freqs=1000,
                 op_n_episodes=10,
                 op_n_steps=100,
                 max_ops=32,
                 method='eigen',
                 mdp=None):
        '''
        Args:
            SubAgentClass (simple_rl.AgentClass)
            agent_params (dict): A dictionary with key=param_name, val=param_value,
                to be given to the constructor for the instance of @SubAgentClass.
            state_abstr (StateAbstraction)
            state_abstr (ActionAbstraction)
            name_ext (str)
        '''

        # Setup the abstracted agent.
        self.agent = SubAgentClass(**agent_params)
        self.action_abstr = action_abstr
        self.state_abstr = state_abstr
        all_actions = self.action_abstr.get_actions(
        ) if self.action_abstr is not None else self.agent.actions

        self.n_ops = n_ops
        self.freqs = freqs
        self.op_n_episodes = op_n_episodes
        self.op_n_steps = op_n_steps
        self.max_ops = max_ops
        self.method = method
        self.mdp = mdp

        self.transitions = []
        self.n_steps = 0
        self.prev_state = None
        self.cur_n_ops = 0

        Agent.__init__(self,
                       name=self.agent.name + name_ext,
                       actions=all_actions)
    def __init__(self,
                    SubAgentClass,
                    agent_params={},
                    feature_mapper=None,
                    name_ext="-feats"):
        '''
        Args:
            SubAgentClass (simple_rl.AgentClass)
            agent_params (dict): A dictionary with key=param_name, val=param_value,
                to be given to the constructor for the instance of @SubAgentClass.
            feature_mapper (FeatureMapper)
            name_ext (str)
        '''

        # Setup the abstracted agent.
        self.agent = SubAgentClass(**agent_params)
        self.feature_mapper = feature_mapper

        if self.feature_mapper is not None:
            name_ext = "-" + feature_mapper.NAME if feature_mapper.NAME is not None else name_ext
        
        Agent.__init__(self, name=self.agent.name + name_ext, actions=self.agent.actions)
    def __init__(self,
                    SubAgentClass,
                    agent_params={},
                    state_abstr=None,
                    action_abstr=None,
                    name_ext="-abstr"):
        '''
        Args:
            SubAgentClass (simple_rl.AgentClass)
            agent_params (dict): A dictionary with key=param_name, val=param_value,
                to be given to the constructor for the instance of @SubAgentClass.
            state_abstr (StateAbstraction)
            state_abstr (ActionAbstraction)
            name_ext (str)
        '''

        # Setup the abstracted agent.
        self.agent = SubAgentClass(**agent_params)
        self.action_abstr = action_abstr
        self.state_abstr = state_abstr
        all_actions = self.action_abstr.get_actions() if self.action_abstr is not None else self.agent.actions
        
        Agent.__init__(self, name=self.agent.name + name_ext, actions=all_actions)
    def __init__(self,
                 SubAgentClass,
                 agent_params={},
                 feature_mapper=None,
                 name_ext="-feats"):
        '''
        Args:
            SubAgentClass (simple_rl.AgentClass)
            agent_params (dict): A dictionary with key=param_name, val=param_value,
                to be given to the constructor for the instance of @SubAgentClass.
            feature_mapper (FeatureMapper)
            name_ext (str)
        '''

        # Setup the abstracted agent.
        self.agent = SubAgentClass(**agent_params)
        self.feature_mapper = feature_mapper

        if self.feature_mapper is not None:
            name_ext = "-" + feature_mapper.NAME if feature_mapper.NAME is not None else name_ext

        Agent.__init__(self,
                       name=self.agent.name + name_ext,
                       actions=self.agent.actions)
 def __init__(self, mdp_distr, actions, gamma=0.99, name="$\pi_b^*$"):
     self.mdp_distr = mdp_distr
     self.active_mdp_distr = copy.deepcopy(mdp_distr)
     self.update_policy()
     Agent.__init__(self, actions=actions, gamma=gamma, name=name)
Exemple #11
0
 def reset(self):
     self.step_number = 0
     self.weights = np.zeros(self.num_features * len(self.actions))
     Agent.reset(self)
 def __init__(self, name, actions, gamma=0.99):
     Agent.__init__(self, name, actions, gamma)
     self.reward_history = defaultdict(dict)
     self.prev_state = None
     self.prev_action = ""