Skip to content

Commit

Permalink
Simplify tracking of information sets to minimum needed, as rows are …
Browse files Browse the repository at this point in the history
…no longer a concept.
  • Loading branch information
tturocy committed Sep 18, 2024
1 parent c485c92 commit d9346ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/solvers/enumpoly/efgpoly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ gPoly<double> BuildSequenceVariable(ProblemData &p_data, const GameSequence &p_s

ProblemData::ProblemData(const BehaviorSupportProfile &p_support)
: support(p_support), SF(p_support),
Space(new gSpace(SF.TotalNumSequences() - SF.NumPlayerInfosets() - SF.NumPlayers())),
Space(new gSpace(SF.TotalNumSequences() - SF.NumInfosets() - SF.NumPlayers())),
Lex(new term_order(Space, lex))
{
for (auto player : p_support.GetGame()->GetPlayers()) {
Expand Down
6 changes: 1 addition & 5 deletions src/solvers/enumpoly/sfg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Sfg::Sfg(const BehaviorSupportProfile &S) : support(S)
m_sequences[player] = {{player, nullptr}};
m_sequenceColumns[player] = {{nullptr, 1}};
m_actionParents[player] = {};
infoset_row[player] = {};
}

PureSequenceProfile parent;
Expand Down Expand Up @@ -76,10 +75,7 @@ void Sfg::BuildSequences(const GameNode &n, PureSequenceProfile &p_previousActio
}
}
else {
auto &player_infoset_row = infoset_row[n->GetPlayer()];
if (player_infoset_row.find(n->GetInfoset()) == player_infoset_row.end()) {
player_infoset_row[n->GetInfoset()] = player_infoset_row.size() + 1;
}
m_infosets.insert(n->GetInfoset());
for (auto action : support.GetActions(n->GetInfoset())) {
m_actionParents[n->GetPlayer()][action] = p_previousActions[n->GetPlayer()];
p_previousActions[n->GetPlayer()] = action;
Expand Down
14 changes: 3 additions & 11 deletions src/solvers/enumpoly/sfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Sfg {
std::map<GamePlayer, std::map<GameAction, int>> m_sequenceColumns;
NDArray<Rational> SF; // sequence form
std::map<std::pair<GameInfoset, GameAction>, int> m_constraints; // (sparse) constraint matrices
std::map<GamePlayer, std::map<GameInfoset, int>> infoset_row;
std::set<GameInfoset> m_infosets; // infosets actually reachable given support
std::map<GamePlayer, std::map<GameAction, GameAction>> m_actionParents;

void BuildSequences(const GameNode &, PureSequenceProfile &);
Expand Down Expand Up @@ -88,8 +88,6 @@ class Sfg {
return m_sequences.at(p_player).cend();
}

int NumInfosets(const GamePlayer &p_player) const { return infoset_row.at(p_player).size(); }

const Array<int> &NumSequences() const { return SF.GetIndexDimension(); }

int TotalNumSequences() const
Expand All @@ -98,16 +96,10 @@ class Sfg {
return std::accumulate(dim.cbegin(), dim.cend(), 0);
}

int NumPlayerInfosets() const
{
auto players = support.GetGame()->GetPlayers();
return std::accumulate(
players.cbegin(), players.cend(), 0,
[this](int accum, const GamePlayer &player) { return accum + NumInfosets(player); });
}

int NumPlayers() const { return support.GetGame()->NumPlayers(); }

size_t NumInfosets() const { return m_infosets.size(); }

const Rational &GetPayoff(const Array<int> &index, int pl) const { return SF.at(index, pl); }

int GetConstraintEntry(const GameInfoset &p_infoset, const GameAction &p_action) const
Expand Down

0 comments on commit d9346ac

Please sign in to comment.