Skip to content

Commit

Permalink
Additional modernisations.
Browse files Browse the repository at this point in the history
  • Loading branch information
tturocy committed Sep 20, 2024
1 parent 8514efa commit 7ee7579
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/solvers/enumpoly/efgpoly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ bool ExtendsToNash(const MixedBehaviorProfile<double> &bs)
BehaviorSupportProfile(bs.GetGame()));
}

List<MixedBehaviorProfile<double>> SolveSupport(const BehaviorSupportProfile &p_support,
bool &p_isSingular)
std::list<MixedBehaviorProfile<double>> SolveSupport(const BehaviorSupportProfile &p_support,
bool &p_isSingular)
{
ProblemData data(p_support);
gPolyList<double> equations(&data.Space, &data.Lex);
Expand All @@ -178,11 +178,11 @@ List<MixedBehaviorProfile<double>> SolveSupport(const BehaviorSupportProfile &p_
Vector<double> bottoms(data.Space.Dmnsn()), tops(data.Space.Dmnsn());
bottoms = 0;
tops = 1;
gRectangle<double> Cube(bottoms, tops);

QuikSolv<double> quickie(equations);
try {
quickie.FindCertainNumberOfRoots(Cube, std::numeric_limits<int>::max(), 0);
quickie.FindCertainNumberOfRoots(gRectangle<double>(bottoms, tops),
std::numeric_limits<int>::max(), 0);
}
catch (const SingularMatrixException &) {
p_isSingular = true;
Expand All @@ -192,17 +192,13 @@ List<MixedBehaviorProfile<double>> SolveSupport(const BehaviorSupportProfile &p_
p_isSingular = true;
}

List<Vector<double>> solutionlist = quickie.RootList();

List<MixedBehaviorProfile<double>> solutions;
for (int k = 1; k <= solutionlist.Length(); k++) {
MixedBehaviorProfile<double> sol(
data.sfg.ToMixedBehaviorProfile(ToSequenceProbs(data, solutionlist[k])));
std::list<MixedBehaviorProfile<double>> solutions;
for (auto root : quickie.RootList()) {
MixedBehaviorProfile<double> sol(data.sfg.ToMixedBehaviorProfile(ToSequenceProbs(data, root)));
if (ExtendsToNash(sol)) {
solutions.push_back(sol);
}
}

return solutions;
}

Expand All @@ -221,18 +217,14 @@ EnumPolyBehaviorSolve(const Game &p_game,

for (auto support : possible_supports->m_supports) {
p_onSupport("candidate", support);

bool isSingular = false;
List<MixedBehaviorProfile<double>> newsolns = SolveSupport(support, isSingular);

for (int j = 1; j <= newsolns.Length(); j++) {
MixedBehaviorProfile<double> fullProfile = newsolns[j].ToFullSupport();
for (auto solution : SolveSupport(support, isSingular)) {
MixedBehaviorProfile<double> fullProfile = solution.ToFullSupport();
if (fullProfile.GetLiapValue() < 1.0e-6) {
p_onEquilibrium(fullProfile);
ret.push_back(fullProfile);
}
}

if (isSingular) {
p_onSupport("singular", support);
}
Expand Down

0 comments on commit 7ee7579

Please sign in to comment.