def runExp(gamma=0, epsilon=0.1, xor=False, lr = 0.02): if xor: print "Attempting the XOR task" else: print "Attempting the AND task" task = XORTask() task.and_task = not xor l = Q_LinFA(task.nactions, task.nsenses) l.rewardDiscount = gamma l.learningRate = lr agent = LinFA_QAgent(l) agent.epsilon = epsilon exp = Experiment(task, agent) sofar = 0 for i in range(30): exp.doInteractions(100) print exp.task.cumreward - sofar, if i%10 == 9: print sofar = exp.task.cumreward l._decayLearningRate()
def __init__(self, task, agent): if isinstance(agent, OptimizationAgent): self.doOptimization = True self.optimizer = agent.learner self.optimizer.setEvaluator(task, agent.module) self.optimizer.maxEvaluations = self.optimizer.numEvaluations else: Experiment.__init__(self, task, agent)
def _oneInteraction(self): """ Do an interaction between the Task and the Agent. """ if self.doOptimization: raise Exception( 'When using a black-box learning algorithm, only full episodes can be done.' ) else: return Experiment._oneInteraction(self)
def _oneInteraction(self): """ Do an interaction between the Task and the Agent. """ if self.doOptimization: raise Exception('When using a black-box learning algorithm, only full episodes can be done.') else: return Experiment._oneInteraction(self)
def __init__(self, task, multiAgent): assert isinstance( task, EpisodicTaskSG), "task should be the subclass of EpisodicTaskSG." assert isinstance(multiAgent, MultiAgent), "task should be MultAgent." Experiment.__init__(self, task, multiAgent)
def __init__(self, task, multiAgent): assert isinstance(task, EpisodicTaskSG), "task should be the subclass of EpisodicTaskSG." assert isinstance(multiAgent, MultiAgent), "task should be MultAgent." Experiment.__init__(self, task, multiAgent)