Skip to content

Commit ffb5f33

Browse files
authored
Merge pull request #1120 from ICB-DCM/release_0.11.1
# Release 0.11.1 ## Python * Upgrade to sympy 1.6.0, which is now required minimum version (#1098, #1103) * Speed up model import * Speed-up computation of sx0, reduce file size (#1109) * Replace terribly slow sympy.MutableDenseMatrix.is_zero_matrix by custom implementation (#1104) * speedup dataframe creation in `get*AsDataFrame` (#1088) * Allow caching edatas for simulate_petab (#1106) * Fix wrong deprecation warning (Fixes #1093) * Fix segmentation faults in NewtonSolver under certain conditions (#1089, #1090, #1097) * fix wrong power function call in `unscale_parameter` (#1094) * Fix MathML conversion (#1086) * Fix deepcopy of SymPy objects (#1091) ## Matlab * handle empty rdata->{pre|post}eq_numlinsteps (Closes #1113), which previously made the matlab interface unusable * Fix generation of compileMexFile.m for matlab compilation of python code (#1115) ## C++ * Reduce memory requirements and speedup compilation of large models (#1105) * Place generated code into own namespace (#937) (#1112) * Fix several msvc compiler warnings (#1116) (Note that MSVC support is still experimental) **breaking change for users of C++ interface** * Fix swig warning: ensure base class ContextManager is known before use (Fixes #1092) (#1101) ## CI * Don't install/run valgrind on travis CI (done with github actions… (#1111)
2 parents a5f30d5 + ca8b18b commit ffb5f33

File tree

327 files changed

+2708
-341
lines changed

Some content is hidden

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

327 files changed

+2708
-341
lines changed

.github/workflows/test-large-model.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- develop
66
- master
7+
- fix_sx0_zeros
78

