From 7ee757999bf2d5edc648545b396f352b0c9d6c41 Mon Sep 17 00:00:00 2001 From: Ted Turocy Date: Fri, 20 Sep 2024 12:23:26 +0100 Subject: [PATCH] Additional modernisations. --- src/solvers/enumpoly/efgpoly.cc | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/solvers/enumpoly/efgpoly.cc b/src/solvers/enumpoly/efgpoly.cc index c527d384a..25429b3fa 100644 --- a/src/solvers/enumpoly/efgpoly.cc +++ b/src/solvers/enumpoly/efgpoly.cc @@ -166,8 +166,8 @@ bool ExtendsToNash(const MixedBehaviorProfile &bs) BehaviorSupportProfile(bs.GetGame())); } -List> SolveSupport(const BehaviorSupportProfile &p_support, - bool &p_isSingular) +std::list> SolveSupport(const BehaviorSupportProfile &p_support, + bool &p_isSingular) { ProblemData data(p_support); gPolyList equations(&data.Space, &data.Lex); @@ -178,11 +178,11 @@ List> SolveSupport(const BehaviorSupportProfile &p_ Vector bottoms(data.Space.Dmnsn()), tops(data.Space.Dmnsn()); bottoms = 0; tops = 1; - gRectangle Cube(bottoms, tops); QuikSolv quickie(equations); try { - quickie.FindCertainNumberOfRoots(Cube, std::numeric_limits::max(), 0); + quickie.FindCertainNumberOfRoots(gRectangle(bottoms, tops), + std::numeric_limits::max(), 0); } catch (const SingularMatrixException &) { p_isSingular = true; @@ -192,17 +192,13 @@ List> SolveSupport(const BehaviorSupportProfile &p_ p_isSingular = true; } - List> solutionlist = quickie.RootList(); - - List> solutions; - for (int k = 1; k <= solutionlist.Length(); k++) { - MixedBehaviorProfile sol( - data.sfg.ToMixedBehaviorProfile(ToSequenceProbs(data, solutionlist[k]))); + std::list> solutions; + for (auto root : quickie.RootList()) { + MixedBehaviorProfile sol(data.sfg.ToMixedBehaviorProfile(ToSequenceProbs(data, root))); if (ExtendsToNash(sol)) { solutions.push_back(sol); } } - return solutions; } @@ -221,18 +217,14 @@ EnumPolyBehaviorSolve(const Game &p_game, for (auto support : possible_supports->m_supports) { p_onSupport("candidate", support); - bool isSingular = false; - List> newsolns = SolveSupport(support, isSingular); - - for (int j = 1; j <= newsolns.Length(); j++) { - MixedBehaviorProfile fullProfile = newsolns[j].ToFullSupport(); + for (auto solution : SolveSupport(support, isSingular)) { + MixedBehaviorProfile fullProfile = solution.ToFullSupport(); if (fullProfile.GetLiapValue() < 1.0e-6) { p_onEquilibrium(fullProfile); ret.push_back(fullProfile); } } - if (isSingular) { p_onSupport("singular", support); }