Esempio n. 1
0
    def step(self, action=None, article_id=None):
        if self.turn < self.turns:

            self._pre_step()
            self.actions.do_action(action, article_id)
            # self.actions.action_random()
            log.info('Step ', self.turn)

            self._post_step()

            reward = self.rewards.calculate_step_reward()

            # resulting_state = []
            resulting_state = self.get_state()
            self.turn += 1

            # state, reward, gameover, debug info
        else:
            log.info('Finished!')
            # resulting_state = []
            resulting_state = self.get_state()
            reward = 0
            self.game_over = True
            # state, reward, gameover, debug info
        self.rewards.add_state_info(state=self.get_state(
        ), possible_articles=self.possible_articles.get_possible_articles())
        return resulting_state, reward, self.game_over, None
Esempio n. 2
0
 def reset(self):
     self.game_over = False
     self.turn = 0
     self._make_new_instances()
     self.rewards.reset_episode()
     log.info('env reset')
     return self.get_state()
Esempio n. 3
0
 def deliver(self, article_id):
     article = self.env.possible_articles.get_article_by_id(article_id)
     if self.env.requests.deliver_article(article):
         log.info('deliver:', article, 'was delivered')
         return 100
     log.warn('deliver:', article, 'could not be delivered')
     return -100
Esempio n. 4
0
 def store(self, article_id, storage_pos=None):
     if storage_pos is None:
         storage_pos = self.store_oracle()
     if (storage_pos is not None
             and self.env.storage.storage_spaces[storage_pos] is not None):
         article = self.env.arrivals.remove_article_from_arrival(
             self.env.possible_articles.get_article_by_id(article_id))
         if article is not None:
             if (self.env.storage.store(article, storage_pos)):
                 log.info(
                     'store: ' + article.get_name() + 'in storage pos: ',
                     storage_pos)
                 return 0
             log.info('store: space is already used...')
             return -10
         log.info('store: article not found')
         return -10
     log.info('store: storage space not found')
     return 0  # storage space
 def _generate_articles(self):
     self.articles.append(Article(1, 0.2, "Selten"))
     self.articles.append(Article(2, 0.8, "Häufig"))
     # self.articles.append(
     #    Article(3, 0.1,  "Normal"))
     log.info("Possible articles added")
Esempio n. 6
0
 def __init__(self, count):
     self.storage_spaces = []
     self._init_spaces(count)
     log.info('Initialized storage', self.get_storage_state())
Esempio n. 7
0
 def __init__(self, count):
     self.max_arrivals = count
     self.arrivals = []
     self._initialize_spaces(self.max_arrivals)
     log.info('Initialized arrivals', self.get_arrivals_state())
Esempio n. 8
0
 def order(self, article_id):
     rew = self.env.orders.new_order(
         self.env.possible_articles.get_article_by_id(article_id))
     log.info('order:', 'order, now there ', len(self.env.orders.orders),
              ' orders')
     return rew