Result Storage

This notebook will show how to store pypesto result objects to be able to load them later on for visualization and further analysis. This includes sampling, profiling and optimization. Additionally we will show how to use optimization history to look further into an optimization run and how to store the history.

After this notebook you will… * know how to store and load optimization, profiling and sampling results * know how to store and load optimization history * know basic plotting functions for optimization history to inspect optimization convergence

[1]:
# install if not done yet
# %pip install pypesto --quiet

Imports

[2]:
import logging
import random
import tempfile

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
from IPython.display import Markdown, display

import pypesto
import pypesto.optimize as optimize
import pypesto.petab
import pypesto.profile as profile
import pypesto.sample as sample
import pypesto.visualize as visualize

mpl.rcParams['figure.dpi'] = 100
mpl.rcParams['font.size'] = 18
# set a random seed to get reproducible results
random.seed(3142)

%matplotlib inline

0. Objective function and problem definition

We will use the Boehm model from the benchmark initiative in this notebook as an example. We load the model through PEtab, a data format for specifying parameter estimation problems in systems biology.

[3]:
%%capture
# directory of the PEtab problem
petab_yaml = './boehm_JProteomeRes2014/boehm_JProteomeRes2014.yaml'

importer = pypesto.petab.PetabImporter.from_yaml(petab_yaml)
problem = importer.create_problem()

1. Filling in the result file

We will now run a standard parameter estimation pipeline with this model. Aside from the part on the history, we shall not go into detail here, as this is covered in other tutorials such as Getting Started and AMICI in pyPESTO.

Optimization

[4]:
%%time

# create optimizers
optimizer = optimize.FidesOptimizer(
    verbose=logging.WARN, options={"maxiter": 200}
)

# set number of starts
n_starts = 15  # usually a larger number >=100 is used

# Optimization
result = pypesto.optimize.minimize(
    problem=problem, optimizer=optimizer, n_starts=n_starts
)
  0%|                                                                                                              | 0/15 [00:00<?, ?it/s]2023-04-29 10:23:55.250 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.5556 and h = 2.20496e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:23:55.251 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.5556: AMICI failed to integrate the forward problem
2023-04-29 10:23:56 fides(WARNING) Stopping as function difference 1.45E-08 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
  7%|██████▊                                                                                               | 1/15 [00:02<00:35,  2.56s/it]2023-04-29 10:23:58.149 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.2578 and h = 1.54142e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:23:58.150 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.2578: AMICI failed to integrate the forward problem
2023-04-29 10:23:58 fides(WARNING) Stopping as function difference 1.37E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 13%|█████████████▌                                                                                        | 2/15 [00:04<00:25,  1.99s/it]2023-04-29 10:24:00 fides(WARNING) Stopping as function difference 7.26E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 20%|████████████████████▍                                                                                 | 3/15 [00:06<00:26,  2.17s/it]2023-04-29 10:24:01.167 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 86.7144 and h = 1.16343e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:01.167 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 86.7144: AMICI failed to integrate the forward problem
2023-04-29 10:24:01.361 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 146.103 and h = 3.52539e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:01.362 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 146.103: AMICI failed to integrate the forward problem
2023-04-29 10:24:01.483 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.469 and h = 3.94404e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:01.484 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.469: AMICI failed to integrate the forward problem
2023-04-29 10:24:01 fides(WARNING) Stopping as function difference 9.92E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 27%|███████████████████████████▏                                                                          | 4/15 [00:07<00:18,  1.71s/it]2023-04-29 10:24:02.802 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.0618 and h = 3.44486e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:02.803 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.0618: AMICI failed to integrate the forward problem
2023-04-29 10:24:02 fides(WARNING) Stopping as function difference 1.25E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 33%|██████████████████████████████████                                                                    | 5/15 [00:08<00:15,  1.53s/it]2023-04-29 10:24:03 fides(WARNING) Stopping as function difference 1.25E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 40%|████████████████████████████████████████▊                                                             | 6/15 [00:09<00:12,  1.39s/it]2023-04-29 10:24:04.413 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 151.824 and h = 3.50701e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:04.413 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 151.824: AMICI failed to integrate the forward problem
2023-04-29 10:24:04.667 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.459 and h = 2.5146e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:04.667 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.459: AMICI failed to integrate the forward problem
2023-04-29 10:24:04.945 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.582 and h = 1.92374e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:04.946 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.582: AMICI failed to integrate the forward problem
2023-04-29 10:24:05 fides(WARNING) Stopping as function difference 8.69E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 47%|███████████████████████████████████████████████▌                                                      | 7/15 [00:10<00:10,  1.30s/it]2023-04-29 10:24:07.102 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 9.8655 and h = 2.59014e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:07.103 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 9.8655: AMICI failed to integrate the forward problem
2023-04-29 10:24:07 fides(WARNING) Stopping as function difference 2.66E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 53%|██████████████████████████████████████████████████████▍                                               | 8/15 [00:13<00:10,  1.54s/it]2023-04-29 10:24:07 fides(WARNING) Stopping as function difference 3.47E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 60%|█████████████████████████████████████████████████████████████▏                                        | 9/15 [00:13<00:06,  1.16s/it]2023-04-29 10:24:07.826 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 84.599 and h = 1.13073e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:07.827 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 84.599: AMICI failed to integrate the forward problem
2023-04-29 10:24:08.190 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 90.0206 and h = 9.59745e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:08.190 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 90.0206: AMICI failed to integrate the forward problem
2023-04-29 10:24:08.493 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.0177 and h = 5.16296e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:08.494 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.0177: AMICI failed to integrate the forward problem
2023-04-29 10:24:08 fides(WARNING) Stopping as function difference 1.02E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 67%|███████████████████████████████████████████████████████████████████▎                                 | 10/15 [00:14<00:05,  1.14s/it]2023-04-29 10:24:10 fides(WARNING) Stopping as function difference 1.22E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 73%|██████████████████████████████████████████████████████████████████████████                           | 11/15 [00:16<00:05,  1.30s/it]2023-04-29 10:24:10 fides(WARNING) Stopping as function difference 2.01E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 80%|████████████████████████████████████████████████████████████████████████████████▊                    | 12/15 [00:16<00:02,  1.01it/s]2023-04-29 10:24:11.367 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.611 and h = 3.06553e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:11.367 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.611: AMICI failed to integrate the forward problem
2023-04-29 10:24:11.466 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.1017 and h = 1.43445e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:11.467 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.1017: AMICI failed to integrate the forward problem
2023-04-29 10:24:11 fides(WARNING) Stopping as function difference 1.15E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 87%|███████████████████████████████████████████████████████████████████████████████████████▌             | 13/15 [00:17<00:01,  1.01it/s]2023-04-29 10:24:12 fides(WARNING) Stopping as function difference 5.30E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 93%|██████████████████████████████████████████████████████████████████████████████████████████████▎      | 14/15 [00:18<00:01,  1.03s/it]2023-04-29 10:24:12 fides(WARNING) Stopping as function difference 1.54E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 15/15 [00:18<00:00,  1.26s/it]
CPU times: user 19 s, sys: 444 ms, total: 19.4 s
Wall time: 18.9 s

