From d9e13bd96e746dfe160037afae756c86746312aa Mon Sep 17 00:00:00 2001 From: Ted Turocy Date: Thu, 19 Sep 2024 12:41:35 +0100 Subject: [PATCH] Removed last instances of numbering sequences. --- src/solvers/enumpoly/efgpoly.cc | 22 ++++++++++------------ src/solvers/enumpoly/sfg.h | 6 ------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/solvers/enumpoly/efgpoly.cc b/src/solvers/enumpoly/efgpoly.cc index a7cc0f292..88bee1a11 100644 --- a/src/solvers/enumpoly/efgpoly.cc +++ b/src/solvers/enumpoly/efgpoly.cc @@ -150,11 +150,12 @@ gPolyList LastActionProbPositiveInequalities(ProblemData &p_data) gPolyList equations(p_data.Space, p_data.Lex); for (auto player : p_data.support.GetGame()->GetPlayers()) { - for (int j = 2; j <= p_data.SF.NumSequences(player); j++) { - GameAction action = p_data.SF.GetSequence(player, j).action; - int act_num = p_data.support.GetIndex(action); - if (act_num == p_data.support.NumActions(action->GetInfoset()) && act_num > 1) { - equations += p_data.variables.at({player, action}); + for (auto sequence = p_data.SF.cbegin_sequences(player); + sequence != p_data.SF.cend_sequences(player); ++sequence) { + int action_number = (sequence->action) ? p_data.support.GetIndex(sequence->action) : 0; + if (action_number > 1 && + action_number == p_data.support.NumActions(sequence->action->GetInfoset())) { + equations += p_data.variables.at({player, sequence->action}); } } } @@ -179,15 +180,12 @@ gPolyList NashOnSupportEquationsAndInequalities(ProblemData &p_data) std::map ToSequenceProbs(const ProblemData &p_data, const Vector &v) { std::map x; - - for (int i = 1; i <= p_data.support.GetGame()->NumPlayers(); i++) { - GamePlayer player = p_data.support.GetGame()->GetPlayer(i); - for (int j = 1; j <= p_data.SF.NumSequences()[i]; j++) { - GameSequence sequence = p_data.SF.GetSequence(player, j); - x[sequence] = p_data.variables.at(sequence).Evaluate(v); + for (auto player : p_data.support.GetGame()->GetPlayers()) { + for (auto sequence = p_data.SF.cbegin_sequences(player); + sequence != p_data.SF.cend_sequences(player); sequence++) { + x[*sequence] = p_data.variables.at(*sequence).Evaluate(v); } } - return x; } diff --git a/src/solvers/enumpoly/sfg.h b/src/solvers/enumpoly/sfg.h index 759f01d01..c1626ddf4 100644 --- a/src/solvers/enumpoly/sfg.h +++ b/src/solvers/enumpoly/sfg.h @@ -127,12 +127,6 @@ class Sfg { return m_sequenceColumns.at(p_player).size(); } - GameSequence GetSequence(const GamePlayer &p_player, int p_index) const - { - // For the moment sequences are indexed from 1 externally. - return m_sequences.at(p_player).at(p_index - 1); - } - std::vector::const_iterator cbegin_sequences(const GamePlayer &p_player) const { return m_sequences.at(p_player).cbegin();