Skip to content

Give warning message when no solutions were computed #653

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

Merged
merged 4 commits into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/numerical_irreducible_decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
83 changes: 18 additions & 65 deletions test/nid_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions test/solve_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -623,5 +644,7 @@

@test length(R1) == 6
end


end
end