[5]:
display(Markdown(result.summary()))

Optimization Result

  • number of starts: 15

  • best value: 147.54396431144596, id=4

  • worst value: 249.74599867046513, id=14

  • number of non-finite values: 0

  • execution time summary:

    • Mean execution time: 1.257s

    • Maximum execution time: 2.561s, id=0

    • Minimum execution time: 0.295s, id=11

  • summary of optimizer messages:

    Count

    Message

    15

    Converged according to fval difference

  • best value found (approximately) 9 time(s)

  • number of plateaus found: 3

A summary of the best run:

Optimizer Result

  • optimizer used: <FidesOptimizer hessian_update=default verbose=30 options={‘maxiter’: 200}>

  • message: Converged according to fval difference

  • number of evaluations: 73

  • time taken to optimize: 1.219s

  • startpoint: [-2.27612603 -3.97878893 -4.75536979 1.01507509 4.52085869 -3.49099606 -1.43819985 -0.57852243 0.30743517]

  • endpoint: [-1.50314486 -3.3582361 4.99984874 -1.77793181 -1.75877103 3.98195654 0.63197992 0.78930862 0.73484354]

  • final objective value: 147.54396431144596

  • final gradient value: [-1.24210833e-02 -1.07239871e-03 -4.96546443e-06 -1.15883105e-02 -3.68401402e-03 -6.12209422e-03 -3.14630353e-03 8.91043641e-04 1.91794317e-03]

  • final hessian value: [[ 2.41991876e+03 2.18595132e+01 -1.18703033e-04 1.80814818e+03 6.87980199e+02 -9.06169344e+02 1.80781358e+01 -9.17931272e+00 -8.87022249e+00] [ 2.18595132e+01 1.00911607e+00 -2.10294398e-06 1.35925382e+01 8.93547021e-01 -9.00820125e+00 -4.45106795e-02 -2.96987292e-01 3.43967261e-01] [-1.18703033e-04 -2.10294398e-06 1.06019527e-11 -8.28728104e-05 -2.49854392e-05 6.41691062e-05 2.77361513e-06 -5.69473921e-08 8.71673663e-06] [ 1.80814818e+03 1.35925382e+01 -8.28728104e-05 1.37880908e+03 5.22003515e+02 -6.38361857e+02 2.39978066e+01 -8.16598344e+00 -1.58051401e+01] [ 6.87980199e+02 8.93547021e-01 -2.49854392e-05 5.22003515e+02 2.98487654e+02 -2.95580650e+02 -1.05293443e+01 -4.04534691e+00 1.45831740e+01] [-9.06169344e+02 -9.00820125e+00 6.41691062e-05 -6.38361857e+02 -2.95580650e+02 8.97338305e+02 1.04739037e+01 -3.74496175e+01 2.69898104e+01] [ 1.80781358e+01 -4.45106795e-02 2.77361513e-06 2.39978066e+01 -1.05293443e+01 1.04739037e+01 8.48376144e+01 0.00000000e+00 0.00000000e+00] [-9.17931272e+00 -2.96987292e-01 -5.69473921e-08 -8.16598344e+00 -4.04534691e+00 -3.74496175e+01 0.00000000e+00 8.48283181e+01 0.00000000e+00] [-8.87022249e+00 3.43967261e-01 8.71673663e-06 -1.58051401e+01 1.45831740e+01 2.69898104e+01 0.00000000e+00 0.00000000e+00 8.48259535e+01]]

