diff --git a/src/numerical_irreducible_decomposition.jl b/src/numerical_irreducible_decomposition.jl index 24261ca6..83b9eb8b 100644 --- a/src/numerical_irreducible_decomposition.jl +++ b/src/numerical_irreducible_decomposition.jl @@ -284,6 +284,9 @@ function regeneration!( # it is covenient to use the WitnessSet wrapper here, because this also keeps track of the equation # as a linear subspace we take the linear subspace for out[1], that sets u=0. H = initialize_hypersurfaces(f, vars, linear_subspace(out[1])) + if any(H .== nothing) + return nothing + end # Initialize a cache Fᵢ = fixed(System(f[1:1], variables = vars), compile = false) @@ -394,6 +397,9 @@ function initialize_hypersurfaces(f::Vector{Expression}, vars, L) start_system = :total_degree, show_progress = false, ) + if isnothing(res) + return nothing + end S = solutions(res, only_nonsingular = true) out[i] = WitnessSet(h, L, S) @@ -1402,6 +1408,9 @@ function numerical_irreducible_decomposition( endgame_options = endgame_options, kwargs..., ) + if isnothing(Ws) + return nothing + end decompose( Ws; monodromy_options = monodromy_options, diff --git a/src/solve.jl b/src/solve.jl index 463e1d8e..e1ad7a34 100644 --- a/src/solve.jl +++ b/src/solve.jl @@ -499,7 +499,15 @@ end solve(S::Solver, R::Result; kwargs...) = solve(S, solutions(R; only_nonsingular = true); kwargs...) solve(S::Solver, s::AbstractVector{<:Number}; kwargs...) = solve(S, [s]; kwargs...) -solve(S::Solver, starts; kwargs...) = solve(S, collect(starts); kwargs...) +function solve(S::Solver, starts; kwargs...) + try + s = collect(starts) + solve(S, s; kwargs...) + catch + @warn "No solutions were found." + nothing + end +end function solve( S::Solver, starts::AbstractArray; @@ -508,6 +516,7 @@ function solve( threading::Bool = Threads.nthreads() > 1, catch_interrupt::Bool = true, ) + n = length(starts) progress = show_progress ? make_progress(n; delay = 0.3) : nothing init!(S.stats) diff --git a/test/nid_test.jl b/test/nid_test.jl index 147b4ca7..82f4f48b 100644 --- a/test/nid_test.jl +++ b/test/nid_test.jl @@ -273,69 +273,22 @@ @test degrees(NID)[0] == [1] end - # @testset "426" begin - # ### Example thanks to Julian Vill - # @var a, b, c, d, e - - - # f1 = - # -18 * a^4 * c^5 + 27 * a^3 * b * c^5 - 9 * a^2 * b^2 * c^5 - 18 * a^4 * c^4 + - # 81 * a^3 * b * c^4 - 90 * a^2 * b^2 * c^4 + 27 * a * b^3 * c^4 - 9 * a^2 * c^6 + - # c^8 - 18 * a^4 * c^3 + 81 * a^3 * b * c^3 - 126 * a^2 * b^2 * c^3 + - # 81 * a * b^3 * c^3 - 18 * b^4 * c^3 + 36 * a * b * c^5 - 9 * b^2 * c^5 + - # c^7 + - # 27 * a^3 * b * c^2 - 90 * a^2 * b^2 * c^2 + 81 * a * b^3 * c^2 - - # 18 * b^4 * c^2 + 18 * a^2 * c^4 - 36 * a * b * c^4 - 8 * c^6 - - # 9 * a^2 * b^2 * c + 27 * a * b^3 * c - 18 * b^4 * c - 36 * a * b * c^3 + - # 18 * b^2 * c^3 + - # 7 * c^5 - 9 * a^2 * c^2 + 36 * a * b * c^2 - 2 * c^4 - 9 * b^2 * c + 7 * c^3 - - # 8 * c^2 + - # c + - # 1 - - # f2 = - # -18 * a^4 * e^5 + 27 * a^3 * d * e^5 - 9 * a^2 * d^2 * e^5 - 18 * a^4 * e^4 + - # 81 * a^3 * d * e^4 - 90 * a^2 * d^2 * e^4 + 27 * a * d^3 * e^4 - 9 * a^2 * e^6 + - # e^8 - 18 * a^4 * e^3 + 81 * a^3 * d * e^3 - 126 * a^2 * d^2 * e^3 + - # 81 * a * d^3 * e^3 - 18 * d^4 * e^3 + 36 * a * d * e^5 - 9 * d^2 * e^5 + - # e^7 + - # 27 * a^3 * d * e^2 - 90 * a^2 * d^2 * e^2 + 81 * a * d^3 * e^2 - - # 18 * d^4 * e^2 + 18 * a^2 * e^4 - 36 * a * d * e^4 - 8 * e^6 - - # 9 * a^2 * d^2 * e + 27 * a * d^3 * e - 18 * d^4 * e - 36 * a * d * e^3 + - # 18 * d^2 * e^3 + - # 7 * e^5 - 9 * a^2 * e^2 + 36 * a * d * e^2 - 2 * e^4 - 9 * d^2 * e + 7 * e^3 - - # 8 * e^2 + - # e + - # 1 - - # f3 = - # -9 * b^2 * c^5 * d^2 * e + 27 * b * c^5 * d^3 * e - 18 * c^5 * d^4 * e + - # 27 * b^3 * c^4 * d * e^2 - 90 * b^2 * c^4 * d^2 * e^2 + - # 81 * b * c^4 * d^3 * e^2 - 18 * c^4 * d^4 * e^2 - 18 * b^4 * c^3 * e^3 + - # 81 * b^3 * c^3 * d * e^3 - 126 * b^2 * c^3 * d^2 * e^3 + - # 81 * b * c^3 * d^3 * e^3 - 18 * c^3 * d^4 * e^3 - 18 * b^4 * c^2 * e^4 + - # 81 * b^3 * c^2 * d * e^4 - 90 * b^2 * c^2 * d^2 * e^4 + - # 27 * b * c^2 * d^3 * e^4 - 18 * b^4 * c * e^5 + 27 * b^3 * c * d * e^5 - - # 9 * b^2 * c * d^2 * e^5 - 9 * c^6 * d^2 * e - 9 * b^2 * c^5 * e^2 + - # 36 * b * c^5 * d * e^2 - 36 * b * c^4 * d * e^3 + - # 18 * c^4 * d^2 * e^3 + - # 18 * b^2 * c^3 * e^4 - 36 * b * c^3 * d * e^4 + 36 * b * c^2 * d * e^5 - - # 9 * c^2 * d^2 * e^5 - 9 * b^2 * c * e^6 + - # c^8 + - # c^7 * e - 8 * c^6 * e^2 + 7 * c^5 * e^3 - 2 * c^4 * e^4 + 7 * c^3 * e^5 - - # 8 * c^2 * e^6 + - # c * e^7 + - # e^8 - - # F = System([f1; f2; f3], variables = [a, b, c, d, e]) - - # N = nid( - # F; - # seed = 0xc7cca254, - # endgame_options = EndgameOptions(; sing_accuracy = 1e-10), - # ) - - # @test ncomponents(N) == 1 - # @test degrees(N) == Dict(2 => [426]) - # end + @testset "solve a system without solutions" begin + using HomotopyContinuation + @var x[1:4] + + I = [ + 13 * (x[1] + x[2]) - 61 * (x[2] + x[3]) + 48 * (x[1] + x[3]) - + 61 * (x[1] + x[4]) + + 48 * (x[2] + x[4]) + + 13 * (x[3] + x[4]) + + 1, + 13 * (x[2]x[1] + x[1]^2 + x[2]^2) - 61(x[4]x[1] + x[1]^2 + x[4]^2) + + 48(x[4]x[2] + x[2]^2 + x[4]^2) + + 48(x[3]x[1] + x[1]^2 + x[3]^2) - 61(x[2]x[3] + x[2]^2 + x[3]^2) + + 13(x[4] * x[3] + x[3]^2 + x[4]^2), + ] + b = nid(I) + @test isnothing(b) + end end diff --git a/test/solve_test.jl b/test/solve_test.jl index 9d9617e2..f16a1139 100644 --- a/test/solve_test.jl +++ b/test/solve_test.jl @@ -418,6 +418,27 @@ @test s ≈ [s2[2], s2[1]] end + @testset "solve a system without solutions" begin + using HomotopyContinuation + @var x[1:4] + + I = [ + 13 * (x[1] + x[2]) - 61 * (x[2] + x[3]) + 48 * (x[1] + x[3]) - + 61 * (x[1] + x[4]) + + 48 * (x[2] + x[4]) + + 13 * (x[3] + x[4]) + + 1, + 13 * (x[2]x[1] + x[1]^2 + x[2]^2) - 61(x[4]x[1] + x[1]^2 + x[4]^2) + + 48(x[4]x[2] + x[2]^2 + x[4]^2) + + 48(x[3]x[1] + x[1]^2 + x[3]^2) - 61(x[2]x[3] + x[2]^2 + x[3]^2) + + 13(x[4] * x[3] + x[3]^2 + x[4]^2), + randn(4)' * x - 1, + randn(4)' * x - 1, + ] + b = solve(I) + @test isnothing(b) + end + @testset "change parameters" begin @var x a y b F = System([x^2 - a, x * y - a + b]; parameters = [a, b]) @@ -623,5 +644,7 @@ @test length(R1) == 6 end + + end end