Exemplo n.º 1
0
    def evaluate_meta_method_for_blocks(self):
        """
      Evaluating heuristic blocks.
      :return: str, the name of the new heuristic selected.
      """
        slow_model_index = self.logs.get_slow_iters()[-1] + 1
        meta_games = self.get_meta_game()
        slow_model_regrets = regret(meta_games, slow_model_index,
                                    self._slow_model_nash)
        slow_model_nashconv = np.sum(slow_model_regrets)

        if len(self._block_nashconv) == 0:
            base_model_regrets = regret(meta_games, 1)
            base_model_nashconv = np.sum(base_model_regrets)
            delta_nashconv = base_model_nashconv - slow_model_nashconv
        else:
            delta_nashconv = self._block_nashconv[-1] - slow_model_nashconv

        self._block_nashconv.append(slow_model_nashconv)
        self._heuristic_selector.update_weights(delta_nashconv,
                                                NE_list=self._NE_list)
        new_heuristic_index = self._heuristic_selector.sample(self._iterations)

        return self._heuristic_list[new_heuristic_index]
Exemplo n.º 2
0
    def evaluate_meta_method(self):
        """
      Evaluating the performance of each heuristic by calculating the regret descent
      based on the base model.
      :return: str, the name of the new heuristic selected.
      """
        if len(self.logs.get_slow_iters()
               ) == self._slow_oracle_period:  #first evaluation
            base_model_index = 1
        else:
            #TODO: check the correctness of the index.
            base_model_index = self.logs.get_slow_iters(
            )[-self._slow_oracle_period]
        slow_model_index = self.logs.get_slow_iters()[-1] + 1
        meta_games = self.get_meta_game()

        if self._standard_regret:
            base_model_regrets = regret(meta_games, base_model_index,
                                        self._base_model_nash)
            slow_model_regrets = regret(meta_games, slow_model_index,
                                        self._slow_model_nash)
        else:
            base_model_regrets = strategy_regret(meta_games, base_model_index,
                                                 self.get_nash_strategies(),
                                                 self._base_model_nash)
            slow_model_regrets = strategy_regret(meta_games, slow_model_index,
                                                 self.get_nash_strategies(),
                                                 self._slow_model_nash)

        base_model_nashconv = np.sum(base_model_regrets)
        slow_model_nashconv = np.sum(slow_model_regrets)
        delta_nashconv = base_model_nashconv - slow_model_nashconv
        self._heuristic_selector.update_weights(delta_nashconv)
        new_heuristic_index = self._heuristic_selector.sample(self._iterations)

        return self._heuristic_list[new_heuristic_index]