Profiling

[6]:
%%time

# Profiling
result = profile.parameter_profile(
    problem=problem,
    result=result,
    optimizer=optimizer,
    profile_index=np.array([1, 1, 1, 0, 0, 0, 0, 0, 1]),
)
  0%|                                                                                                               | 0/9 [00:00<?, ?it/s]2023-04-29 10:24:13.240 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.035 and h = 4.37537e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:13.240 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.035: AMICI failed to integrate the forward problem
2023-04-29 10:24:13 fides(WARNING) Stopping as function difference 1.14E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:13.916 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 92.0818 and h = 2.43361e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:13.917 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 92.0818: AMICI failed to integrate the forward problem
2023-04-29 10:24:13 fides(WARNING) Stopping as function difference 1.96E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:14.052 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 152.529 and h = 3.46952e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:14.052 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 152.529: AMICI failed to integrate the forward problem
2023-04-29 10:24:14 fides(WARNING) Stopping as function difference 1.30E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:14.549 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 141.672 and h = 1.46075e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:14.550 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 141.672: AMICI failed to integrate the forward problem
2023-04-29 10:24:14.804 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 81.8014 and h = 5.76682e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:14.805 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 81.8014: AMICI failed to integrate the forward problem
2023-04-29 10:24:14.963 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 81.7469 and h = 4.74234e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:14.964 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 81.7469: AMICI failed to integrate the forward problem
2023-04-29 10:24:15 fides(WARNING) Stopping as function difference 1.82E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:15 fides(WARNING) Stopping as function difference 8.01E-08 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:15.799 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 49.0537 and h = 8.16869e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:15.799 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 49.0537: AMICI failed to integrate the forward problem
2023-04-29 10:24:15.890 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 142.082 and h = 4.29631e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:15.891 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 142.082: AMICI failed to integrate the forward problem
2023-04-29 10:24:15.907 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 140.967 and h = 3.91271e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:15.908 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 140.967: AMICI failed to integrate the forward problem
2023-04-29 10:24:16.021 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 141.539 and h = 2.54009e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:16.022 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 141.539: AMICI failed to integrate the forward problem
2023-04-29 10:24:16.306 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 73.7976 and h = 5.18648e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:16.306 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 73.7976: AMICI failed to integrate the forward problem
2023-04-29 10:24:16.343 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 141.099 and h = 9.52032e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:16.344 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 141.099: AMICI failed to integrate the forward problem
2023-04-29 10:24:16.624 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 141.023 and h = 3.67972e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:16.624 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 141.023: AMICI failed to integrate the forward problem
2023-04-29 10:24:16 fides(WARNING) Stopping as function difference 6.38E-08 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:16.905 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 68.4724 and h = 1.13687e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:16.905 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 68.4724: AMICI failed to integrate the forward problem
2023-04-29 10:24:16.941 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 68.5095 and h = 2.77394e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:16.941 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 68.5095: AMICI failed to integrate the forward problem
2023-04-29 10:24:17.189 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 68.1381 and h = 1.17233e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:17.190 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 68.1381: AMICI failed to integrate the forward problem
2023-04-29 10:24:17.362 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 139.162 and h = 3.1838e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:17.362 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 139.162: AMICI failed to integrate the forward problem
2023-04-29 10:24:17 fides(WARNING) Stopping as function difference 1.12E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:17.584 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 136.647 and h = 3.77767e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:17.584 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 136.647: AMICI failed to integrate the forward problem
2023-04-29 10:24:17.995 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 135.401 and h = 4.75108e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:17.996 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 135.401: AMICI failed to integrate the forward problem
2023-04-29 10:24:18 fides(WARNING) Stopping as function difference 1.29E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:18.747 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 131.618 and h = 1.86165e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:18.748 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 131.618: AMICI failed to integrate the forward problem
2023-04-29 10:24:18 fides(WARNING) Stopping as function difference 4.69E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 11%|███████████▍                                                                                           | 1/9 [00:05<00:47,  5.96s/it]2023-04-29 10:24:19 fides(WARNING) Stopping as function difference 2.40E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:19.381 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 85.6185 and h = 7.14033e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:19.382 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 85.6185: AMICI failed to integrate the forward problem
2023-04-29 10:24:19 fides(WARNING) Stopping as function difference 5.25E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:19.672 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 37.7049 and h = 3.68981e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:19.673 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 37.7049: AMICI failed to integrate the forward problem
2023-04-29 10:24:19.850 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 83.2298 and h = 6.90408e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:19.851 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 83.2298: AMICI failed to integrate the forward problem
2023-04-29 10:24:19 fides(WARNING) Stopping as function difference 6.01E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:20.019 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 81.3099 and h = 5.20295e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:20.020 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 81.3099: AMICI failed to integrate the forward problem
2023-04-29 10:24:20 fides(WARNING) Stopping as function difference 1.29E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:20.172 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 158.423 and h = 7.57426e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:20.173 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 158.423: AMICI failed to integrate the forward problem
2023-04-29 10:24:20.249 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 158.535 and h = 2.92907e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:20.249 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 158.535: AMICI failed to integrate the forward problem
2023-04-29 10:24:20.472 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 158.526 and h = 2.64512e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:20.472 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 158.526: AMICI failed to integrate the forward problem
2023-04-29 10:24:20 fides(WARNING) Stopping as function difference 1.31E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:20.845 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 162.536 and h = 3.7102e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:20.846 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 162.536: AMICI failed to integrate the forward problem
2023-04-29 10:24:20.921 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 162.316 and h = 7.39856e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:20.921 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 162.316: AMICI failed to integrate the forward problem
2023-04-29 10:24:20 fides(WARNING) Stopping as function difference 6.53E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:21 fides(WARNING) Stopping as function difference 9.90E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:21 fides(WARNING) Stopping as function difference 1.26E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:21 fides(WARNING) Stopping as function difference 7.14E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:21.833 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 143.818 and h = 2.47389e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:21.834 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 143.818: AMICI failed to integrate the forward problem
2023-04-29 10:24:22.118 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 95.5058 and h = 1.17446e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:22.119 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 95.5058: AMICI failed to integrate the forward problem
2023-04-29 10:24:22 fides(WARNING) Stopping as function difference 1.94E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:22 fides(WARNING) Stopping as function difference 1.40E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:22 fides(WARNING) Stopping as function difference 3.55E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
2023-04-29 10:24:23.208 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 102.032 and h = 6.26106e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:23.208 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 102.032: AMICI failed to integrate the forward problem
2023-04-29 10:24:23 fides(WARNING) Stopping as function difference 8.56E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:10<00:00,  1.14s/it]
CPU times: user 10.4 s, sys: 234 ms, total: 10.7 s
Wall time: 10.3 s

