示例#1
0
    def reset(self) -> List[int]:
        """
        Reset the state of the environment and returns an initial observation.
        Returns
        -------
        observation: List[int]
            The initial observation of the space.
        """
        self.curr_step = -1
        self.curr_episode += 1
        self.prev_cost = 0
        for n in self.nodes:
            n.destroy()
        self.nodes = set()
        for i in range(self.MIN_NODES):
            self._create_node(self.CPU_OPTS[len(self.CPU_OPTS)//2], self.RAM_OPTS[len(self.RAM_OPTS)//2])

        self.current_node = random.choice(tuple(self.nodes)) 
        self.action_episode_memory.append([])
        return self._get_state()
 def tearDown(self):
     for node in list(self.nodes.values()):
         node.stop()
         node.destroy()
     self.simulator.stop()