Evolutionary.jl icon indicating copy to clipboard operation
Evolutionary.jl copied to clipboard

Not being able to parallelize.

Open martinmestre opened this issue 1 year ago • 0 comments

Hello, thank you for this great package. I am using the :thread option and running the code as julia --threads 8. The code keeps working serial.

Here is my code:

`"""Perform optimization for ϵ ∈ [56, 370] sequentially."""

using Pkg Pkg.activate(".") using PyCall using Evolutionary using DelimitedFiles using CSV using DataFrames, DataFramesMeta

pushfirst!(PyVector(pyimport("sys")."path"), "") importLib = pyimport("importlib") stream = pyimport("stream") potentials = pyimport("potential_classes") u = pyimport("astropy.units") importLib.reload(stream) importLib.reload(potentials)

"""Initial orbit conditions and output file."""

const ic_file = "param_fit_orbit_from_IbataPolysGaiaDR2-data_fixedpot.txt" const ic = readdlm(ic_file) const r☼ = 8.122

const sol_file = "param_optim_pot.txt"

println("threads=", Threads.nthreads())

"""Loop in ϵ."""

"""χ² wrap.""" function χ²Full(x) θ = x[1] ω = x[2] β = x[3]/10^5 return stream.chi2_full(θ, ω, β, m, ic, r☼) end

"""Main function.""" function main() lb = [35, 37, 1.0] ub = [25, 30, 1.5] x₀ = [36., 27., 1.25] res = Evolutionary.optimize(χ²Full, x₀, DE(populationSize=100), Evolutionary.Options(iterations=100, abstol=5.e-5, reltol=5.e-5, parallelization=:thread)) # open(sol_file,"a") do io # println(io, "xmin = $(xmin)") # end return res end

"""Running.""" m = 56.0 res = main() display(res)`

I would really appreciate any help. Besides I would like to know if it is possible to put some box in parameter space so that the solutions doesn't explore regions outside it.

martinmestre avatar Aug 09 '23 20:08 martinmestre