89
pull_request:
910
branches:

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ matrix:
3232
- CI_PYTHON=TRUE
3333
- CI_ARCHIVE=TRUE
3434
- CI_NOTEBOOK=TRUE
35-
before_install:
36-
- ./scripts/buildValgrind.sh
3735
after_script:
3836
# cpputest coverage cpp
3937
- lcov --compat-libtool --no-external --directory ${BASE_DIR}/build/CMakeFiles/amici.dir/src --base-directory ${BASE_DIR} --capture --output-file coverage_cpp.info
@@ -182,8 +180,7 @@ script:
182180
- if [[ "$CI_PYTHON" == "TRUE" ]] && [[ "$ENABLE_GCOV_COVERAGE" == "TRUE" ]]; then $FOLD codecov ./scripts/run-codecov.sh; fi
183181
- if [[ "$CI_PYTHON" == "TRUE" ]] && [[ "$ENABLE_GCOV_COVERAGE" != "TRUE" ]]; then $FOLD python-tests ./scripts/run-python-tests.sh; fi
184182
# needs to be run after python tests
185-
- if [[ "$CI_CPPUTEST" == "TRUE" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then $FOLD valgrind ./scripts/run-valgrind.sh; fi
186-
- if [[ "$CI_CPPUTEST" == "TRUE" ]] && [[ "$TRAVIS_OS_NAME" != "linux" ]]; then $FOLD cpputest ./scripts/run-cpputest.sh; fi
183+
- if [[ "$CI_CPPUTEST" == "TRUE" ]]; then $FOLD cpputest ./scripts/run-cpputest.sh; fi
187184
- if [[ "$CI_DOC" == "TRUE" ]]; then $FOLD doxygen ./scripts/run-doxygen.sh; fi
188185
- if [[ "$CI_PYTHON" == "TRUE" ]]; then $FOLD sphinx ./scripts/run-sphinx.sh; fi
189186

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ target_link_libraries(${PROJECT_NAME}
170170

171171
# For matlab interface
172172
add_custom_target(matlabInterface
173-
SOURCES src/interface_matlab.cpp src/returndata_matlab.cpp)
173+
SOURCES
174+
src/interface_matlab.cpp
175+
src/returndata_matlab.cpp
176+
include/amici/interface_matlab.h)
174177
set_target_properties(matlabInterface
175178
PROPERTIES INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/include/")
176179
find_package(Matlab)
@@ -189,6 +192,7 @@ add_custom_target(
189192
src/CMakeLists.template.cmake
190193
src/main.template.cpp
191194
src/model_header.ODE_template.h
195+
src/model.ODE_template.cpp
192196
src/wrapfunctions.ODE_template.h
193197
src/wrapfunctions.template.cpp
194198
swig/CMakeLists_model.cmake

include/amici/defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ constexpr int AMICI_ERR_FAILURE= -3;
2929
constexpr int AMICI_CONV_FAILURE= -4;
3030
constexpr int AMICI_ILL_INPUT= -22;
3131
constexpr int AMICI_ERROR= -99;
32+
constexpr int AMICI_SINGULAR_JACOBIAN= -807;
3233
constexpr int AMICI_NOT_IMPLEMENTED= -999;
3334
constexpr int AMICI_SUCCESS= 0;
3435
constexpr int AMICI_DATA_RETURN= 1;

include/amici/forwardproblem.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,23 @@ class ForwardProblem {
213213
* @return index
214214
*/
215215
int getTimepointCounter() const {
216-
return timepoint_states.size() - 1;
216+
return static_cast<int>(timepoint_states.size() - 1);
217217
}
218218

219219
/**
220220
* @brief Returns maximal event index for which simulations are available
221221
* @return index
222222
*/
223223
int getEventCounter() const {
224-
return event_states.size() - 1;
224+
return static_cast<int>(event_states.size() - 1);
225225
}
226226

227227
/**
228228
* @brief Returns maximal event index for which the timepoint is available
229229
* @return index
230230
*/
231231
int getRootCounter() const {
232-
return discs.size() - 1;
232+
return static_cast<int>(discs.size() - 1);
233233
}
234234

235235
/**

include/amici/interface_matlab.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
#include <mex.h>
77
#include <memory>
88

9-
class Model;
10-
extern std::unique_ptr<amici::Model> getModel();
119

12-
namespace amici {
10+
namespace amici {
11+
12+
namespace generic_model {
13+
extern std::unique_ptr<amici::Model> getModel();
14+
} // namespace generic_model
1315

16+
class Model;
1417
class ReturnDataMatlab;
1518

1619

@@ -39,7 +42,7 @@ void setSolverOptions(const mxArray *prhs[], int nrhs, Solver& solver);
3942
*/
4043
ReturnDataMatlab *setupReturnData(mxArray *plhs[], int nlhs);
4144

42-
45+
4346
/*!
4447
* @brief expDataFromMatlabCall parses the experimental data from the matlab
4548
* call and writes it to an ExpData class object

include/amici/misc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ const gsl::span<const T> slice(const std::vector<T> &data,
6161
* @param expected_size expected size of the buffer
6262
*/
6363
template <class T>
64-
void checkBufferSize(gsl::span<T> buffer, unsigned expected_size) {
64+
void checkBufferSize(gsl::span<T> buffer,
65+
typename gsl::span<T>::index_type expected_size) {
6566
if (buffer.size() != expected_size)
6667
throw AmiException("Incorrect buffer size! Was %u, expected %u.",
6768
buffer.size(), expected_size);

include/amici/steadystateproblem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ class SteadystateProblem {
211211
/** state differential sensitivities */
212212
AmiVectorArray sdx;
213213

214+
/** maximum number of steps for Newton solver for allocating numlinsteps */
215+
int maxSteps = 0;
216+
214217
/** weighted root-mean-square error */
215218
realtype wrms = NAN;
216219

matlab/@amimodel/compileAndLinkModel.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,24 @@ function compileAndLinkModel(modelname, modelSourceFolder, coptim, debug, funs,
143143
end
144144
end
145145

146+
% in case we compile python-generated code, there is a modelname.cpp
147+
model_cpp = fullfile(modelSourceFolder, [modelname '.cpp']);
148+
if(exist(model_cpp, 'file'))
149+
model_cpp = ['"' model_cpp '" '];
150+
model_cpp_obj = [' "' fullfile(modelObjectFolder,[modelname objectFileSuffix]) '" '];
151+
else
152+
model_cpp = '';
153+
model_cpp_obj = '';
154+
end
155+
156+
146157
% compile the wrapfunctions object
147158
fprintf('wrapfunctions | ');
148159
eval(['mex ' DEBUG COPT ...
149160
' -c -outdir "' modelObjectFolder '" "' ...
150-
fullfile(modelSourceFolder,'wrapfunctions.cpp') '" ' ...
161+
fullfile(modelSourceFolder,'wrapfunctions.cpp') '" ' model_cpp ...
151162
includesstr]);
152-
objectsstr = [objectsstr, ' "' fullfile(modelObjectFolder,['wrapfunctions' objectFileSuffix]) '"'];
163+
objectsstr = [objectsstr, ' "' fullfile(modelObjectFolder,['wrapfunctions' objectFileSuffix]) '" ' model_cpp_obj];
153164

154165
% now we have compiled everything model-specific, so we can replace hashes.mat to prevent recompilation
155166
try

matlab/@amimodel/generateC.m

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ function generateC(this)
4343
fprintf(fid,'\n');
4444
fprintf(fid,'using namespace amici;\n');
4545
fprintf(fid,'\n');
46+
fprintf(fid,'namespace amici {\n\n');
47+
fprintf(fid,['namespace model_' this.modelname '{\n\n']);
4648

4749
% function definition
4850
fprintf(fid,['void ' cppFunctionName '_' this.modelname '' this.fun.(ifun{1}).argstr ' {\n']);
@@ -82,19 +84,28 @@ function generateC(this)
8284
end
8385
fprintf(fid,'}\n');
8486
fprintf(fid,'\n');
87+
fprintf(fid,['} // namespace model_' this.modelname '\n\n']);
88+
fprintf(fid,'} // namespace amici\n\n');
89+
8590
fclose(fid);
8691
end
8792
end
8893
end
8994

95+
% wrapfunctions.h
96+
9097
fid = fopen(fullfile(this.wrap_path,'models',this.modelname,'wrapfunctions.h'),'w');
9198
fprintf(fid,'#ifndef _amici_wrapfunctions_h\n');
9299
fprintf(fid,'#define _amici_wrapfunctions_h\n');
93100
fprintf(fid,'\n');
94101
fprintf(fid,['#include "' this.modelname '.h"\n']);
95102
fprintf(fid,'\n');
103+
fprintf(fid,'namespace amici {\n\n');
104+
fprintf(fid,'namespace generic_model {\n\n');
96105
fprintf(fid,'std::unique_ptr<amici::Model> getModel();\n');
97106
fprintf(fid,'\n');
107+
fprintf(fid,'} // namespace generic_model\n\n');
108+
fprintf(fid,'} // namespace amici \n\n');
98109
fprintf(fid,'#endif /* _amici_wrapfunctions_h */\n');
99110
fclose(fid);
100111

@@ -121,9 +132,9 @@ function generateC(this)
121132
fprintf(fid,'#include "amici/model_dae.h"\n');
122133
end
123134
fprintf(fid,'\n');
124-
fprintf(fid,'namespace amici {\nclass Solver;\n}\n');
125-
fprintf(fid,'\n');
126-
fprintf(fid,'\n');
135+
fprintf(fid,'namespace amici {\n\n');
136+
fprintf(fid,'class Solver;\n\n');
137+
fprintf(fid,['namespace model_' this.modelname '{\n\n']);
127138

128139
for ifun = this.funs
129140
if(~isfield(this.fun,ifun{1}))
@@ -194,17 +205,23 @@ function generateC(this)
194205
fprintf(fid,' }\n\n');
195206
end
196207
fprintf(fid,'};\n\n');
197-
208+
fprintf(fid,['} // namespace model_' this.modelname '\n\n']);
209+
fprintf(fid,'} // namespace amici \n\n');
198210
fprintf(fid,['#endif /* _amici_' this.modelname '_h */\n']);
199211
fclose(fid);
200212

201-
213+
% wrapfunctions.cpp
202214
fid = fopen(fullfile(this.wrap_path,'models',this.modelname,'wrapfunctions.cpp'),'w');
203215
fprintf(fid,'#include "amici/model.h"\n');
204216
fprintf(fid,'#include "wrapfunctions.h"\n\n');
217+
fprintf(fid,'namespace amici {\n\n');
218+
fprintf(fid,'namespace generic_model {\n\n');
205219
fprintf(fid,'std::unique_ptr<amici::Model> getModel() {\n');
206-
fprintf(fid, [' return std::unique_ptr<amici::Model>(new Model_' this.modelname '());\n']);
220+
fprintf(fid,' return std::unique_ptr<amici::Model>(\n');
221+
fprintf(fid,[' new amici::model_' this.modelname '::Model_' this.modelname '());\n']);
207222
fprintf(fid,'}\n\n');
223+
fprintf(fid,'} // namespace generic_model\n\n');
224+
fprintf(fid,'} // namespace amici \n\n');
208225
fclose(fid);
209226

210227
fprintf('CMakeLists | ');

0 commit comments

Comments
 (0)