def access(self, page): # Attempt to access a given page # print 'page', page state = FrameTable.current_state # print 'getting action for current state' action = self.agent.act(state) self.ah_counts[action] += 1 for a in range(0, len(self.algorithms)): self.ah_files[a].write(str(self.ah_counts[a]) + "\n") if not action == self.curalgo: self.curalgo = action if not FrameTable.access(self, page): # page fault reward = self.get_miss_reward() else: # hit reward = self.get_hit_reward() new_state = FrameTable.current_state new_action = self.agent.act(new_state) self.agent.update_q(state, action, reward, new_state, new_action) if not FrameTable.time % 100: self.agent.save_model()