-
Notifications
You must be signed in to change notification settings - Fork 23
1512 Generate ODE models from yaml template #1518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HenrZu
wants to merge
12
commits into
main
Choose a base branch
from
1512-Automatic-generation-of-ODE-model
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
56d6bf6
first idea to generate ODE models from yaml template with jinja2, Tes…
HenrZu 4598389
add toml support
reneSchm f0a6637
move into generation pkg, add example, yaml without ""
HenrZu 1b18185
prevent overwrite of existing models (unless explicit allowed)
HenrZu 9753bbc
typo template
HenrZu 9166ed7
doc
HenrZu e70cf41
add simulation.py file for bindings
HenrZu 340de4e
fix binding example
HenrZu 71fb81c
[ci skip] Apply suggestions from code review
HenrZu 2633302
[ci skip] review suggestions in doc
HenrZu d552a34
add support for list of compartments in foi
HenrZu e6a9b52
move model generator into memilio generation package, fix doc style, …
HenrZu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,27 @@ | ||
| MEmilio Generation | ||
| =================== | ||
|
|
||
| .. note:: | ||
|
|
||
| The ``memilio-generation`` package contains two independent tools: | ||
|
|
||
| * **Model Generator:** generates a C++ compartmental model with Python bindings from a YAML/TOML configuration file. See :doc:`m-modelgenerator`. | ||
| * **Bindings Generator:** automatically generates Python bindings from existing C++ model source files using libclang. Described on this page. | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
| :hidden: | ||
|
|
||
| m-modelgenerator | ||
|
|
||
| .. _bindings-generator: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bindings generator should also be placed in a subsection as the model generator |
||
|
|
||
| Bindings Generator | ||
| ------------------ | ||
|
|
||
|
HenrZu marked this conversation as resolved.
|
||
| Overview | ||
| ~~~~~~~~ | ||
|
|
||
| This package provides an automatic code generator for Python bindings of the MEmilio C++ library. | ||
| It enables the automatic generation of a part of the :doc:`Python Bindings <m-simulation>` that is common across multiple models. | ||
| For a particular example, see the SEIR model with its files `oseir.cpp <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-simulation/memilio/simulation/bindings/models/oseir.cpp>`_ and `oseir.py <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-simulation/memilio/simulation/oseir.py>`_. | ||
|
|
@@ -13,7 +34,7 @@ The following figure from Chapter 5 outlines the workflow of the generator. Blue | |
|
|
||
|
|
||
| Dependencies | ||
| ---------- | ||
| ~~~~~~~~~~~~ | ||
|
|
||
| The package uses the `Clang C++ library <https://clang.llvm.org/>`_ and the `LibClang Python library <https://libclang.readthedocs.io/en/latest/index.html>`_ to analyze the C++ code of a model. Both need to be installed and share the same version. | ||
|
|
||
|
|
@@ -33,7 +54,7 @@ For a successful build, the development libraries for Python need to be installe | |
| If you want to try a different version, set your `libclang` version under ``dependencies`` in the `pyproject.toml <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-generation/pyproject.toml>`_ and change the clang command in ``create_ast`` in `ast.py <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-generation/memilio/generation/ast.py>`_. | ||
|
|
||
| Usage | ||
| ----- | ||
| ~~~~~ | ||
|
|
||
| During the installation the package creates a compilation database (compile_commands.json) for the models of the `MEmilio C++ Library <https://github.com/SciCompMod/memilio/blob/main/cpp/>`_. | ||
|
|
||
|
|
@@ -59,7 +80,7 @@ To use the visualization run the command: | |
|
|
||
|
|
||
| Visualization | ||
| ------------- | ||
| ~~~~~~~~~~~~~ | ||
|
|
||
| The package contains a `Visualization class <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-generation/memilio/generation/graph_visualization.py>`_ to display the generated AST. | ||
| This allows you to visualize the abstract syntax tree (AST) of the C++ model in different ways: | ||
|
|
@@ -83,7 +104,7 @@ This means that any nodes beyond the specified depth (e.g., all nodes at level 3 | |
| Notice that the visualization as a PNG file should not print the whole AST, as it is not possible to display the whole AST in a single image. | ||
|
|
||
| Development | ||
| ----------- | ||
| ~~~~~~~~~~~ | ||
|
|
||
| When implementing new model features you can follow these steps: | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.