New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solve is too slow for small systems of equations #16949
Comments
Here are the equations and unknowns: In [63]: for e in eqs: pprint(e)
2⋅a + 2⋅b⋅ptq₂ + ε⋅(2⋅a - 2⋅b) - μₐ + 2⋅s - 2⋅tp
2⋅a⋅ptq₂ + 2⋅b + ε⋅(-2⋅a + 2⋅b) - μ_b + 2⋅s - 2⋅tq
2⋅D⋅s + 2⋅a + 2⋅b - μₛ - 2⋅t
a⋅μₐ
b⋅μ_b
μₛ⋅s
In [64]: pprint(primal_vars + dual_vars)
[a, b, s, μₐ, μ_b, μₛ] If I read this correctly the first 3 equations are linear. Then the remaining equations are fairly trivially solved by saying that one or other variable must be zero. Presumably the 8 solutions come from making that choice in each of the last 3 equations. Although in principle this is a multivariate polynomial system it's easy to see heuristics that would be efficient for this kind of problem. Perhaps recognising equations of the form |
Yes, you're correct: that's equivalent to solving 8 linear problems. Here's a problem with
I'll have to solve it "manually" by exploiting its structure... edit: Sorry for the many edits. This was the last one. |
explicitly: >>> list(cartes((a,ma),(b,mb),(s,ms))) # list of sym-dependent factors of equations that are products
[(a, b, s), (a, b, ms), (a, mb, s), (a, mb, ms), (ma, b, s), (ma, b, ms), (ma, mb, s), (ma, mb, ms)]
>>> len(_)
8 |
The following problem is solved almost instantaneously in both SageMath and Matlab, but it takes much longer in sympy. The problem has 8 solutions. If I use
manual=True
, solve is very fast, but it finds only 2 solutions.If I try a bigger problem with the same structure, it takes forever in sympy but only a few seconds in SageMath and Matlab.
The text was updated successfully, but these errors were encountered: