main
Francesco Minnocci 1 year ago
parent e3c752d82d
commit 5e8d538d09
No known key found for this signature in database
GPG Key ID: 76DA3AF9BAED1A32

@ -19,9 +19,7 @@ module RandomPoly
# of degree d_i randomly chosen between 1 and max_degree # of degree d_i randomly chosen between 1 and max_degree
function random_system(m, max_degree) function random_system(m, max_degree)
d = rand(1:max_degree, m) d = rand(1:max_degree, m)
println("generating system")
random_polys = [random_poly(d[i], m) for i in 1:m] random_polys = [random_poly(d[i], m) for i in 1:m]
println("done generating system")
return random_polys return random_polys
end end

@ -41,10 +41,9 @@ end
end end
# Main homotopy continuation loop # Main homotopy continuation loop
function solve(F, (G, roots)=start_system(F)) function solve(F, G, roots)
H = homotopy(F, G) H = homotopy(F, G)
println("Number of roots: ", length(roots))
result = Array{Future}(undef, length(roots)) result = Array{Future}(undef, length(roots))
for i in eachindex(roots) for i in eachindex(roots)
result[i] = @spawn compute_root(H, roots[i]) result[i] = @spawn compute_root(H, roots[i])
@ -69,11 +68,13 @@ end
R = random_system(3, 5) R = random_system(3, 5)
println("System: ", R) println("System: ", R)
(G, roots)=start_system(F)
println("Number of roots: ", length(roots))
# Parallel execution # Parallel execution
println("Parallel") println("PARALLEL")
@time begin @time begin
(sol, steps) = solve(R) (sol, steps) = solve(R, G, roots)
end end
println("Number of steps: ", steps) println("Number of steps: ", steps)
# converting sR to array of arrays instead of a matrix # converting sR to array of arrays instead of a matrix
@ -84,11 +85,11 @@ vars = variables(R)
println("Solutions: ", sol) println("Solutions: ", sol)
println("Norms (lower = better): ", [norm([f(vars => s) for f in R]) for s in sol]) println("Norms (lower = better): ", [norm([f(vars => s) for f in R]) for s in sol])
# Single process execution # Single execution
println("Single process") println("SINGLE")
rmprocs(workers()) rmprocs(workers())
@time begin @time begin
(sol, steps) = solve(R) (sol, steps) = solve(R, G, roots)
end end
println("Number of steps: ", steps) println("Number of steps: ", steps)
# converting sR to array of arrays instead of a matrix # converting sR to array of arrays instead of a matrix

Loading…
Cancel
Save