コード例 #1
0
 def reset(self):
     LoggingAgentSG.reset(self)
     self._temperature = self.init_temperature
     self._expl_proportion = self.init_exploration
     self.learner.reset()
     self._oaro = None
     self.newEpisode()
 def integrateObservation(self, obs):
     if self.learning and not self.learner.batchMode and self.lastobs is not None:
         if self.learner.passNextAction:
             self._oaro = [self.lastobs, self.lastaction, self.lastreward, obs]
         else:
             self.learner._updateWeights(self.lastobs, self.lastaction, self.lastreward, obs)
     LoggingAgentSG.integrateObservation(self, obs)        
 def reset(self):
     LoggingAgentSG.reset(self)
     self._temperature = self.init_temperature
     self._expl_proportion = self.init_exploration
     self.learner.reset()    
     self._oaro = None
     self.newEpisode()
コード例 #4
0
 def integrateObservation(self, obs):
     if self.learning and not self.learner.batchMode and self.lastobs is not None:
         if self.learner.passNextAction:
             self._oaro = [self.lastobs, self.lastaction, self.lastreward, obs]
         else:
             self.learner._updateWeights(self.lastobs, self.lastaction, self.lastreward, obs)
     LoggingAgentSG.integrateObservation(self, obs)        
コード例 #5
0
    def __init__(self, module, num_features, num_actions, num_agents, index,
                 learner):
        """
        :key module: the acting module
        :key learner: the learner (optional) """
        assert isinstance(
            learner,
            IndexableValueBasedLearner), "learner should be indexable."
        self.module = module
        self.learner = learner
        LoggingAgentSG.__init__(self, num_features, num_actions, num_agents,
                                index)

        # if learner is available, tell it the module and data
        if self.learner is not None:
            self.learner.module = self.module
            self.learner.dataset = self.history

        self.learning = True

        self.agentProperties["requireOtherAgentsState"] = False
        self.agentProperties["requireJointAction"] = False
        self.agentProperties["requireJointReward"] = False
        #parity check
        for prop in self.learner.getProperty().keys():
            if learner.getProperty()[prop]:
                assert self.getProperty(
                )[prop], "learners property should same to that of agents."
    def getAction(self):
        """ Activate the module with the last observation, add the exploration from
            the explorer object and store the result as last action. """
        LoggingAgentSG.getAction(self)

        self.lastaction = self.module.activate(self.lastobs)

        if self.learning:
            self.lastaction = self.learner.explore(self.lastobs, self.lastaction)

        return self.lastaction
 def __init__(self, learner, num_actions, numAgents, index, **kwargs):
     assert isinstance(learner, IndexableValueBasedLearner), "learner should be indexable."
     self.learner = learner
     LoggingAgentSG.__init__(self, np.ones(numAgents)*learner.num_features, num_actions, numAgents, index, **kwargs)
     self.learner._behaviorPolicy = self._actionProbs
     self.reset()
     self.agentProperties["requireOtherAgentsState"]=False
     self.agentProperties["requireJointAction"]=True
     self.agentProperties["requireJointReward"]=True
     for prop in self.learner.getProperty().keys():
         if learner.getProperty()[prop]:
             assert self.getProperty()[prop], "learners property should same to that of agents."
コード例 #8
0
 def __init__(self, learner, num_features, num_actions, num_agents, index, **kwargs):
     self.learner = learner
     LoggingAgentSG.__init__(self, np.ones(num_agents, dtype=np.int8)*num_features, num_actions, num_agents, index, **kwargs)
     assert isinstance(learner, IndexableValueBasedLearner), "learner should be indexable."
     self.learner._behaviorPolicy = self._actionProbs
     self.reset()
     self.agentProperties["requireOtherAgentsState"]=False
     self.agentProperties["requireJointAction"]=True
     self.agentProperties["requireJointReward"]=True
     for prop in self.learner.getProperty().keys():
         if learner.getProperty()[prop]:
             assert self.getProperty()[prop], "learners property should same to that of agents."
コード例 #9
0
    def getAction(self):
        """ Activate the module with the last observation, add the exploration from
            the explorer object and store the result as last action. """
        LoggingAgentSG.getAction(self)

        self.lastaction = self.module.activate(self.lastobs)

        if self.learning:
            self.lastaction = self.learner.explore(self.lastobs,
                                                   self.lastaction)

        return self.lastaction
    def __init__(self, learner, num_features, num_actions, num_agents, index,
                 **kwargs):
        assert isinstance(learner,
                          NFCEQ), "learner should be instance of NFCEQ."
        self.learner = learner
        LoggingAgentSG.__init__(self, num_features, num_actions, num_agents,
                                index, **kwargs)
        # if learner is available, tell it the module and data
        if self.learner is not None:
            self.learner.dataset = self.history
        self.learning = True
        self.learner._behaviorPolicy = self._actionProbs
        self.reset()

        self.agentProperties["requireOtherAgentsState"] = False
        self.agentProperties["requireJointAction"] = True
        self.agentProperties["requireJointReward"] = True
        for prop in self.learner.getProperty().keys():
            if learner.getProperty()[prop]:
                assert self.getProperty(
                )[prop], "learners property should same to that of agents."
    def __init__(self, module, num_features, num_actions, num_agents, index, learner):
        """
        :key module: the acting module
        :key learner: the learner (optional) """
        LoggingAgentSG.__init__(self, num_features, num_actions, num_agents,index)
        assert isinstance(learner, IndexableValueBasedLearner), "learner should be indexable."
        self.module = module
        self.learner = learner

        # if learner is available, tell it the module and data
        if self.learner is not None:
            self.learner.module = self.module
            self.learner.dataset = self.history

        self.learning = True
        
        self.agentProperties["requireOtherAgentsState"]=False
        self.agentProperties["requireJointAction"]=False
        self.agentProperties["requireJointReward"]=False
        #parity check
        for prop in self.learner.getProperty().keys():
            if learner.getProperty()[prop]:
                assert self.getProperty()[prop], "learners property should same to that of agents."
 def reset(self):
     """ Clear the history of the agent and resets the module and learner. """
     LoggingAgentSG.reset(self)
     self.module.reset()
     if self.learning:
         self.learner.reset()
 def integrateObservation(self, obs):
     LoggingAgentSG.integrateObservation(self, obs)
コード例 #14
0
 def reset(self):
     """ Clear the history of the agent and resets the module and learner. """
     LoggingAgentSG.reset(self)
     self.module.reset()
     if self.learning:
         self.learner.reset()