Skip to content

Commit e42d272

Browse files
authored
Merge pull request #688 from ICB-DCM/develop
0.10.6 Release
2 parents 72a7b2b + 42181fa commit e42d272

File tree

89 files changed

+2395
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2395
-426
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ models/model_events/build/*
3434
models/model_nested_events/build/*
3535
!models/model_robertson
3636
models/model_robertson/build/*
37+
!models/model_calvetti
38+
models/model_calvetti/build/*
3739

3840
simulate_model_*_hdf.m
3941
simulate_model_*.m
@@ -80,6 +82,8 @@ python/.idea/*
8082
*.log
8183
*.pyc
8284
*.so
85+
*.bak
86+
*.sav
8387

8488
matlab/mtoc/config/latexextras.sty-e
8589
matlab/mtoc/config/latexextras.sty
@@ -154,3 +158,5 @@ ThirdParty/mtocpp-master*
154158
ThirdParty/sundials/build/*
155159
ThirdParty/SuiteSparse/lib/*
156160
ThirdParty/SuiteSparse/share/*
161+
ThirdParty/SuperLU_MT_3.1/
162+
ThirdParty/superlu_mt_3.1.tar.gz

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ set(SUNDIALS_LIBRARIES
6666
)
6767
set(SUNDIALS_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/ThirdParty/sundials/build/include")
6868

69+
option(SUNDIALS_SUPERLUMT_ENABLE "Enable sundials SuperLUMT?" OFF)
70+
if(SUNDIALS_SUPERLUMT_ENABLE)
71+
set(SUNDIALS_LIBRARIES ${SUNDIALS_LIBRARIES}
72+
${SUNDIALS_LIB_DIR}/libsundials_sunlinsolsuperlumt${CMAKE_STATIC_LIBRARY_SUFFIX}
73+
${CMAKE_SOURCE_DIR}/ThirdParty/SuperLU_MT_3.1/lib/libsuperlu_mt_PTHREAD${CMAKE_STATIC_LIBRARY_SUFFIX}
74+
-lblas
75+
)
76+
set(SUNDIALS_INCLUDE_DIRS ${SUNDIALS_INCLUDE_DIRS}
77+
"${CMAKE_SOURCE_DIR}/ThirdParty/SuperLU_MT_3.1/SRC/")
78+
endif()
79+
6980
set(GSL_LITE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/ThirdParty/gsl")
7081

7182
# AMICI requires BLAS, currently Intel MKL, CBLAS or MATLAB BLAS can be used.

INSTALL.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ The sources for AMICI are accessible as
77
- Source [zip](https://github.com/ICB-DCM/AMICI/zipball/master)
88
- GIT repository on [github](https://github.com/ICB-DCM/AMICI)
99

10-
### Obtaining AMICI via the GIT versioning system
10+
If AMICI was downloaded as a zip, it needs to be unpacked in a convenient directory. If AMICI was obtained via cloning of the git repository, no further unpacking is necessary.
11+
12+
### Obtaining AMICI via the GIT version control system
1113
In order to always stay up-to-date with the latest AMICI versions, simply pull it from our GIT repository and
1214
recompile it when a new release is available. For more information about GIT checkout their [website](http://git-scm.com/)
1315

1416
The GIT repository can currently be found at https://github.com/ICB-DCM/AMICI and a direct clone is possible via
1517

1618
git clone https://github.com/ICB-DCM/AMICI.git AMICI
1719

18-
## Installation
19-
20-
If AMICI was downloaded as a zip, it needs to be unpacked in a convenient directory. If AMICI was obtained via cloning of the git repository, no further unpacking is necessary.
21-
2220
### Dependencies
2321

2422
The MATLAB interface only depends on the symbolic toolbox, which is needed for model compilation, but not simulation.
@@ -82,7 +80,7 @@ For the compilation of .mex files, MATLAB needs to be configured with a working
8280
For a list of supported compilers we refer to the mathworks documentation: [mathworks.com](http://mathworks.com/support/compilers/R2018b/index.html)
8381
Note that Microsoft Visual Studio compilers are currently not supported.
8482

85-
### python
83+
### Python
8684

8785
To use AMICI from python, install the module and all other requirements using pip:
8886

@@ -167,14 +165,24 @@ To use AMICI from C++, run the
167165
./scripts/buildSuitesparse.sh
168166
./scripts/buildAmici.sh
169167

170-
script to compile amici libary. The static library file can then be linked from
168+
script to compile amici library.
169+
170+
The static library file can then be linked from
171171

172172
./build/libamici.a
173173

174174
In CMake-based packages, amici can be linked via
175175

176176
find_package(Amici)
177177

178+
*Optional*: To build AMICI with SuperLU_MT support, run
179+
180+
./scripts/buildSuperLUMT.sh
181+
./scripts/buildSundials.sh
182+
cd build/
183+
cmake -DSUNDIALS_SUPERLUMT_ENABLE=ON ..
184+
make
185+
178186
## Dependencies
179187

180188
The MATLAB interface requires the Mathworks Symbolic Toolbox for model generation via `amiwrap(...)`, but not for execution of precompiled models. Currently MATLAB R2018a or newer is not supported (see https://github.com/ICB-DCM/AMICI/issues/307)
@@ -199,3 +207,11 @@ __Algorithm 837: AMD__, an approximate minimum degree ordering algorithm, Patric
199207

200208
__Algorithm 836: COLAMD__, a column approximate minimum degree ordering algorithm, Timothy A. Davis, John R. Gilbert, Stefan I. Larimore, Esmond G. Ng
201209
_ACM Transactions on Mathematical Software_, Vol 30, Issue 3, 2004, pp 377 - 380. [PDF](http://dl.acm.org/authorize?734450)
210+
211+
212+
### Optional
213+
214+
__SuperLU_MT__, "a general purpose library for the direct solution of large,
215+
sparse, nonsymmetric systems of linear equations"
216+
(https://crd-legacy.lbl.gov/~xiaoye/SuperLU/#superlu_mt).
217+
SuperLU_MT is optional and is so far only available from the C++ interface.

documentation/FAQ.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ __A__: This may be due to an old compiler version. See [issue #161](https://gith
1818

1919
---
2020

21+
__Q__: How are events interpreted in a DAE context?
22+
23+
__A__: Currently we only support impulse free events. Also sensitivities have never been tested. Proceed with care and create an [issue](https://github.com/ICB-DCM/AMICI/issues) if any problems arise!
24+
25+
---
26+
2127
__Q__: The simulation/sensitivities I get are incorrect.
2228

2329
__A__: There are some known issues, especially with adjoint sensitivities, events and DAEs. If your particular problem is not featured in the [issues](https://github.com/ICB-DCM/AMICI/issues) list, please add it!

include/amici/defines.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ enum class LinearSolver {
102102
SPGMR = 6,
103103
SPBCG = 7,
104104
SPTFQMR = 8,
105-
KLU = 9
105+
KLU = 9,
106+
SuperLUMT = 10,
106107
};
107108

108109
/** CVODES/IDAS forward sensitivity computation method */
@@ -131,20 +132,13 @@ enum class NonlinearSolverIteration {
131132
newton = 2
132133
};
133134