Sampling

[7]:
%%time

# Sampling
sampler = sample.AdaptiveMetropolisSampler()
result = sample.sample(
    problem=problem,
    sampler=sampler,
    n_samples=5000,  # rather low
    result=result,
    filename=None,
)
100%|████████████████████████████████████████████████████████████████████████████████████████████████| 5000/5000 [00:09<00:00, 502.59it/s]
Elapsed time: 12.470708381000001
CPU times: user 10.9 s, sys: 1.56 s, total: 12.5 s
Wall time: 9.96 s

2. Storing the result file

We filled all our analyses into one result file. We can now store this result object into HDF5 format to reload this later on.

[8]:
# create temporary file
fn = tempfile.mktemp(".hdf5")

# write result with write_result function.
# Choose which parts of the result object to save with
# corresponding booleans.
pypesto.store.write_result(
    result=result,
    filename=fn,
    problem=True,
    optimize=True,
    profile=True,
    sample=True,
)

As easy as we can save the result object, we can also load it again:

[9]:
# load result with read_result function
result_loaded = pypesto.store.read_result(fn)
WARNING: You are loading a problem.
This problem is not to be used without a separately created objective.

As you can see, when loading the result object, we get a warning regarding the problem. This is the case, as the problem is not fully saved into hdf5, as a big part of the problem is the objective function. Therefore after loading the result object we cannot evaluate the objective function anymore. We can however still use the result object for plotting and further analysis.

The best practice would be to still create the problem through petab and insert it into the result object after loading it.

[10]:
# dummy call to non-existent objective function would fail
test_parameter = result.optimize_result[0].x[problem.x_free_indices]
# result_loaded.problem.objective(test_parameter)
[11]:
result_loaded.problem = problem
print(
    f"Objective function call: {result_loaded.problem.objective(test_parameter)}"
)
print(f"Corresponding saved value: {result_loaded.optimize_result[0].fval}")
Objective function call: 147.54396938335182
Corresponding saved value: 147.54396431144596

To show that for visualizations however, the storage and loading of the result object is accurate, we will plot some result visualizations.

3. Visualization Comparison

Optimization

[12]:
# waterfall plot original
ax = visualize.waterfall(result)
ax.title.set_text("Original Result")
../_images/example_store_24_0.png
[13]:
# waterfall plot loaded
ax = visualize.waterfall(result_loaded)
ax.title.set_text("Loaded Result")
../_images/example_store_25_0.png

Profiling

[14]:
# profile plot original
ax = visualize.profiles(result)
../_images/example_store_27_0.png
[15]:
# profile plot loaded
ax = visualize.profiles(result_loaded)
../_images/example_store_28_0.png

Sampling

[16]:
# sampling plot original
ax = visualize.sampling_fval_traces(result)
../_images/example_store_30_0.png
[17]:
# sampling plot loaded
ax = visualize.sampling_fval_traces(result_loaded)
../_images/example_store_31_0.png

We can see that we are perfectly able to reproduce the plots from the loaded result object. With this we can reuse the result object for further analysis and visualization again and again without spending time and resources on rerunning the analyses.

4. Optimization History

During optimization, it is possible to regularly write the objective function trace to file. This is useful e.g. when runs fail, or for various diagnostics. Currently, pyPESTO can save histories to 3 backends: in-memory, as CSV files, or to HDF5 files.

Memory History

To record the history in-memory, just set trace_record=True in the pypesto.HistoryOptions. Then, the optimization result contains those histories:

[18]:
# record the history
history_options = pypesto.HistoryOptions(trace_record=True)

