|
44 | 44 | "from pprint import pprint\n", |
45 | 45 | "\n", |
46 | 46 | "import amici\n", |
| 47 | + "import amici.sim.sundials as asd\n", |
47 | 48 | "import matplotlib as mpl\n", |
48 | 49 | "import numpy as np\n", |
49 | 50 | "import petab\n", |
|
120 | 121 | "source": [ |
121 | 122 | "sbml_file = f\"./{model_name}/{model_name}.xml\"\n", |
122 | 123 | "# Create an SbmlImporter instance for our SBML model\n", |
123 | | - "sbml_importer = amici.SbmlImporter(sbml_file)" |
| 124 | + "sbml_importer = amici.importers.sbml.SbmlImporter(sbml_file)" |
124 | 125 | ], |
125 | 126 | "outputs": [], |
126 | 127 | "execution_count": null |
|
136 | 137 | "name": "#%% md\n" |
137 | 138 | } |
138 | 139 | }, |
139 | | - "source": [ |
140 | | - "In this example, we want to specify fixed parameters, observables and a $\\sigma$ parameter. Unfortunately, the latter two are not part of the [SBML standard](https://sbml.org/). However, they can be provided to `amici.SbmlImporter.sbml2amici` as demonstrated in the following." |
141 | | - ] |
| 140 | + "source": "In this example, we want to specify fixed parameters, observables and a $\\sigma$ parameter. Unfortunately, the latter two are not part of the [SBML standard](https://sbml.org/). However, they can be provided to `amici.importers.sbml.SbmlImporter.sbml2amici` as demonstrated in the following." |
142 | 141 | }, |
143 | 142 | { |
144 | 143 | "cell_type": "markdown", |
|
204 | 203 | }, |
205 | 204 | "source": [ |
206 | 205 | "# Retrieve model output names and formulae from AssignmentRules and remove the respective rules\n", |
207 | | - "observables = amici.assignment_rules_to_observables(\n", |
| 206 | + "observables = amici.importers.sbml.assignment_rules_to_observables(\n", |
208 | 207 | " sbml_importer.sbml, # the libsbml model object\n", |
209 | 208 | " filter_function=lambda variable: variable.getId().startswith(\"observable_\")\n", |
210 | 209 | " and not variable.getId().endswith(\"_sigma\"),\n", |
|
231 | 230 | "source": [ |
232 | 231 | "#### Generating the module\n", |
233 | 232 | "\n", |
234 | | - "Now we can generate the python module for our model. `amici.SbmlImporter.sbml2amici` will symbolically derive the sensitivity equations, generate C++ code for model simulation, and assemble the python module." |
| 233 | + "Now we can generate the python module for our model. `SbmlImporter.sbml2amici` will symbolically derive the sensitivity equations, generate C++ code for model simulation, and assemble the python module." |
235 | 234 | ] |
236 | 235 | }, |
237 | 236 | { |
|
287 | 286 | "name": "#%%\n" |
288 | 287 | } |
289 | 288 | }, |
290 | | - "source": [ |
291 | | - "model_module = amici.import_model_module(model_name, model_output_dir)" |
292 | | - ], |
| 289 | + "source": "model_module = amici.import_model_module(model_name, model_output_dir)", |
293 | 290 | "outputs": [], |
294 | 291 | "execution_count": null |
295 | 292 | }, |
|
304 | 301 | "name": "#%% md\n" |
305 | 302 | } |
306 | 303 | }, |
307 | | - "source": [ |
308 | | - "Afterwards, we can get an instance of our model from which we can retrieve information such as parameter names:" |
309 | | - ] |
| 304 | + "source": "Afterwards, we can get an instance of our model from which we can retrieve information such as parameter names:" |
310 | 305 | }, |
311 | 306 | { |
312 | 307 | "cell_type": "code", |
|
343 | 338 | "source": [ |
344 | 339 | "#### Running simulations and analyzing results\n", |
345 | 340 | "\n", |
346 | | - "After importing the model, we can run simulations using `amici.runAmiciSimulation`. This requires a `Model` instance and a `Solver` instance. But, in order go gain a value of fit, we also need to provide some data." |
| 341 | + "After importing the model, we can run simulations using `run_simulation`. This requires a `Model` instance and a `Solver` instance. But, in order go gain a value of fit, we also need to provide some data." |
347 | 342 | ] |
348 | 343 | }, |
349 | 344 | { |
|
479 | 474 | "model.set_fixed_parameters(np.array([0.693, 0.107]))\n", |
480 | 475 | "\n", |
481 | 476 | "# set parameters to optimal values found in the benchmark collection\n", |
482 | | - "model.set_parameter_scale(amici.ParameterScaling.log10)\n", |
| 477 | + "model.set_parameter_scale(asd.ParameterScaling.log10)\n", |
483 | 478 | "model.set_free_parameters(benchmark_parameters)\n", |
484 | 479 | "\n", |
485 | 480 | "# Create solver instance\n", |
486 | 481 | "solver = model.create_solver()\n", |
487 | 482 | "\n", |
488 | 483 | "# Run simulation using model parameters from the benchmark collection and default solver options\n", |
489 | | - "rdata = amici.run_simulation(model, solver)" |
| 484 | + "rdata = asd.run_simulation(model, solver)" |
490 | 485 | ], |
491 | 486 | "outputs": [], |
492 | 487 | "execution_count": null |
|
504 | 499 | }, |
505 | 500 | "source": [ |
506 | 501 | "# Create edata instance with dimensions and timepoints\n", |
507 | | - "edata = amici.ExpData(\n", |
| 502 | + "edata = asd.ExpData(\n", |
508 | 503 | " 3, # number of observables\n", |
509 | 504 | " 0, # number of event outputs\n", |
510 | 505 | " 0, # maximum number of events\n", |
|
535 | 530 | } |
536 | 531 | }, |
537 | 532 | "source": [ |
538 | | - "rdata = amici.run_simulation(model, solver, edata)\n", |
| 533 | + "rdata = asd.run_simulation(model, solver, edata)\n", |
539 | 534 | "\n", |
540 | 535 | "print(\"Chi2 value reported in benchmark collection: 47.9765479\")\n", |
541 | 536 | "print(f\"chi2 value using AMICI: {rdata['chi2']}\")" |
|
577 | 572 | "# we make some more adjustments to our model and the solver\n", |
578 | 573 | "model.require_sensitivities_for_all_parameters()\n", |
579 | 574 | "\n", |
580 | | - "solver.set_sensitivity_method(amici.SensitivityMethod.forward)\n", |
581 | | - "solver.set_sensitivity_order(amici.SensitivityOrder.first)\n", |
| 575 | + "solver.set_sensitivity_method(asd.SensitivityMethod.forward)\n", |
| 576 | + "solver.set_sensitivity_order(asd.SensitivityOrder.first)\n", |
582 | 577 | "\n", |
583 | 578 | "\n", |
584 | 579 | "objective = pypesto.AmiciObjective(\n", |
|
0 commit comments