From d9346acb976da635065d6245754e6b4594c9eb28 Mon Sep 17 00:00:00 2001 From: Ted Turocy Date: Wed, 18 Sep 2024 16:36:32 +0100 Subject: [PATCH] Simplify tracking of information sets to minimum needed, as rows are no longer a concept. --- src/solvers/enumpoly/efgpoly.cc | 2 +- src/solvers/enumpoly/sfg.cc | 6 +----- src/solvers/enumpoly/sfg.h | 14 +++----------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/solvers/enumpoly/efgpoly.cc b/src/solvers/enumpoly/efgpoly.cc index ba4714d3f..875a0a5d1 100644 --- a/src/solvers/enumpoly/efgpoly.cc +++ b/src/solvers/enumpoly/efgpoly.cc @@ -75,7 +75,7 @@ gPoly 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()) { diff --git a/src/solvers/enumpoly/sfg.cc b/src/solvers/enumpoly/sfg.cc index d7f18dba7..4c9caab1f 100644 --- a/src/solvers/enumpoly/sfg.cc +++ b/src/solvers/enumpoly/sfg.cc @@ -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; @@ -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; diff --git a/src/solvers/enumpoly/sfg.h b/src/solvers/enumpoly/sfg.h index 02b864592..dcfe08a20 100644 --- a/src/solvers/enumpoly/sfg.h +++ b/src/solvers/enumpoly/sfg.h @@ -55,7 +55,7 @@ class Sfg { std::map> m_sequenceColumns; NDArray SF; // sequence form std::map, int> m_constraints; // (sparse) constraint matrices - std::map> infoset_row; + std::set m_infosets; // infosets actually reachable given support std::map> m_actionParents; void BuildSequences(const GameNode &, PureSequenceProfile &); @@ -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 &NumSequences() const { return SF.GetIndexDimension(); } int TotalNumSequences() const @@ -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 &index, int pl) const { return SF.at(index, pl); } int GetConstraintEntry(const GameInfoset &p_infoset, const GameAction &p_action) const