# Run optimizaitons
result = optimize.minimize(
    problem=problem,
    optimizer=optimizer,
    n_starts=n_starts,
    history_options=history_options,
    filename=None,
)
  0%|                                                                                                              | 0/15 [00:00<?, ?it/s]2023-04-29 10:24:35 fides(WARNING) Stopping as function difference 6.17E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
  7%|██████▊                                                                                               | 1/15 [00:00<00:04,  2.91it/s]2023-04-29 10:24:37 fides(WARNING) Stopping as trust region radius 6.20E-17 is smaller than machine precision.
 13%|█████████████▌                                                                                        | 2/15 [00:01<00:11,  1.14it/s]2023-04-29 10:24:37 fides(WARNING) Stopping as function difference 5.16E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 20%|████████████████████▍                                                                                 | 3/15 [00:01<00:07,  1.69it/s]2023-04-29 10:24:37.968 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 118.183 and h = 3.31466e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:37.969 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 118.183: AMICI failed to integrate the forward problem
2023-04-29 10:24:38 fides(WARNING) Stopping as function difference 4.40E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 27%|███████████████████████████▏                                                                          | 4/15 [00:02<00:07,  1.41it/s]2023-04-29 10:24:38 fides(WARNING) Stopping as function difference 3.42E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 33%|██████████████████████████████████                                                                    | 5/15 [00:03<00:07,  1.38it/s]2023-04-29 10:24:39.432 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 147.089 and h = 3.56557e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:39.433 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 147.089: AMICI failed to integrate the forward problem
2023-04-29 10:24:39.664 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.4076 and h = 1.63783e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:39.664 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.4076: AMICI failed to integrate the forward problem
2023-04-29 10:24:39.715 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 144.759 and h = 2.92771e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:39.716 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 144.759: AMICI failed to integrate the forward problem
2023-04-29 10:24:39.816 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.8685 and h = 3.80658e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:39.816 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.8685: AMICI failed to integrate the forward problem
2023-04-29 10:24:40 fides(WARNING) Stopping as function difference 1.24E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 40%|████████████████████████████████████████▊                                                             | 6/15 [00:04<00:08,  1.07it/s]2023-04-29 10:24:40.621 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 137.837 and h = 3.66603e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:40.622 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 137.837: AMICI failed to integrate the forward problem
2023-04-29 10:24:41.012 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.8169 and h = 6.69766e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:41.012 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.8169: AMICI failed to integrate the forward problem
2023-04-29 10:24:41.227 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.602 and h = 4.0429e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:41.228 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.602: AMICI failed to integrate the forward problem
2023-04-29 10:24:41 fides(WARNING) Stopping as function difference 2.01E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 47%|███████████████████████████████████████████████▌                                                      | 7/15 [00:05<00:07,  1.03it/s]2023-04-29 10:24:42 fides(WARNING) Stopping as function difference 3.65E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 53%|██████████████████████████████████████████████████████▍                                               | 8/15 [00:06<00:06,  1.03it/s]2023-04-29 10:24:42.768 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 140.383 and h = 3.18994e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:42.769 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 140.383: AMICI failed to integrate the forward problem
2023-04-29 10:24:42.892 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 91.3238 and h = 1.14244e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:42.893 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 91.3238: AMICI failed to integrate the forward problem
2023-04-29 10:24:43 fides(WARNING) Stopping as trust region radius 1.11E-16 is smaller than machine precision.
 60%|█████████████████████████████████████████████████████████████▏                                        | 9/15 [00:08<00:06,  1.09s/it]2023-04-29 10:24:44 fides(WARNING) Stopping as function difference 7.07E-08 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 67%|███████████████████████████████████████████████████████████████████▎                                 | 10/15 [00:09<00:05,  1.10s/it]2023-04-29 10:24:45.820 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 65.304 and h = 7.08868e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:45.821 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 65.304: AMICI failed to integrate the forward problem
2023-04-29 10:24:46.448 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.724 and h = 3.92752e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:46.449 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.724: AMICI failed to integrate the forward problem
2023-04-29 10:24:46 fides(WARNING) Stopping as function difference 7.69E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 73%|██████████████████████████████████████████████████████████████████████████                           | 11/15 [00:11<00:05,  1.33s/it]2023-04-29 10:24:48 fides(WARNING) Stopping as function difference 1.10E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 80%|████████████████████████████████████████████████████████████████████████████████▊                    | 12/15 [00:12<00:04,  1.40s/it]2023-04-29 10:24:49 fides(WARNING) Stopping as function difference 1.14E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 87%|███████████████████████████████████████████████████████████████████████████████████████▌             | 13/15 [00:13<00:02,  1.31s/it]2023-04-29 10:24:50 fides(WARNING) Stopping as function difference 8.68E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 93%|██████████████████████████████████████████████████████████████████████████████████████████████▎      | 14/15 [00:15<00:01,  1.40s/it]2023-04-29 10:24:51.570 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.9938 and h = 1.27747e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:51.570 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.9938: AMICI failed to integrate the forward problem
2023-04-29 10:24:51 fides(WARNING) Stopping as function difference 9.05E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 15/15 [00:16<00:00,  1.10s/it]

Now, in addition to queries on the result, we can also access the history.

