Skip to content

Truncation Error in large Systems #459

@matthiashimmelmann

Description

@matthiashimmelmann

Hey guys!

Particularly when solving large polynomial systems via parameter homotopy, I get the following truncation error:

Computing mixed cells... 296     Time: 0:00:11
  mixed_volume:  40320
ERROR: LoadError: InexactError: trunc(Int32, 1721321924321454894)
Stacktrace:
 [1] throw_inexacterror(::Symbol, ::Type{Int32}, ::Int64) at .\boot.jl:558
 [2] checked_trunc_sint at .\boot.jl:580 [inlined]
 [3] toInt32 at .\boot.jl:617 [inlined]
 [4] Int32 at .\boot.jl:707 [inlined]
 [5] convert at .\number.jl:7 [inlined]
 [6] cconvert at .\essentials.jl:388 [inlined]
 [7] set_si! at .\gmp.jl:201 [inlined]
 [8] _broadcast_getindex_evalf at .\broadcast.jl:648 [inlined]
 [9] _broadcast_getindex at .\broadcast.jl:621 [inlined]
 [10] getindex at .\broadcast.jl:575 [inlined]
 [11] macro expansion at .\broadcast.jl:932 [inlined]
 [12] macro expansion at .\simdloop.jl:77 [inlined]
 [13] copyto! at .\broadcast.jl:931 [inlined]
 [14] copyto! at .\broadcast.jl:886 [inlined]
 [15] copy at .\broadcast.jl:862 [inlined]
 [16] materialize at .\broadcast.jl:837 [inlined]
 [17] solve!(::HomotopyContinuation.BinomialSystemSolver) at C:\Users\matth\.julia\packages\HomotopyContinuation\Mpf1C\src\binomial_system.jl:178
 [18] solve at C:\Users\matth\.julia\packages\HomotopyContinuation\Mpf1C\src\binomial_system.jl:163 [inlined]
 [19] iterate(::HomotopyContinuation.PolyhedralStartSolutionsIterator, ::Tuple{Int64,Int64}) at C:\Users\matth\.julia\packages\HomotopyContinuation\Mpf1C\src\polyhedral.jl:81
 [20] _collect(::UnitRange{Int64}, ::HomotopyContinuation.PolyhedralStartSolutionsIterator, ::Base.HasEltype, ::Base.SizeUnknown) at .\array.jl:636
 [21] collect at .\array.jl:624 [inlined]
 [22] #solve#274 at C:\Users\matth\.julia\packages\HomotopyContinuation\Mpf1C\src\solve.jl:499 [inlined]
 [23] solve(::HomotopyContinuation.ModelKit.System; show_progress::Bool, threading::Bool, catch_interrupt::Bool, target_parameters::Array{Complex{Float64},1}, stop_early_cb::Function, transform_result::Nothing, transform_parameters::typeof(identity), flatten::Nothing, target_subspaces::Nothing, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\matth\.julia\packages\HomotopyContinuation\Mpf1C\src\solve.jl:485
 [24] catastrophePoints(::Array{Array{T,1} where T,1}, ::Array{HomotopyContinuation.ModelKit.Variable,1}, ::Array{HomotopyContinuation.ModelKit.Variable,1}, ::Array{Float64,1}, ::Array{Array{Int64,1},1}, ::Array{Array{Float64,1},1}) at C:\Users\matth\equilibriaTensegrityFramework.jl\equilibriaTensegrityFramework.jl\src\functionsForStableEquilibria.jl:245
 [25] stableEquilibria(::Array{Array{T,1} where T,1}, ::Array{Array{Float64,1},1}, ::Array{Array{Int64,1},1}, ::Array{HomotopyContinuation.ModelKit.Variable,1}, ::Array{HomotopyContinuation.ModelKit.Variable,1}, ::Array{Float64,1}, ::Array{Array{Int64,1},1}, ::Array{Any,1}) at C:\Users\matth\equilibriaTensegrityFramework.jl\equilibriaTensegrityFramework.jl\src\functionsForStableEquilibria.jl:31
 [26] start_demo(::Array{Float64,1}) at C:\Users\matth\equilibriaTensegrityFramework.jl\equilibriaTensegrityFramework.jl\src\functionsForStableEquilibria.jl:292
 [27] top-level scope at C:\Users\matth\equilibriaTensegrityFramework.jl\equilibriaTensegrityFramework.jl\src\tensegrityEquilibria.jl:7
 [28] include(::String) at .\client.jl:457
 [29] top-level scope at none:1
in expression starting at C:\Users\matth\equilibriaTensegrityFramework.jl\equilibriaTensegrityFramework.jl\src\tensegrityEquilibria.jl:7

This particular error is produced by

startParams=randn(ComplexF64, nparameters(P))
res=solve(P, target_parameters=startParams)

Sometimes, rerunning the code solves the issue (I guess because there is a random initialization involved). The corresponding polynomial system P is given by

System of length 35
 35 variables: p₁, p₂, p₃, p₄, p₅, p₆, delta₁, delta₂, delta₃, delta₄, delta₅, delta₆, lambda₁, lambda₂, lambda₃, lambda₄, lambda₅, lambda₆, lambda₇, v₁, v₂, v₃, v₄, v₅, v₆, v₇, v₈, v₉, v₁₀, v₁₁, v₁₂, v₁₃, v₁₄, v₁₅, v₁₆
 8 parameters: a₁₋₁, a₂₋₁, a₃₋₁, a₁₋₂, a₂₋₂, a₃₋₂, b₁, b₂

 2*p₄*lambda₅ + 2*(-0.866025403784439 + p₄)*lambda₆ + 2*(0.866025403784438 + p₄)*lambda₇ - 2*(p₁ - p₄)*lambda₁
 2*(-1 + p₅)*lambda₅ + 2*(0.5 + p₅)*lambda₆ + 2*(0.5 + p₅)*lambda₇ - 2*(p₂ - p₅)*lambda₁
 2*p₆*lambda₅ + 2*p₆*lambda₆ + 2*p₆*lambda₇ - 2*(p₃ - p₆)*lambda₁
 -2*lambda₂*delta₁ - (1 - delta₁)
 -2*lambda₃*delta₂ - (1 - delta₂)
 -2*lambda₄*delta₃ - (1 - delta₃)
 -2*lambda₅*delta₄ - (1 - delta₄)
 -2*lambda₆*delta₅ - (1 - delta₅)
 -2*lambda₇*delta₆ - (1 - delta₆)
 -4.0 + (p₁ - p₄)^2 + (p₂ - p₅)^2 + (p₃ - p₆)^2
 -delta₁^2 + p₁^2 + p₃^2 + (-1 + p₂)^2
 -delta₂^2 + p₃^2 + (-0.866025403784439 + p₁)^2 + (0.5 + p₂)^2
 -delta₃^2 + p₃^2 + (0.5 + p₂)^2 + (0.866025403784438 + p₁)^2
 -delta₄^2 + p₄^2 + p₆^2 + (-1 + p₅)^2
 -delta₅^2 + p₆^2 + (-0.866025403784439 + p₄)^2 + (0.5 + p₅)^2
 -delta₆^2 + p₆^2 + (0.5 + p₅)^2 + (0.866025403784438 + p₄)^2
 2*p₄*v₁₄ + v₁₅*(-1.73205080756888 + 2*p₄) + (1.73205080756888 + 2*p₄)*v₁₆ + (-2*p₁ + 2*p₄)*v₁₀ + (2*lambda₁ + 2*lambda₅ + 2*lambda₆ + 2*lambda₇)*v₁
 (-2 + 2*p₅)*v₁₄ + (1.0 + 2*p₅)*v₁₅ + (1.0 + 2*p₅)*v₁₆ + (-2*p₂ + 2*p₅)*v₁₀ + (2*lambda₁ + 2*lambda₅ + 2*lambda₆ + 2*lambda₇)*v₂
 2*p₆*v₁₄ + 2*p₆*v₁₅ + 2*p₆*v₁₆ + (-2*p₃ + 2*p₆)*v₁₀ + (2*lambda₁ + 2*lambda₅ + 2*lambda₆ + 2*lambda₇)*v₃
 -2*v₁₁*delta₁ + v₄*(1 - 2*lambda₂)
 -2*v₁₂*delta₂ + v₅*(1 - 2*lambda₃)
 -2*v₁₃*delta₃ + v₆*(1 - 2*lambda₄)
 -2*v₁₄*delta₄ + v₇*(1 - 2*lambda₅)
 -2*v₁₅*delta₅ + v₈*(1 - 2*lambda₆)
 -2*v₁₆*delta₆ + v₉*(1 - 2*lambda₇)
 -2*(p₁ - p₄)*v₁ - 2*(p₂ - p₅)*v₂ - 2*(p₃ - p₆)*v₃
 -2*v₄*delta₁
 -2*v₅*delta₂
 -2*v₆*delta₃
 2*v₁*p₄ + 2*v₂*(-1 + p₅) + 2*v₃*p₆ - 2*v₇*delta₄
 2*v₁*(-0.866025403784439 + p₄) + 2*v₂*(0.5 + p₅) + 2*v₃*p₆ - 2*v₈*delta₅
 2*v₁*(0.866025403784438 + p₄) + 2*v₂*(0.5 + p₅) + 2*v₃*p₆ - 2*v₉*delta₆
 -1 - 0.481160723746646*v₁ + 0.780597212802205*v₁₀ + 1.45722731207576*v₁₁ + 0.228247265817305*v₁₂ + 0.0839779731063026*v₁₃ - 1.82488516406006*v₁₄ - 0.224474693522123*v₁₅ - 2.15550885540766*v₁₆ + 1.79513147636094*v₂ + 0.484994402317654*v₃ - 0.0174600366022241*v₄ - 1.58052197849557*v₅ - 1.24679156009183*v₆ - 0.142158337321007*v₇ + 1.35072136471882*v₈ - 1.15859223454497*v₉
 b₁ + p₁*a₁₋₁ + p₂*a₂₋₁ + p₃*a₃₋₁
 b₂ + p₁*a₁₋₂ + p₂*a₂₋₂ + p₃*a₃₋₂

in this case. This system comes from an application in material science and is derived in a way comparable to the package Catastrophe.jl by Sascha. I should maybe mention that I can compute the system from Zeeman.jl (and of course systems entered via manual input), but larger systems fail for me.

I was wondering, if this is a known issue, whether there is a workaround or if this problem is maybe more on the user's side (me)? For starters, I was unable to identify the issue in your code.

Thanks a bunch for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions