ICB-DCM / pyPESTO

python Parameter EStimation TOolbox
https://pypesto.readthedocs.io
BSD 3-Clause "New" or "Revised" License
211 stars 47 forks source link

`ScipyDifferentialEvolutionOptimizer` appears to load the AMICI model many times #882

Open dilpath opened 2 years ago

dilpath commented 2 years ago

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

dweindl commented 2 years ago

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.

dilpath commented 2 years ago

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,
)
dweindl commented 2 years ago

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.

yannikschaelte commented 2 years ago

Moved "using existing" message to debug level in #912, should reduce appearance unless in debug mode.