Skip to content

Commit

Permalink
Merge branch 'develop' into makej
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Nov 11, 2024
2 parents c20f7cf + de3ee0b commit 8fd3ec3
Show file tree
Hide file tree
Showing 26 changed files with 589 additions and 611 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ equation (ODE) models.
parPE offers the following features:

* MPI-based load-balancing of individual simulations
(if you don't need this, and don't require a C++ library, consider using
the [pypesto](https://pypesto.readthedocs.io/en/latest/) Python package
which is more mature and user-friendly)
* improved load balancing by intermingling multiple optimization runs
(multi-start local optimization)
* simple integration with [SBML](http://sbml.org/) models via
* integration with [SBML](http://sbml.org/) models via
[AMICI](https://github.com/AMICI-dev/AMICI) and
[PEtab](https://github.com/PEtab-dev/PEtab)
* hierarchical optimization (https://doi.org/10.1093/bioinformatics/btz581)
* interfaces to [Ipopt](https://www.coin-or.org/Ipopt/),
[Ceres](http://ceres-solver.org/),
[FFSQP](https://www.isr.umd.edu/news/news_story.php?id=4088) and
Expand All @@ -37,6 +41,12 @@ parPE offers the following features:
* Good parallel scaling to up to several thousand cores
(highly problem dependent)

**Note that this library has been developed for specific research questions
and certain assumptions may not always hold. Use with caution.
In particular, certain default settings may need adaptation (in particular,
parallelization settings and AMICI settings such as the sensitivity method).
PEtab support is patchy. Always verify your simulation results.**

## Getting started

Although various modules of parPE can be used independently, the most
Expand Down Expand Up @@ -109,7 +119,7 @@ Other sample build scripts are provided as `/build*.sh`.

## Recently tested compilers

* GCC 13.2.0
* GCC 14.2.0
* Clang 18.1.3

## Containers
Expand Down
27 changes: 15 additions & 12 deletions deps/AMICI/.github/workflows/test_benchmark_collection_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,28 @@ jobs:
AMICI_PARALLEL_COMPILE="" pip3 install -v --user \
$(ls -t python/sdist/dist/amici-*.tar.gz | head -1)[petab,test,vis]
- run: |
- name: Install test dependencies
run: |
python3 -m pip uninstall -y petab && python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@develop \
&& python3 -m pip install -U sympy
&& python3 -m pip install -U sympy \
&& python3 -m pip install git+https://github.com/ICB-DCM/fiddy.git
# retrieve test models
- name: Download and test benchmark collection
- name: Download benchmark collection
run: |
git clone --depth 1 https://github.com/benchmarking-initiative/Benchmark-Models-PEtab.git \
&& export BENCHMARK_COLLECTION="$(pwd)/Benchmark-Models-PEtab/Benchmark-Models/" \
&& pip3 install -e $BENCHMARK_COLLECTION/../src/python \
&& AMICI_PARALLEL_COMPILE="" tests/benchmark-models/test_benchmark_collection.sh
&& python3 -m pip install -e Benchmark-Models-PEtab/src/python
- name: Run tests
env:
AMICI_PARALLEL_COMPILE: ""
run: |
cd tests/benchmark-models && pytest --durations=10
# run gradient checks
- name: Run Gradient Checks
# collect & upload results
- name: Aggregate results
run: |
pip install git+https://github.com/ICB-DCM/fiddy.git \
&& cd tests/benchmark-models && pytest --durations=10 ./test_petab_benchmark.py
cd tests/benchmark-models && python3 evaluate_benchmark.py
# upload results
- uses: actions/upload-artifact@v4
with:
name: computation-times-${{ matrix.python-version }}-${{ matrix.extract_subexpressions }}
Expand Down
10 changes: 8 additions & 2 deletions deps/AMICI/.github/workflows/test_python_cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ jobs:
macos_cpp_py:
name: Tests MacOS C++/Python
runs-on: macos-latest
env:
PYTHONFAULTHANDLER: "1"

steps:
- name: Set up Python
Expand Down Expand Up @@ -291,7 +293,8 @@ jobs:

- name: Python tests
run: |
scripts/run-python-tests.sh \
# ignore warnings until https://github.com/swig/swig/issues/3061 is resolved
scripts/run-python-tests.sh -W ignore:: \
test_pregenerated_models.py \
test_splines_short.py \
test_misc.py
Expand All @@ -300,6 +303,8 @@ jobs:
macos_python:
name: Tests MacOS Python
runs-on: macos-latest
env:
PYTHONFAULTHANDLER: "1"

steps:
- name: Cache
Expand Down Expand Up @@ -351,7 +356,8 @@ jobs:
- name: Python tests
run: |
scripts/run-python-tests.sh \
# ignore warnings until https://github.com/swig/swig/issues/3061 is resolved
scripts/run-python-tests.sh -W ignore:: \
--ignore=test_pregenerated_models.py \
--ignore=test_splines_short.py \
--ignore=test_misc.py
2 changes: 1 addition & 1 deletion deps/AMICI/.github/workflows/test_python_ver_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- python-version: '3.12'
experimental: false
- python-version: '3.13'
experimental: true
experimental: false

steps:
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
Expand Down
6 changes: 3 additions & 3 deletions deps/AMICI/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
;
[subrepo]
remote = [email protected]:ICB-DCM/AMICI.git
branch = v0.27.0
commit = 638c3eef18261f82192ac250f4ef3cef5a0359e4
parent = df42a8926e9cb6aa46c4f225aa279d7742ddab09
branch = v0.28.0
commit = c3bbdd9e7261da247ef5e2a648901fd07c2f52fa
parent = db859ddeba0094b964aaba66e3aab70746e1eb80
cmdver = 0.4.8
method = merge
57 changes: 57 additions & 0 deletions deps/AMICI/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,63 @@ See also our [versioning policy](https://amici.readthedocs.io/en/latest/versioni

## v0.X Series

### v0.28.0 (2024-11-11)

**Breaking changes**

* Changed the default steady-state method to `integrationOnly`
(by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2574)

The default mode for computing steady states and sensitivities at steady
state was changed to `integrationOnly`
(from previously `integrateIfNewtonFails`).

This was done for a more robust default behavior. For example, the evaluation
in https://doi.org/10.1371/journal.pone.0312148 shows that - at least for
some models - Newton's method may easily lead to physically impossible
solutions.

To keep the previous behavior, use:
```python
amici_model.setSteadyStateComputationMode(amici.SteadyStateComputationMode.integrateIfNewtonFails)
amici_model.setSteadyStateSensitivityMode(amici.SteadyStateSensitivityMode.integrateIfNewtonFails)
```

**Fixes**

* PEtab import: **Fixed potentially incorrect sensitivities** with
observable/state-dependent sigmas.
This was fixed for all cases amici can handle, others cases will now result
in `ValueError`s (https://github.com/AMICI-dev/AMICI/pull/2563).

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2562

* Fixed potentially incorrect disabling of Newton's method

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2576

* Fixed `ModelStateDerived` copy ctor, where previously dangling pointers
could lead to crashes in some situations

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2583

* Added missing simulation status codes

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2560

* Check for unsupported observable IDs in sigma expressions

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2563


**Features**

* Optional warning in `fill_in_parameters`

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2578

**Full Changelog**: https://github.com/AMICI-dev/AMICI/compare/v0.27.0...v0.28.0

### v0.27.0 (2024-10-21)

This release comes with an **updated version of the SUNDIALS package (7.1.1)** (https://github.com/AMICI-dev/AMICI/pull/2513).
Expand Down
12 changes: 8 additions & 4 deletions deps/AMICI/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
fixes:
- "build/venv/lib/python3.9/site-packages/::python/"
- "build/venv/lib/python3.10/site-packages/::python/"
- "build/venv/lib/python3.11/site-packages/::python/"
# see https://docs.codecov.com/docs/codecovyml-reference

fixes:
# https://docs.codecov.com/docs/fixing-paths
- "build/venv/lib/python[0-9.]+/site-packages/::python/"
- "python/sdist/build/temp_amici/CMakeFiles/amici.dir/src/::src/"
- "build/CMakeFiles/amici.dir/src/::src/"
codecov:
require_ci_to_pass: yes

Expand All @@ -27,6 +29,8 @@ comment:
ignore:
- "tests/*"
- "tests/**/*"
- "build/tests/**"
- "amici_models/**"

flags:
python:
Expand Down
6 changes: 6 additions & 0 deletions deps/AMICI/include/amici/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ constexpr int AMICI_CONSTR_FAIL= -15;
constexpr int AMICI_CVODES_CONSTR_FAIL= -15;
constexpr int AMICI_IDAS_CONSTR_FAIL= -11;
constexpr int AMICI_ILL_INPUT= -22;
constexpr int AMICI_BAD_T= -25;
constexpr int AMICI_BAD_DKY= -26;
constexpr int AMICI_FIRST_QRHSFUNC_ERR= -32;
constexpr int AMICI_SRHSFUNC_FAIL= -41;
constexpr int AMICI_FIRST_SRHSFUNC_ERR= -42;
constexpr int AMICI_REPTD_SRHSFUNC_ERR= -43;
constexpr int AMICI_UNREC_SRHSFUNC_ERR= -44;
constexpr int AMICI_ERROR= -99;
constexpr int AMICI_NO_STEADY_STATE= -81;
constexpr int AMICI_DAMPING_FACTOR_ERROR= -86;
Expand Down
4 changes: 2 additions & 2 deletions deps/AMICI/include/amici/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -2063,12 +2063,12 @@ class Model : public AbstractModel, public ModelDimensions {

/** method for steady-state computation */
SteadyStateComputationMode steadystate_computation_mode_{
SteadyStateComputationMode::integrateIfNewtonFails
SteadyStateComputationMode::integrationOnly
};

/** method for steadystate sensitivities computation */
SteadyStateSensitivityMode steadystate_sensitivity_mode_{
SteadyStateSensitivityMode::integrateIfNewtonFails
SteadyStateSensitivityMode::integrationOnly
};

/**
Expand Down
90 changes: 28 additions & 62 deletions deps/AMICI/include/amici/model_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,71 +146,37 @@ struct ModelStateDerived {
, dwdw_(other.dwdw_)
, dwdx_hierarchical_(other.dwdx_hierarchical_)
, dJydy_dense_(other.dJydy_dense_) {
// Update the SUNContext of all matrices
if (J_.data()) {
J_.get()->sunctx = sunctx_;
// Update the SUNContext of all SUNDIALS objects
J_.set_ctx(sunctx_);
JB_.set_ctx(sunctx_);
dxdotdw_.set_ctx(sunctx_);
dwdx_.set_ctx(sunctx_);
dwdp_.set_ctx(sunctx_);
M_.set_ctx(sunctx_);
MSparse_.set_ctx(sunctx_);
dfdx_.set_ctx(sunctx_);
dxdotdp_full.set_ctx(sunctx_);
dxdotdp_explicit.set_ctx(sunctx_);
dxdotdp_implicit.set_ctx(sunctx_);
dxdotdx_explicit.set_ctx(sunctx_);
dxdotdx_implicit.set_ctx(sunctx_);
dx_rdatadx_solver.set_ctx(sunctx_);
dx_rdatadtcl.set_ctx(sunctx_);
dtotal_cldx_rdata.set_ctx(sunctx_);
dxdotdp.set_ctx(sunctx_);

for (auto& dJydy : dJydy_) {
dJydy.set_ctx(sunctx_);
}
if (JB_.data()) {
JB_.get()->sunctx = sunctx_;
for (auto& dwdp : dwdp_hierarchical_) {
dwdp.set_ctx(sunctx_);
}
if (dxdotdw_.data()) {
dxdotdw_.get()->sunctx = sunctx_;
}
if (dwdx_.data()) {
dwdx_.get()->sunctx = sunctx_;
}
if (dwdp_.data()) {
dwdp_.get()->sunctx = sunctx_;
}
if (M_.data()) {
M_.get()->sunctx = sunctx_;
}
if (MSparse_.data()) {
MSparse_.get()->sunctx = sunctx_;
}
if (dfdx_.data()) {
dfdx_.get()->sunctx = sunctx_;
}
if (dxdotdp_full.data()) {
dxdotdp_full.get()->sunctx = sunctx_;
}
if (dxdotdp_explicit.data()) {
dxdotdp_explicit.get()->sunctx = sunctx_;
}
if (dxdotdp_implicit.data()) {
dxdotdp_implicit.get()->sunctx = sunctx_;
}
if (dxdotdx_explicit.data()) {
dxdotdx_explicit.get()->sunctx = sunctx_;
}
if (dxdotdx_implicit.data()) {
dxdotdx_implicit.get()->sunctx = sunctx_;
}
if (dx_rdatadx_solver.data()) {
dx_rdatadx_solver.get()->sunctx = sunctx_;
}
if (dx_rdatadtcl.data()) {
dx_rdatadtcl.get()->sunctx = sunctx_;
}
if (dtotal_cldx_rdata.data()) {
dtotal_cldx_rdata.get()->sunctx = sunctx_;
}
for (auto const& dwdp : dwdp_hierarchical_) {
if (dwdp.data()) {
dwdp.get()->sunctx = sunctx_;
}
}
for (auto const& dwdx : dwdx_hierarchical_) {
if (dwdx.data()) {
dwdx.get()->sunctx = sunctx_;
}
}
if (dwdw_.data()) {
dwdw_.get()->sunctx = sunctx_;
}
if (dJydy_dense_.data()) {
dJydy_dense_.get()->sunctx = sunctx_;
for (auto& dwdx : dwdx_hierarchical_) {
dwdx.set_ctx(sunctx_);
}
sspl_.set_ctx(sunctx_);
dwdw_.set_ctx(sunctx_);
dJydy_dense_.set_ctx(sunctx_);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions deps/AMICI/include/amici/sundials_matrix_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,19 @@ class SUNMatrixWrapper {
*/
SUNContext get_ctx() const;

/**
* @brief Set SUNContext
*
* Update the SUNContext of the wrapped SUNMatrix.
*
* @param ctx SUNDIALS context to set
*/
void set_ctx(SUNContext ctx) {
if (matrix_) {
matrix_->sunctx = ctx;
}
}

private:
/**
* @brief SUNMatrix to which all methods are applied
Expand Down
14 changes: 14 additions & 0 deletions deps/AMICI/include/amici/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,20 @@ class AmiVectorArray {
*/
void copy(AmiVectorArray const& other);

/**
* @brief Set SUNContext
*
* If any AmiVector is non-empty, this changes the current SUNContext of the
* associated N_Vector. If empty, do nothing.
*
* @param ctx SUNDIALS context to set
*/
void set_ctx(SUNContext ctx) {
for (auto& vec : vec_array_) {
vec.set_ctx(ctx);
}
}

private:
/** main data storage */
std::vector<AmiVector> vec_array_;
Expand Down
Loading

0 comments on commit 8fd3ec3

Please sign in to comment.