134-
/** KLU state reordering */
135-
enum class StateOrdering {
136-
AMD,
137-
COLAMD,
138-
natural
139-
};
140-
141135
/** Sensitivity computation mode in steadyStateProblem */
142136
enum class SteadyStateSensitivityMode {
143137
newtonOnly,
144138
simulationFSA
145139
};
146140

147-
/** State in which the steady state computionat finished */
141+
/** State in which the steady state computation finished */
148142
enum class NewtonStatus {
149143
failed=-1,
150144
newt=1,

include/amici/model.h

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class Model : public AbstractModel {
5757
* @param ndwdp number of nonzero elements in the p derivative of the
5858
* repeating elements
5959
* @param ndxdotdw number of nonzero elements in the w derivative of xdot
60+
* @param ndJydy number of nonzero elements in the y derivative of dJy
61+
* (dimension nytrue)
6062
* @param nnz number of nonzero elements in Jacobian
6163
* @param ubw upper matrix bandwidth in the Jacobian
6264
* @param lbw lower matrix bandwidth in the Jacobian
@@ -70,7 +72,8 @@ class Model : public AbstractModel {
7072
Model(const int nx_rdata, const int nxtrue_rdata, const int nx_solver,
7173
const int nxtrue_solver, const int ny, const int nytrue, const int nz,
7274
const int nztrue, const int ne, const int nJ, const int nw,
73-
const int ndwdx, const int ndwdp, const int ndxdotdw, const int nnz,
75+
const int ndwdx, const int ndwdp, const int ndxdotdw,
76+
std::vector<int> ndJydy, const int nnz,
7477
const int ubw, const int lbw, amici::SecondOrderMode o2mode,
7578
const std::vector<amici::realtype> &p, std::vector<amici::realtype> k,
7679
const std::vector<int> &plist, std::vector<amici::realtype> idlist,
@@ -132,6 +135,29 @@ class Model : public AbstractModel {
132135
using AbstractModel::fy;
133136
using AbstractModel::fz;
134137

138+
/**
139+
* Model specific implementation of fdJydy colptrs
140+
* @param indexptrs column pointers
141+
* @param index ytrue index
142+
*/
143+
virtual void fdJydy_colptrs(sunindextype *indexptrs, int index) {
144+
throw AmiException("Requested functionality is not supported as %s "
145+
"is not implemented for this model!",
146+
__func__); // not implemented
147+
}
148+
149+
/**
150+
* Model specific implementation of fdxdotdw row vals
151+
* @param indexptrs row val pointers
152+
* @param index ytrue index
153+
*/
154+
virtual void fdJydy_rowvals(sunindextype *indexptrs, int index) {
155+
throw AmiException("Requested functionality is not supported as %s "
156+
"is not implemented for this model!",
157+
__func__); // not implemented
158+
}
159+
160+
135161
/**
136162
* Expands conservation law for states
137163
* @param x_rdata pointer to state variables with conservation laws
@@ -507,11 +533,11 @@ class Model : public AbstractModel {
507533
/**
508534
* Sensitivity of time-resolved measurement negative log-likelihood Jy
509535
* w.r.t. state variables
510-
* @param dJydx pointer to vector with values of state derivative of Jy
536+
* @param dJydx vector with values of state derivative of Jy
511537
* @param it timepoint index
512538
* @param edata pointer to experimental data instance
513539
*/
514-
void fdJydx(std::vector<realtype> *dJydx, const int it,
540+
void fdJydx(std::vector<realtype> &dJydx, const int it,
515541
const ExpData *edata);
516542

517543
/**
@@ -1140,7 +1166,7 @@ class Model : public AbstractModel {
11401166
* @return that
11411167
*/
11421168
bool getAlwaysCheckFinite() const;
1143-
1169+
11441170
/**
11451171
* @brief check whether the model was generated from python
11461172
* @return that
@@ -1176,6 +1202,8 @@ class Model : public AbstractModel {
11761202
const int ndwdp;
11771203
/** number of nonzero entries in dxdotdw */
11781204
const int ndxdotdw;
1205+
/** number of nonzero entries in dJydy */
1206+
std::vector<int> ndJydy;
11791207
/** number of nonzero entries in jacobian */
11801208
const int nnz;
11811209
/** dimension of the augmented objective function for 2nd order ASA */
@@ -1194,29 +1222,37 @@ class Model : public AbstractModel {
11941222

11951223
/** data standard deviation for current timepoint (dimension: ny) */
11961224
std::vector<realtype> sigmay;
1225+
11971226
/** parameter derivative of data standard deviation for current timepoint
11981227
* (dimension: nplist x ny, row-major) */
11991228
std::vector<realtype> dsigmaydp;
1229+
12001230
/** event standard deviation for current timepoint (dimension: nz) */
12011231
std::vector<realtype> sigmaz;
1232+
12021233
/** parameter derivative of event standard deviation for current timepoint
12031234
* (dimension: nplist x nz, row-major) */
12041235
std::vector<realtype> dsigmazdp;
1236+
12051237
/** parameter derivative of data likelihood for current timepoint
12061238
* (dimension: nplist x nJ, row-major) */
12071239
std::vector<realtype> dJydp;
1240+
12081241
/** parameter derivative of event likelihood for current timepoint
12091242
* (dimension: nplist x nJ, row-major) */
12101243
std::vector<realtype> dJzdp;
12111244

12121245
/** change in x at current timepoint (dimension: nx_solver) */
12131246
std::vector<realtype> deltax;
1247+
12141248
/** change in sx at current timepoint (dimension: nplist x nx_solver,
12151249
* row-major) */
12161250
std::vector<realtype> deltasx;
1251+
12171252
/** change in xB at current timepoint (dimension: nJ x nxtrue_cl, row-major)
12181253
*/
12191254
std::vector<realtype> deltaxB;
1255+
12201256
/** change in qB at current timepoint (dimension: nJ x nplist, row-major) */
12211257
std::vector<realtype> deltaqB;
12221258

@@ -1351,65 +1387,82 @@ class Model : public AbstractModel {
13511387

13521388
/** Sparse Jacobian (dimension: nnz)*/
13531389
SUNMatrixWrapper J;
1354-
1390+
13551391
/** Sparse dxdotdw temporary storage (dimension: ndxdotdw) */
13561392
SUNMatrixWrapper dxdotdw;
1357-
1393+
13581394
/** Sparse dwdx temporary storage (dimension: ndwdx) */
13591395
SUNMatrixWrapper dwdx;
1360-
1396+
13611397
/** Dense Mass matrix (dimension: nx_solver x nx_solver) */
13621398
SUNMatrixWrapper M;
13631399

13641400
/** current observable (dimension: nytrue) */
13651401
std::vector<realtype> my;
1402+
13661403
/** current event measurement (dimension: nztrue) */
13671404
std::vector<realtype> mz;
1405+
1406+
/** Sparse observable derivative of data likelihood
1407+
* (dimension nytrue, nJ x ny, ordering = ?) */
1408+
std::vector<SUNMatrixWrapper> dJydy;
1409+
13681410
/** observable derivative of data likelihood (dimension nJ x nytrue x ny,
1369-
* ordering = ?) */
1370-
std::vector<realtype> dJydy;
1411+
* ordering = ?) (only used if wasPythonGenerated()==false ) */
1412+
std::vector<realtype> dJydy_matlab;
1413+
13711414
/** observable sigma derivative of data likelihood (dimension nJ x nytrue x
13721415
* ny, ordering = ?) */
13731416
std::vector<realtype> dJydsigma;
13741417

13751418
/** event ouput derivative of event likelihood (dimension nJ x nztrue x nz,
13761419
* ordering = ?) */
13771420
std::vector<realtype> dJzdz;
1421+
13781422
/** event sigma derivative of event likelihood (dimension nJ x nztrue x nz,
13791423
* ordering = ?) */
13801424
std::vector<realtype> dJzdsigma;
1425+
13811426
/** event ouput derivative of event likelihood at final timepoint (dimension
13821427
* nJ x nztrue x nz, ordering = ?) */
13831428
std::vector<realtype> dJrzdz;
1429+
13841430
/** event sigma derivative of event likelihood at final timepoint (dimension
13851431
* nJ x nztrue x nz, ordering = ?) */
13861432
std::vector<realtype> dJrzdsigma;
1433+
13871434
/** state derivative of event output (dimension: nz x nx_solver, ordering =
13881435
* ?) */
13891436
std::vector<realtype> dzdx;
1437+
13901438
/** parameter derivative of event output (dimension: nz x nplist, ordering =
13911439
* ?) */
13921440
std::vector<realtype> dzdp;
1441+
13931442
/** state derivative of event timepoint (dimension: nz x nx_solver, ordering
13941443
* = ?) */
13951444
std::vector<realtype> drzdx;
1445+
13961446
/** parameter derivative of event timepoint (dimension: nz x nplist,
13971447
* ordering = ?) */
13981448
std::vector<realtype> drzdp;
1449+
13991450
/** parameter derivative of observable (dimension: nplist x ny, row-major)
14001451
*/
14011452
std::vector<realtype> dydp;
14021453

1403-
/** state derivative of observable (dimension: ny x nx_solver, ordering = ?)
1404-
*/
1454+
/** state derivative of observable
1455+
* (dimension: nx_solver x ny, ordering = row-major) */
14051456
std::vector<realtype> dydx;
1457+
14061458
/** tempory storage of w data across functions (dimension: nw) */
14071459
std::vector<realtype> w;
1460+
14081461
/** tempory storage of sparse/dense dwdp data across functions
14091462
(dimension: ndwdp)
14101463
*/
14111464
std::vector<realtype> dwdp;
1412-
1465+
14131466
/** tempory storage of stau data across functions (dimension: nplist) */
14141467
std::vector<realtype> stau;
14151468

@@ -1419,6 +1472,7 @@ class Model : public AbstractModel {
14191472

14201473
/** tempory storage x_rdata (dimension: nx_rdata) */
14211474
std::vector<realtype> x_rdata;
1475+
14221476
/** tempory storage sx_rdata slice (dimension: nx_rdata) */
14231477
std::vector<realtype> sx_rdata;
14241478

0 commit comments

Comments
 (0)