[19]:
print("History type: ", type(result.optimize_result.list[0].history))
# print("Function value trace of best run: ", result.optimize_result.list[0].history.get_fval_trace())

fig, ax = plt.subplots(1, 2)
visualize.waterfall(result, ax=ax[0])
visualize.optimizer_history(result, ax=ax[1])
fig.set_size_inches((15, 5))
History type:  <class 'pypesto.history.memory.MemoryHistory'>
../_images/example_store_39_1.png

CSV History

The in-memory storage is however not stored anywhere. To do that, it is possible to store either to CSV or HDF5. This is specified via the storage_file option. If it ends in .csv, a pypesto.objective.history.CsvHistory will be employed; if it ends in .hdf5 a pypesto.objective.history.Hdf5History. Occurrences of the substring {id} in the filename are replaced by the multistart id, allowing to maintain a separate file per run (this is necessary for CSV as otherwise runs are overwritten).

[20]:
# create temporary file
fn_csv = tempfile.mktemp("_{id}.hdf5")
# record the history and store to CSV
history_options = pypesto.HistoryOptions(
    trace_record=True, storage_file=fn_csv
)

# Run optimizaitons
result = optimize.minimize(
    problem=problem,
    optimizer=optimizer,
    n_starts=n_starts,
    history_options=history_options,
    filename=None,
)
  0%|                                                                                                              | 0/15 [00:00<?, ?it/s]2023-04-29 10:24:53.093 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 172.224 and h = 2.89764e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:53.094 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 172.224: AMICI failed to integrate the forward problem
2023-04-29 10:24:53.733 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.271 and h = 4.02344e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:53.734 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.271: AMICI failed to integrate the forward problem
2023-04-29 10:24:53 fides(WARNING) Stopping as function difference 1.06E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
  7%|██████▊                                                                                               | 1/15 [00:01<00:18,  1.33s/it]2023-04-29 10:24:54.533 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.05 and h = 1.54835e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:54.533 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.05: AMICI failed to integrate the forward problem
2023-04-29 10:24:54.858 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.382 and h = 3.75849e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:54.858 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.382: AMICI failed to integrate the forward problem
2023-04-29 10:24:54.899 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.627 and h = 2.15674e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:24:54.900 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.627: AMICI failed to integrate the forward problem
2023-04-29 10:24:55 fides(WARNING) Stopping as trust region radius 1.78E-16 is smaller than machine precision.
 13%|█████████████▌                                                                                        | 2/15 [00:02<00:19,  1.48s/it]2023-04-29 10:24:58 fides(WARNING) Stopping as function difference 1.11E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 20%|████████████████████▍                                                                                 | 3/15 [00:06<00:29,  2.48s/it]2023-04-29 10:25:00 fides(WARNING) Stopping as function difference 6.99E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 27%|███████████████████████████▏                                                                          | 4/15 [00:07<00:21,  1.98s/it]2023-04-29 10:25:01 fides(WARNING) Stopping as function difference 1.00E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 33%|██████████████████████████████████                                                                    | 5/15 [00:08<00:16,  1.69s/it]2023-04-29 10:25:03 fides(WARNING) Stopping as function difference 1.08E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 40%|████████████████████████████████████████▊                                                             | 6/15 [00:10<00:15,  1.75s/it]2023-04-29 10:25:03.712 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 160 and h = 1.24447e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:03.713 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 160: AMICI failed to integrate the forward problem
