Esempio n. 1
0
    def testMain(self):
        self.myTestAgent()
        self.assertEqual(self.rli.episode_data.variables['length'][-1], self.correct_length)
        self.assertEqual(self.rli.episode_data.variables['reward'][-1], self.correct_reward)

        steps = self.rli.episode_data.variables['length']
        
        self.agent.sim = None
        name = tmpnam()
        pkl.save(self.agent,name)
        new_agent = pkl.load(name)
        new_agent.sim = self.rli
        self.rli.agent = new_agent
        self.rli.episodes(2,100)
        self.assertEqual(steps,self.rli.episode_data.variables['length'][-1])
    def ckpt_restore_state(self,filename):
        from plastk import pkl
        ckpt = pkl.load(filename)

        self.verbose("Restoring checkpoint state")
        for a in self.ckpt_attribs:
            self.verbose(a,' = ', ckpt[a])
            setattr(self,a,ckpt[a])
            
        rand.seed(*ckpt['rand_seed'])

        self.env.sim = self.agent.sim = self
        
        self.episode_data = NetCDFFile(self.episode_filename,'a')
        if self.step_vars:
            self.step_data = NetCDFFile(self.step_filename,'a')
        return ckpt
Esempio n. 3
0
    def testMain(self):
        self.myTestAgent()
        self.assertEqual(self.rli.episode_data.variables['length'][-1],
                         self.correct_length)
        self.assertEqual(self.rli.episode_data.variables['reward'][-1],
                         self.correct_reward)

        steps = self.rli.episode_data.variables['length']

        self.agent.sim = None
        name = tmpnam()
        pkl.save(self.agent, name)
        new_agent = pkl.load(name)
        new_agent.sim = self.rli
        self.rli.agent = new_agent
        self.rli.episodes(2, 100)
        self.assertEqual(steps, self.rli.episode_data.variables['length'][-1])