Skip to content
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

Not being able to parallelize. #125

Open
martinmestre opened this issue Aug 9, 2023 · 0 comments
Open

Not being able to parallelize. #125

martinmestre opened this issue Aug 9, 2023 · 0 comments

Comments

@martinmestre
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant