Open 1-Bart-1 opened 2 days ago
I guess there is a bug in handling tuples, since the following "works":
julia> symbolic_solve([eq1, eq2], [RisoP, RisoN])
"works" in quotation because it fails later with the familiar monomial ordering error:
julia> symbolic_solve([eq1, eq2], [RisoP, RisoN])
[ Info: Assuming (R2*RisoN + R2*RisoP + R3*RisoN + R3*RisoP + RisoN*RisoP) != 0
[ Info: Assuming (R1*R2*RisoN + R1*R2*RisoP + R1*R3*RisoN + R1*R3*RisoP + R1*RisoN*RisoP + R2*RisoN*RisoP + R3*RisoN*RisoP) != 0
ERROR: DomainError with Invalid monomial ordering.:
Stacktrace:
[1] map_variables(vars::Vector{Num}, varmap::Dict{DynamicPolynomials.Variable{…}, Int64})
@ Groebner ~/Groebner.jl/src/monomials/orderings.jl:347
[2] ordering_transform(ord::Lex{false, Num}, varmap::Dict{DynamicPolynomials.Variable{…}, Int64})
@ Groebner ~/Groebner.jl/src/monomials/orderings.jl:355
[3] io_convert_polynomials_to_ir(polynomials::Vector{DynamicPolynomials.Polynomial{…}}, options::Groebner.KeywordArguments)
@ GroebnerDynamicPolynomialsExt ~/Groebner.jl/ext/GroebnerDynamicPolynomialsExt.jl:32
[4] groebner0(polynomials::Vector{DynamicPolynomials.Polynomial{…}}, options::Groebner.KeywordArguments)
@ Groebner ~/Groebner.jl/src/groebner/groebner.jl:9
[5] #groebner#214
@ ~/Groebner.jl/src/interface.jl:110 [inlined]
[6] groebner_basis(polynomials::Vector{Num}; ordering::Lex{false, Num}, kwargs::@Kwargs{})
@ SymbolicsGroebnerExt ~/.julia/packages/Symbolics/8MbnV/ext/SymbolicsGroebnerExt.jl:45
[7] solve_zerodim(eqs::Vector{Num}, vars::Vector{Num}; dropmultiplicity::Bool, warns::Bool)
@ SymbolicsGroebnerExt ~/.julia/packages/Symbolics/8MbnV/ext/SymbolicsGroebnerExt.jl:209
[8] solve_zerodim
@ ~/.julia/packages/Symbolics/8MbnV/ext/SymbolicsGroebnerExt.jl:174 [inlined]
[9] solve_multivar(eqs::Vector{Num}, vars::Vector{Num}; dropmultiplicity::Bool, warns::Bool)
@ SymbolicsGroebnerExt ~/.julia/packages/Symbolics/8MbnV/ext/SymbolicsGroebnerExt.jl:311
[10] solve_multivar
@ ~/.julia/packages/Symbolics/8MbnV/ext/SymbolicsGroebnerExt.jl:310 [inlined]
[11] symbolic_solve(expr::Vector{Equation}, x::Vector{Num}; dropmultiplicity::Bool, warns::Bool)
@ Symbolics ~/.julia/packages/Symbolics/8MbnV/src/solver/main.jl:204
[12] symbolic_solve(expr::Vector{Equation}, x::Vector{Num})
@ Symbolics ~/.julia/packages/Symbolics/8MbnV/src/solver/main.jl:145
[13] top-level scope
@ REPL[15]:1
Some type information was truncated. Use `show(err)` to see complete types.
Seems we really ought to revisit Symbolics.groebner_basis 😅
The issue is that pvar2sym
, sym2term
may not contain all actually present variables:
and I turn to hacky shenanigans to alleviate that (https://github.com/JuliaSymbolics/Symbolics.jl/pull/1324).
EDIT: @n0rbed maybe the solver has some internal function to convert to DP.jl polynomials and maintain a map of vartiables that we can use instead of symbol_to_poly ?
Im afraid we'll still need the Symbolic version of the polys. we go back and forth a lot between both types. If you have the time, can you try running solve_zerodim or a portion of it on a DP? if no Symbolic equation is needed then this is good yes
If you have the time, can you try running solve_zerodim or a portion of it on a DP?
Recall that we call symbolic_solve on univariate expressions in solve_zerodim. Whence I think translating to DP.jl in solve_zerodim is challenging.
It seems in the long run the solver would benefit from robust functions
symbolics_to_dp(expr :: Num) -> poly :: DP.Polynomial
dp_to_symbolics(poly :: DP.Polynomial) -> expr :: Num
that
We use PolyForm and it currently does not do 2. in a conveniet way (or at least I did not manage to make it always work).
https://discourse.julialang.org/t/getting-the-symbolic-solution-of-system-of-equations-using-modelingtoolkit/122786/3
solve_multivar using Groebner is broken
[0c5d862f] Symbolics v6.21.0