diff --git a/src/solvers/enumpoly/efgpoly.cc b/src/solvers/enumpoly/efgpoly.cc index 23aa64e23..db7c05b5e 100644 --- a/src/solvers/enumpoly/efgpoly.cc +++ b/src/solvers/enumpoly/efgpoly.cc @@ -63,14 +63,17 @@ gPoly BuildSequenceVariable(ProblemData &p_data, const GamePlayer &p_pla return gPoly(p_data.Space, p_data.var[p_player->GetNumber()][seq], 1, p_data.Lex); } - int isetrow = p_data.SF.InfosetRowNumber(p_player, seq); gPoly equation(p_data.Space, p_data.Lex); - for (int j = 1; j < seq; j++) { - if (p_data.SF.GetConstraintEntry(p_player, isetrow, j) == Rational(-1)) { - equation -= BuildSequenceVariable(p_data, p_player, p_data.SF.GetSequence(p_player, j)); + for (auto seq = p_data.SF.cbegin_sequences(p_player); seq != p_data.SF.cend_sequences(p_player); + seq++) { + if (*seq == p_action) { + break; } - else if (p_data.SF.GetConstraintEntry(p_player, isetrow, j) == Rational(1)) { - equation += BuildSequenceVariable(p_data, p_player, p_data.SF.GetSequence(p_player, j)); + if (p_data.SF.GetConstraintEntry(infoset, *seq) == Rational(-1)) { + equation -= BuildSequenceVariable(p_data, p_player, *seq); + } + else if (p_data.SF.GetConstraintEntry(infoset, *seq) == Rational(1)) { + equation += BuildSequenceVariable(p_data, p_player, *seq); } } return equation; diff --git a/src/solvers/enumpoly/sfg.cc b/src/solvers/enumpoly/sfg.cc index 0bef28398..78be708d7 100644 --- a/src/solvers/enumpoly/sfg.cc +++ b/src/solvers/enumpoly/sfg.cc @@ -66,7 +66,7 @@ Rational &Sfg::GetMatrixEntry(const PureSequenceProfile &profile, const GamePlay return SF.at(index, player->GetNumber()); } -Rational &Sfg::GetConstraintEntry(const GameInfoset &infoset, const GameAction &action) +Rational &Sfg::GetConstraintEntryPrivate(const GameInfoset &infoset, const GameAction &action) { return E.at(infoset->GetPlayer())(infoset_row[infoset->GetPlayer()][infoset], m_sequenceColumns[infoset->GetPlayer()][action]); @@ -116,7 +116,7 @@ void Sfg::FillTableau(const GameNode &n, const Rational &prob, } } else { - GetConstraintEntry(n->GetInfoset(), previousActions.at(n->GetPlayer())) = Rational(1); + GetConstraintEntryPrivate(n->GetInfoset(), previousActions.at(n->GetPlayer())) = Rational(1); for (auto action : support.GetActions(n->GetInfoset())) { if (m_sequenceColumns[n->GetPlayer()].find(action) == m_sequenceColumns[n->GetPlayer()].end()) { @@ -124,7 +124,7 @@ void Sfg::FillTableau(const GameNode &n, const Rational &prob, m_sequences[n->GetPlayer()].push_back(action); } previousActions[n->GetPlayer()] = action; - GetConstraintEntry(n->GetInfoset(), action) = Rational(-1); + GetConstraintEntryPrivate(n->GetInfoset(), action) = Rational(-1); FillTableau(n->GetChild(action), prob, previousActions); previousActions[n->GetPlayer()] = m_actionParents[n->GetPlayer()][action]; } diff --git a/src/solvers/enumpoly/sfg.h b/src/solvers/enumpoly/sfg.h index 66e57ba46..14848ab49 100644 --- a/src/solvers/enumpoly/sfg.h +++ b/src/solvers/enumpoly/sfg.h @@ -47,7 +47,7 @@ class Sfg { void FillTableau(const GameNode &, const Rational &, PureSequenceProfile &); Rational &GetMatrixEntry(const PureSequenceProfile &, const GamePlayer &); - Rational &GetConstraintEntry(const GameInfoset &, const GameAction &); + Rational &GetConstraintEntryPrivate(const GameInfoset &, const GameAction &); public: explicit Sfg(const BehaviorSupportProfile &); @@ -111,6 +111,13 @@ class Sfg { return E.at(p_player)(infoset_row, seq_col); } + const Rational &GetConstraintEntry(const GameInfoset &p_infoset, + const GameAction &p_action) const + { + return E.at(p_infoset->GetPlayer())(infoset_row.at(p_infoset->GetPlayer()).at(p_infoset), + GetSequenceNumber(p_infoset->GetPlayer(), p_action)); + } + int InfosetRowNumber(const GamePlayer &p_player, int sequence) const { if (sequence == 1) {