Skip to content

small bugfixes in nid and solve #645

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 5 commits into from
Jun 30, 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
40 changes: 22 additions & 18 deletions src/numerical_irreducible_decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ function u_transform(W::WitnessPoints)
A = extrinsic(L).A
b = extrinsic(L).b

E = ExtrinsicDescription(A[:, 1:end-1], b; orthonormal = false)
E = ExtrinsicDescription(A[:, 1:(end-1)], b; orthonormal = false)
P = map(points(W)) do p
p[1:end-1]
p[1:(end-1)]
end

P, LinearSubspace(E)
Expand All @@ -48,8 +48,8 @@ end

Base.@kwdef mutable struct WitnessSetsProgress
ambient_dim::Int
codim::Int
current_codim::Int = 1
nhypersurfaces::Int
current_hypersurface::Int = 1
degrees::Dict{Int,Int} = Dict{Int,Int}()
is_solving::Bool = false
is_removing_points::Bool = false
Expand All @@ -58,8 +58,12 @@ Base.@kwdef mutable struct WitnessSetsProgress
current_npaths::Int = 0
progress_meter::PM.ProgressUnknown
end
WitnessSetsProgress(n::Int, codim::Int, progress_meter::PM.ProgressUnknown) =
WitnessSetsProgress(ambient_dim = n, codim = codim, progress_meter = progress_meter)
WitnessSetsProgress(n::Int, nhypersurfaces::Int, progress_meter::PM.ProgressUnknown) =
WitnessSetsProgress(
ambient_dim = n,
nhypersurfaces = nhypersurfaces,
progress_meter = progress_meter,
)
update_progress!(progress::Nothing, is_solving::Bool) = nothing
function update_progress!(progress::WitnessSetsProgress, is_solving::Bool)
progress.is_computing_hypersurfaces = false
Expand All @@ -68,10 +72,10 @@ function update_progress!(progress::WitnessSetsProgress, is_solving::Bool)
end
update_progress!(progress::Nothing, i::Int) = nothing
function update_progress!(progress::WitnessSetsProgress, i::Int)
progress.current_codim = i
progress.current_hypersurface = i
PM.update!(
progress.progress_meter,
progress.current_codim,
progress.current_hypersurface,
showvalues = showvalues(progress),
)
end
Expand All @@ -81,7 +85,7 @@ function update_progress!(progress::WitnessSetsProgress, i::Int, m::Int)
progress.current_npaths = m
PM.update!(
progress.progress_meter,
progress.current_codim,
progress.current_hypersurface,
showvalues = showvalues(progress),
)
end
Expand All @@ -90,7 +94,7 @@ function update_progress!(progress::WitnessSetsProgress, W::Union{WitnessPoints,
progress.degrees[codim(W)] = length(points(W))
PM.update!(
progress.progress_meter,
progress.current_codim,
progress.current_hypersurface,
showvalues = showvalues(progress),
)
end
Expand All @@ -108,7 +112,7 @@ function showvalues(progress::WitnessSetsProgress)
else
text = [(
"Intersect with hypersurface",
"$(progress.current_codim) / $(progress.codim)",
"$(progress.current_hypersurface) / $(progress.nhypersurfaces)",
)]
if progress.is_solving
push!(
Expand All @@ -119,7 +123,7 @@ function showvalues(progress::WitnessSetsProgress)
push!(text, ("Removing junk points", "..."))
end
push!(text, ("Current number of witness points", ""))
for c = 1:progress.codim
for c = 1:progress.current_hypersurface
d = progress.ambient_dim - c
deg = get(progress.degrees, c, nothing)
if !isnothing(deg) && deg > 0
Expand Down Expand Up @@ -252,7 +256,7 @@ function regeneration!(
if show_progress
progress = WitnessSetsProgress(
n,
codim,
c,
PM.ProgressUnknown(
dt = 1.0,
desc = "Computing witness sets...",
Expand Down Expand Up @@ -489,7 +493,7 @@ function intersect_with_hypersurface!(W, H, X, cache)
)

# the start solutions are the Cartesian product between P_next and the d-th roots of unity.
start = Iterators.product(P_next, [exp(2 * pi * im * k / d) for k = 0:d-1])
start = Iterators.product(P_next, [exp(2 * pi * im * k / d) for k = 0:(d-1)])

# here comes the loop for tracking
l_start = length(start)
Expand Down Expand Up @@ -794,7 +798,7 @@ function decompose_with_monodromy!(
)

if warning && (trace(res) > options.trace_test_tol)
@warn "Trying to decompose non-complete set of witness points (trace test failed)"
@warn "Trying to decompose non-complete set of witness points for codimension $(dim(L)) (trace test failed). Will try to compute the missing points. The output will contain all components, for which the trace test was successfull."
end

iter = 0
Expand All @@ -808,7 +812,7 @@ function decompose_with_monodromy!(
break
end

# for safety and additional monodromy
# for safety an additional monodromy
res = monodromy_solve(
MS,
non_complete_points,
Expand Down Expand Up @@ -911,7 +915,7 @@ function decompose_with_monodromy!(
end
setdiff(orbits, complete_orbits)
],
)
),
)
end
else
Expand Down Expand Up @@ -1313,7 +1317,7 @@ function degree_table(io, N::NumericalIrreducibleDecomposition)
data[i, 2] = string(components)
else
s = string(components[1:10])
data[i, 2] = string("(", s[2:end-1], ", ...)")
data[i, 2] = string("(", s[2:(end-1)], ", ...)")
end
end

Expand Down
11 changes: 4 additions & 7 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ function parameter_homotopy(
H = on_affine_chart(H)
else
m ≥ (n - length(vargroups)) || throw(FiniteException(n - length(vargroups) - m))
H = on_affine_chart(H, length.(vargroups,) .- 1)
H = on_affine_chart(H, length.(vargroups) .- 1)
end
else
m ≥ n || throw(FiniteException(n - m))
Expand Down Expand Up @@ -326,7 +326,7 @@ function start_target_homotopy(
H = on_affine_chart(H)
else
m ≥ (n - length(vargroups)) || throw(FiniteException(n - length(vargroups) - m))
H = on_affine_chart(H, length.(vargroups,) .- 1)
H = on_affine_chart(H, length.(vargroups) .- 1)
end
else
m ≥ n || throw(FiniteException(n - m))
Expand Down Expand Up @@ -384,10 +384,7 @@ The `solve` routines takes the following options:
then no further paths are tracked and the computation is finished. This is only called
for successfull paths. This is for example useful if you only want to compute one solution
of a polynomial system. For this `stop_early_cb = _ -> true` would be sufficient.
* `threading = true`: Enable multi-threading for the computation. The number of
available threads is controlled by the environment variable `JULIA_NUM_THREADS`.
Careful: Some CPUs hang when using multiple threads. To avoid this run Julia with 1
interactive thread for the REPL and `n` threads for other tasks (e.g., `julia -t 8,1` for `n=8`).
* `threading = true`: Enable multi-threading for the computation. The number of available threads is controlled by the environment variable `JULIA_NUM_THREADS`. You can run `Julia` with `n` threads using the command `julia -t n`; e.g., `julia -t 8` for `n=8`. (Some CPUs hang when using multiple threads. To avoid this run Julia with 1 interactive thread for the REPL; e.g., `julia -t 8,1` for `n=8`. Note that some CPUs seem to let `Julia` crash when using that option.)
* `tracker_options`: The options and parameters for the path tracker.
See [`TrackerOptions`](@ref).

Expand Down Expand Up @@ -601,7 +598,7 @@ function threaded_solve(
nthr = Threads.nthreads()

resize!(solver.trackers, nthr)
for i = ntrackers+1:nthr
for i = (ntrackers+1):nthr
solver.trackers[i] = deepcopy(tracker)
end

Expand Down