I’m using NLopt. Depending on what you are using, details may vary.
In NLopt, the syntax is roughly
optS = set_solve_options();
x0 = set_initial_guess();
for p in P
model = create_model(p);
opt.min_objective = model;
soln, _ = optimize(optS, x0);
# save soln somehwere
x0 = soln;
end
Since this is kind of obvious, I am presumably missing something in your question.
Yes, it is about 33% of the total loop time for the first parameter. The necessary time to run create_model for the first and second parameters is 21.8 and 0.6s, respectively. So, ideally, I’d like to make the model creation faster for the first case.
But then, why worry about 22 seconds? Unless you are running that loop many, many times.
If you really want to know what’s going on, I suggest to run a profiler.
The necessary time to run create_model for the first and second parameters is 21.8 and 0.6s, respectively. So, ideally, I’d like to make the model creation faster for the first case.