Beispiel #1
0
 def post_body_init(self):
     '''Run init for components that need bodies to exist first, e.g. memory or architecture.'''
     self.nanflat_body_e = util.nanflatten(self.body_e)
     for idx, body in enumerate(self.nanflat_body_e):
         body.nanflat_e_idx = idx
     self.body_num = len(self.nanflat_body_e)
     logger.info(util.self_desc(self))
Beispiel #2
0
 def post_body_init(self):
     '''Initializes the part of algorithm needing a body to exist first.'''
     self.body = self.agent.nanflat_body_a[0]  # single-body algo
     # create the extra replay memory for SIL
     memory_name = self.memory_spec['sil_replay_name']
     MemoryClass = getattr(memory, memory_name)
     self.body.replay_memory = MemoryClass(self.memory_spec, self, self.body)
     self.init_algorithm_params()
     self.init_nets()
     logger.info(util.self_desc(self))
Beispiel #3
0
 def post_body_init(self):
     '''
     Initializes the part of algorithm needing a body to exist first. A body is a part of an Agent. Agents may have 1 to k bodies. Bodies do the acting in environments, and contain:
         - Memory (holding experiences obtained by acting in the environment)
         - State and action dimensions for an environment
         - Boolean var for if the action space is discrete
     '''
     self.body = self.agent.nanflat_body_a[0]  # single-body algo
     self.init_algorithm_params()
     self.init_nets()
     logger.info(util.self_desc(self))
Beispiel #4
0
 def __init__(self, spec, info_space=None):
     info_space = info_space or InfoSpace()
     init_thread_vars(spec, info_space, unit='session')
     self.spec = deepcopy(spec)
     self.info_space = info_space
     self.coor, self.index = self.info_space.get_coor_idx(self)
     self.random_seed = 100 * (info_space.get('trial') or 0) + self.index
     torch.cuda.manual_seed_all(self.random_seed)
     torch.manual_seed(self.random_seed)
     np.random.seed(self.random_seed)
     self.data = None
     self.aeb_space = AEBSpace(self.spec, self.info_space)
     self.env_space = EnvSpace(self.spec, self.aeb_space)
     self.agent_space = AgentSpace(self.spec, self.aeb_space)
     logger.info(util.self_desc(self))
     self.aeb_space.init_body_space()
     self.aeb_space.post_body_init()
     logger.info(f'Initialized session {self.index}')
Beispiel #5
0
 def post_body_init(self):
     '''Initializes the part of algorithm needing a body to exist first.'''
     self.body = self.agent.nanflat_body_a[0]  # single-body algo
     self.init_algorithm_params()
     self.init_nets()
     logger.info(util.self_desc(self))
Beispiel #6
0
 def post_body_init(self):
     '''Run init for agent, env components that need bodies to exist first, e.g. memory or architecture.'''
     self.clock = self.env_space.get_base_clock()
     logger.info(util.self_desc(self))
     self.agent_space.post_body_init()
     self.env_space.post_body_init()
Beispiel #7
0
 def post_body_init(self):
     '''Run init for components that need bodies to exist first, e.g. memory or architecture.'''
     for env in self.envs:
         env.post_body_init()
     logger.info(util.self_desc(self))
Beispiel #8
0
 def post_body_init(self):
     '''Initializes the part of algorithm needing a body to exist first.'''
     self.body = self.agent.nanflat_body_a[0]  # single-body algo
     self.init_algorithm_params()
     self.init_nets()
     logger.info(util.self_desc(self))
Beispiel #9
0
 def post_body_init(self):
     '''Run init for agent, env components that need bodies to exist first, e.g. memory or architecture.'''
     self.clock = self.env_space.get_base_clock()
     logger.info(util.self_desc(self))
     self.agent_space.post_body_init()
     self.env_space.post_body_init()
Beispiel #10
0
 def post_body_init(self):
     '''Run init for components that need bodies to exist first, e.g. memory or architecture.'''
     for agent in self.agents:
         agent.post_body_init()
     logger.info(util.self_desc(self))
Beispiel #11
0
 def post_body_init(self):
     '''Initializes the part of algorithm needing a body to exist first.'''
     self.init_nets()
     self.init_algo_params()
     logger.info(util.self_desc(self))
Beispiel #12
0
 def post_body_init(self):
     '''Run init for components that need bodies to exist first, e.g. memory or architecture.'''
     self.flat_nonan_body_a = util.flatten_nonan(self.body_a)
     self.algorithm.post_body_init()
     logger.info(util.self_desc(self))