2023-04-29 10:25:04.190 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.4437 and h = 1.50902e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:04.190 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.4437: AMICI failed to integrate the forward problem
2023-04-29 10:25:04.253 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 147.382 and h = 2.56865e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:04.253 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 147.382: AMICI failed to integrate the forward problem
2023-04-29 10:25:04 fides(WARNING) Stopping as function difference 5.34E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 47%|███████████████████████████████████████████████▌                                                      | 7/15 [00:12<00:12,  1.61s/it]2023-04-29 10:25:05.050 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 79.993 and h = 1.17719e-07, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:05.050 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 79.993: AMICI failed to integrate the forward problem
2023-04-29 10:25:05.512 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.948 and h = 1.32042e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:05.513 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.948: AMICI failed to integrate the forward problem
2023-04-29 10:25:05.575 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.568 and h = 2.10158e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:05.576 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.568: AMICI failed to integrate the forward problem
2023-04-29 10:25:05 fides(WARNING) Stopping as function difference 4.61E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 53%|██████████████████████████████████████████████████████▍                                               | 8/15 [00:13<00:10,  1.50s/it]2023-04-29 10:25:06.687 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 142.615 and h = 3.67463e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:06.688 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 142.615: AMICI failed to integrate the forward problem
2023-04-29 10:25:06.808 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.9061 and h = 2.87625e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:06.809 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.9061: AMICI failed to integrate the forward problem
2023-04-29 10:25:06.911 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.9431 and h = 2.53173e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:06.912 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.9431: AMICI failed to integrate the forward problem
2023-04-29 10:25:07 fides(WARNING) Stopping as function difference 7.67E-08 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 60%|█████████████████████████████████████████████████████████████▏                                        | 9/15 [00:14<00:08,  1.41s/it]2023-04-29 10:25:07.476 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 11.5523 and h = 1.18074e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:07.477 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 11.5523: AMICI failed to integrate the forward problem
2023-04-29 10:25:07.737 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.268 and h = 2.58305e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:07.737 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.268: AMICI failed to integrate the forward problem
2023-04-29 10:25:08.388 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.8179 and h = 1.22709e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:08.389 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.8179: AMICI failed to integrate the forward problem
2023-04-29 10:25:08 fides(WARNING) Stopping as function difference 4.57E-08 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 67%|███████████████████████████████████████████████████████████████████▎                                 | 10/15 [00:16<00:07,  1.47s/it]2023-04-29 10:25:09 fides(WARNING) Stopping as function difference 9.62E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 73%|██████████████████████████████████████████████████████████████████████████                           | 11/15 [00:16<00:04,  1.14s/it]2023-04-29 10:25:09.817 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 21.9565 and h = 3.95812e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:09.818 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 21.9565: AMICI failed to integrate the forward problem
2023-04-29 10:25:10 fides(WARNING) Stopping as function difference 5.49E-08 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 80%|████████████████████████████████████████████████████████████████████████████████▊                    | 12/15 [00:18<00:03,  1.30s/it]2023-04-29 10:25:11.264 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 84.1388 and h = 1.20556e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:11.265 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 84.1388: AMICI failed to integrate the forward problem
2023-04-29 10:25:11.749 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.9728 and h = 1.06089e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:11.749 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.9728: AMICI failed to integrate the forward problem
2023-04-29 10:25:12 fides(WARNING) Stopping as function difference 7.53E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 87%|███████████████████████████████████████████████████████████████████████████████████████▌             | 13/15 [00:19<00:02,  1.31s/it]2023-04-29 10:25:12 fides(WARNING) Stopping as function difference 1.50E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 93%|██████████████████████████████████████████████████████████████████████████████████████████████▎      | 14/15 [00:20<00:01,  1.06s/it]2023-04-29 10:25:13 fides(WARNING) Stopping as function difference 2.29E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 15/15 [00:20<00:00,  1.37s/it]

Note that for this simple cost function, saving to CSV takes a considerable amount of time. This overhead decreases for more costly simulators, e.g. using ODE simulations via AMICI.

[21]:
print("History type: ", type(result.optimize_result.list[0].history))
# print("Function value trace of best run: ", result.optimize_result.list[0].history.get_fval_trace())

fig, ax = plt.subplots(1, 2)
visualize.waterfall(result, ax=ax[0])
visualize.optimizer_history(result, ax=ax[1])
fig.set_size_inches((15, 5))
History type:  <class 'pypesto.history.hdf5.Hdf5History'>
../_images/example_store_44_1.png

HDF5 History

Just as in CSV, writing the history to HDF5 takes a considerable amount of time. If a user specifies a HDF5 output file named my_results.hdf5 and uses a parallelization engine, then: * a folder is created to contain partial results, named my_results/ (the stem of the output filename) * files are created to store the results of each start, named my_results/my_results_{START_INDEX}.hdf5 * a file is created to store the combined result from all starts, named my_results.hdf5. Note that this file depends on the files in the my_results/ directory, so cease to function if my_results/ is deleted.

[22]:
# create temporary file
fn_hdf5 = tempfile.mktemp(".hdf5")
# record the history and store to CSV
history_options = pypesto.HistoryOptions(
    trace_record=True, storage_file=fn_hdf5
)

# Run optimizaitons
result = optimize.minimize(
    problem=problem,
    optimizer=optimizer,
    n_starts=n_starts,
    history_options=history_options,
    filename=fn_hdf5,
)
  0%|                                                                                                              | 0/15 [00:00<?, ?it/s]2023-04-29 10:25:16 fides(WARNING) Stopping as function difference 6.30E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
  7%|██████▊                                                                                               | 1/15 [00:02<00:36,  2.62s/it]2023-04-29 10:25:17.196 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 149.625 and h = 2.81694e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:17.197 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 149.625: AMICI failed to integrate the forward problem
2023-04-29 10:25:17.382 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.1651 and h = 5.81075e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:17.383 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.1651: AMICI failed to integrate the forward problem
2023-04-29 10:25:17.498 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.651 and h = 2.08513e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:17.499 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.651: AMICI failed to integrate the forward problem
2023-04-29 10:25:17.596 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.0716 and h = 1.55917e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:17.596 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.0716: AMICI failed to integrate the forward problem
2023-04-29 10:25:17 fides(WARNING) Stopping as function difference 1.09E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 13%|█████████████▌                                                                                        | 2/15 [00:03<00:24,  1.85s/it]2023-04-29 10:25:18 fides(WARNING) Stopping as function difference 1.85E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 20%|████████████████████▍                                                                                 | 3/15 [00:04<00:14,  1.20s/it]2023-04-29 10:25:19.155 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.7305 and h = 1.3347e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:19.156 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.7305: AMICI failed to integrate the forward problem
2023-04-29 10:25:19 fides(WARNING) Stopping as function difference 7.43E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 27%|███████████████████████████▏                                                                          | 4/15 [00:05<00:14,  1.36s/it]2023-04-29 10:25:21 fides(WARNING) Stopping as function difference 1.45E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 33%|██████████████████████████████████                                                                    | 5/15 [00:07<00:14,  1.45s/it]2023-04-29 10:25:22.980 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.568 and h = 3.51935e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:22.981 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.568: AMICI failed to integrate the forward problem
2023-04-29 10:25:22 fides(WARNING) Stopping as trust region radius 9.58E-17 is smaller than machine precision.
 40%|████████████████████████████████████████▊                                                             | 6/15 [00:09<00:13,  1.53s/it]2023-04-29 10:25:23.759 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.851 and h = 5.05874e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:23.759 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.851: AMICI failed to integrate the forward problem
