Add ClusterManagers

main
Francesco Minnocci 1 year ago
parent 79a162cfdb
commit f114eeec77
Signed by untrusted user: BachoSeven
GPG Key ID: 2BE4AB7FDAD828A4

@ -2,6 +2,7 @@
using TypedPolynomials using TypedPolynomials
using LinearAlgebra using LinearAlgebra
using Distributed using Distributed
using ClusterManagers
# Local dependencies # Local dependencies
include("random_poly.jl") include("random_poly.jl")
@ -18,36 +19,36 @@ using .AdaptStep
using .Plot using .Plot
# Launch worker processes # Launch worker processes
num_cores = parse(Int, ENV["SLURM_CPUS_PER_TASK"]) addprocs(SlurmManager(40), N=20, t="01:00:00"))
addprocs(num_cores)
function compute_root(H, r, maxsteps)
t = 1.0
step_size = 0.01
x0 = r
m = 0
steps = 0
while t > 0 && steps < maxsteps
x0 = en_step(H, x0, t, step_size)
(m, step_size) = adapt_step(H, x0, t, step_size, m)
t -= step_size
steps += 1
end
return (x0, steps)
end
# Main homotopy continuation loop # Main homotopy continuation loop
function solve(F, (G, roots) = start_system(F), maxsteps = 1000) function solve(F, (G, roots) = start_system(F))
H=homotopy(F,G) H=homotopy(F,G)
solutions = []
step_array = []
@distributed for r in roots @distributed for r in roots
t = 1.0 (solutions, step_array) = compute_root(H, r, maxsteps = 1000)
step_size = 0.01
x0 = r
m = 0
steps = 0
while t > 0 && steps < maxsteps
x0 = en_step(H, x0, t, step_size)
(m, step_size) = adapt_step(H, x0, t, step_size, m)
t -= step_size
steps += 1
end
push!(solutions, x0)
push!(step_array, steps)
end end
# Gather results from worker processes # Gather results from worker processes
solutions = fetch(solutions) sols = fetch(solutions)
step_array = fetch(step_array) steps = fetch(step_array)
return (solutions, step_array) return (sols, steps)
end end
# Input polynomial systems # Input polynomial systems

Loading…
Cancel
Save