Skip to content

Commit 6c2ec23

Browse files
committed
Restrict search space for enumpoly to be strictly interior.
This shrinks the search space for searching for equilibria on a given support to be in the interior of the simplex (rather than including the boundaries as before). This solves the behaviour noted in #756, in which degenerate situations which required a solution to be on the boundary would be very slow as it tried to approach the solution on the boundary.
1 parent c4eeb37 commit 6c2ec23

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/solvers/enumpoly/efgpoly.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ std::list<MixedBehaviorProfile<double>> SolveSupport(const BehaviorSupportProfil
161161

162162
// set up the rectangle of search
163163
Vector<double> bottoms(data.space->GetDimension()), tops(data.space->GetDimension());
164-
bottoms = 0;
165-
tops = 1;
164+
bottoms = 1e-12;
165+
tops = 1 - 1e-12;
166166

167167
PolynomialSystemSolver solver(equations);
168168
std::list<Vector<double>> roots;

src/solvers/enumpoly/nfgpoly.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ EnumPolyStrategySupportSolve(const StrategySupportProfile &support, bool &is_sin
111111
const PolynomialSystem<double> equations = ConstructEquations(space, support, strategy_poly);
112112

113113
Vector<double> bottoms(space->GetDimension()), tops(space->GetDimension());
114-
bottoms = 0;
115-
tops = 1;
114+
bottoms = 1e-12;
115+
tops = 1 - 1e-12;
116116
PolynomialSystemSolver solver(equations);
117117
is_singular = false;
118118
std::list<Vector<double>> roots;

src/solvers/enumpoly/poly.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,11 @@ template <class T> class Polynomial {
375375
});
376376
}
377377
[[nodiscard]] const std::vector<Monomial<T>> &GetTerms() const noexcept { return m_terms; }
378-
bool IsZero() const noexcept { return m_terms.empty(); }
378+
bool IsZero() const noexcept
379+
{
380+
return m_terms.empty() || std::all_of(m_terms.begin(), m_terms.end(),
381+
[](const auto &mono) { return mono.IsZero(); });
382+
}
379383
bool IsConstant() const noexcept
380384
{
381385
return m_terms.size() == 1 && m_terms.front().TotalDegree() == 0;

0 commit comments

Comments
 (0)