`ScipyDifferentialEvolutionOptimizer` appears to load the AMICI model many times
Bug description Many of these messages in the log file, possibly every function evaluation during optimization.
Using existing amici model in folder /.../amici_models/icg_body.
Expected behavior Only one of these messages.
To reproduce Run the example in #881
Replacing the optimizer with pypesto.optimize.ScipyOptimizer() results in the expected behavior.
Environment
- Operating system: Ubuntu 20.04
-
pypestoversion: currentdevelopbranch, commit https://github.com/ICB-DCM/pyPESTO/commit/1e30f36f41bce2645b13ac2928c392d22edc44c0 - Python version: 3.8.10
It's expected that this message shows up N times for ScipyDifferentialEvolutionOptimizer(..., workers=N), because the objective is pickled there for each worker. Wouldn't consider that a bug.
The messages appear far greater than N times, e.g. using the problem from #881 and the following script.
import pypesto.petab
import pypesto.optimize
petab_yaml = 'icg_sd.yaml'
pypesto_importer = pypesto.petab.PetabImporter.from_yaml(petab_yaml)
pypesto_problem = pypesto_importer.create_problem()
optimizer = pypesto.optimize.ScipyDifferentialEvolutionOptimizer(
options={
'strategy': 'best1bin',
'maxiter': 8000,
'mutation': (0.2, 1),
'recombination': 0.7,
'popsize': 70,
'init': 'latinhypercube',
'polish': True,
'workers': 8,
}
)
result = pypesto.optimize.minimize(
pypesto_problem,
optimizer=optimizer,
n_starts=4,
filename=None,
)
Okay, potentially multiplied by popsize or maxiter :see_no_evil: .
The best we can do is not showing the message during unpickling. The rest is on scipy.
Moved "using existing" message to debug level in #912, should reduce appearance unless in debug mode.