コード例 #1
0
  protected void initialNodes(
      SymmetricGame base,
      Queue<FormationSearchNode<SymmetricGame, Set<Action>>> queue,
      Map<Set<Action>, FormationSearchNode<SymmetricGame, Set<Action>>> nodes,
      int bound) {

    for (Action action : actions) {

      Set<Action> strategySpace = new HashSet<Action>();

      strategySpace.add(action);

      SymmetricGame game = new ActionReducedSymmetricGame(base, strategySpace);

      if (1 <= bound) {
        double epsilon = rationalizableFinder.rationalizableEpsilon(game, base);
        epsilon = Math.round(epsilon / tolerance) * tolerance;

        FormationSearchNode<SymmetricGame, Set<Action>> node =
            new FormationSearchNode<SymmetricGame, Set<Action>>(game, strategySpace, epsilon, 1);

        queue.offer(node);
        nodes.put(strategySpace, node);
      }
    }
  }
コード例 #2
0
  protected void expandNode(
      FormationSearchNode<SymmetricGame, Set<Action>> node,
      Queue<FormationSearchNode<SymmetricGame, Set<Action>>> queue,
      Map<Set<Action>, FormationSearchNode<SymmetricGame, Set<Action>>> nodes,
      int bound) {

    Set<Action> currentPlayerActions = node.getGame().getActions();

    if (currentPlayerActions.size() != actions.length) {

      for (Action action : actions) {

        if (!currentPlayerActions.contains(action)) {

          Set<Action> key = new HashSet<Action>(currentPlayerActions);

          key.add(action);

          if (!nodes.containsKey(key)) {
            double tau = rationalizableFinder.rationalizableTau(action, node.getGame(), getBase());

            if (tau > 0) {
              FormationSearchNode<SymmetricGame, Set<Action>> child = createNode(key, bound);

              if (child != null) {
                queue.offer(child);
                nodes.put(key, child);
              }
            }
          }
        }
      }
    }
  }
コード例 #3
0
  protected FormationSearchNode<SymmetricGame, Set<Action>> createNode(Set<Action> strategySpace) {
    SymmetricGame game = new ActionReducedSymmetricGame(getBase(), strategySpace);

    int total = calculateGameSize(strategySpace.size(), game.players().size());

    double epsilon = rationalizableFinder.rationalizableEpsilon(game, getBase());
    epsilon = Math.round(epsilon / tolerance) * tolerance;

    FormationSearchNode<SymmetricGame, Set<Action>> node =
        new FormationSearchNode<SymmetricGame, Set<Action>>(game, strategySpace, epsilon, total);

    return node;
  }