2023-04-29 10:25:23.962 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.8237 and h = 2.60677e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:23.962 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.8237: AMICI failed to integrate the forward problem
2023-04-29 10:25:24 fides(WARNING) Stopping as function difference 2.59E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 47%|███████████████████████████████████████████████▌                                                      | 7/15 [00:10<00:11,  1.45s/it]2023-04-29 10:25:25.037 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 121.411 and h = 7.28542e-06, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:25.037 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 121.411: AMICI failed to integrate the forward problem
2023-04-29 10:25:25 fides(WARNING) Stopping as function difference 9.57E-08 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 53%|██████████████████████████████████████████████████████▍                                               | 8/15 [00:11<00:09,  1.36s/it]2023-04-29 10:25:26 fides(WARNING) Stopping as function difference 8.77E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 60%|█████████████████████████████████████████████████████████████▏                                        | 9/15 [00:12<00:07,  1.21s/it]2023-04-29 10:25:26.821 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 182.211 and h = 4.01994e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:26.822 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 182.211: AMICI failed to integrate the forward problem
2023-04-29 10:25:27 fides(WARNING) Stopping as function difference 4.77E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 67%|███████████████████████████████████████████████████████████████████▎                                 | 10/15 [00:14<00:06,  1.33s/it]2023-04-29 10:25:28 fides(WARNING) Stopping as function difference 1.30E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 73%|██████████████████████████████████████████████████████████████████████████                           | 11/15 [00:14<00:04,  1.04s/it]2023-04-29 10:25:29.104 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 86.0229 and h = 1.42218e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:29.104 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 86.0229: AMICI failed to integrate the forward problem
2023-04-29 10:25:30 fides(WARNING) Stopping as function difference 4.38E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 80%|████████████████████████████████████████████████████████████████████████████████▊                    | 12/15 [00:16<00:03,  1.23s/it]2023-04-29 10:25:30.274 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 208.138 and h = 1.36339e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:30.275 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 208.138: AMICI failed to integrate the forward problem
2023-04-29 10:25:30.819 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 148.639 and h = 3.44999e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:30.819 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 148.639: AMICI failed to integrate the forward problem
2023-04-29 10:25:30.895 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 91.0051 and h = 1.66986e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:30.896 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 91.0051: AMICI failed to integrate the forward problem
2023-04-29 10:25:31 fides(WARNING) Stopping as function difference 5.87E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 87%|███████████████████████████████████████████████████████████████████████████████████████▌             | 13/15 [00:17<00:02,  1.33s/it]2023-04-29 10:25:31.913 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 150.269 and h = 2.33927e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:31.914 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 150.269: AMICI failed to integrate the forward problem
2023-04-29 10:25:32.032 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 87.1034 and h = 1.60318e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:32.032 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 87.1034: AMICI failed to integrate the forward problem
2023-04-29 10:25:32.353 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.146 and h = 2.02295e-05, the error test failed repeatedly or with |h| = hmin.
2023-04-29 10:25:32.353 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.146: AMICI failed to integrate the forward problem
2023-04-29 10:25:32 fides(WARNING) Stopping as function difference 1.39E-06 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
 93%|██████████████████████████████████████████████████████████████████████████████████████████████▎      | 14/15 [00:18<00:01,  1.20s/it]2023-04-29 10:25:32 fides(WARNING) Stopping as function difference 1.19E-07 was smaller than specified tolerances (atol=1.00E-08, rtol=1.00E-08)
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 15/15 [00:19<00:00,  1.27s/it]
[23]:
print("History type: ", type(result.optimize_result.list[0].history))
# print("Function value trace of best run: ", result.optimize_result.list[0].history.get_fval_trace())

fig, ax = plt.subplots(1, 2)
visualize.waterfall(result, ax=ax[0])
visualize.optimizer_history(result, ax=ax[1])
fig.set_size_inches((15, 5))
History type:  <class 'pypesto.history.hdf5.Hdf5History'>
../_images/example_store_48_1.png

For the HDF5 history, it is possible to load the history from file, and to plot it, together with the optimization result.

[24]:
# load the history
result_loaded_w_history = pypesto.store.read_result(fn_hdf5)

fig, ax = plt.subplots(1, 2)
visualize.waterfall(result_loaded_w_history, ax=ax[0])
visualize.optimizer_history(result_loaded_w_history, ax=ax[1])
fig.set_size_inches((15, 5))
WARNING: You are loading a problem.
This problem is not to be used without a separately created objective.
Loading the profiling result failed. It is highly likely that no profiling result exists within /tmp/tmp6a3yx147.hdf5.
Loading the sampling result failed. It is highly likely that no sampling result exists within /tmp/tmp6a3yx147.hdf5.
../_images/example_store_50_1.png