Skip to content

Commit 8e3f5d5

Browse files
author
fabian.froehlich
committed
Merge branch 'develop' into stable
# Conflicts: # @amimodel/makeEvents.m
2 parents db2b562 + 57d1ead commit 8e3f5d5

File tree

14 files changed

+290
-195
lines changed

14 files changed

+290
-195
lines changed

@amimodel/amimodel.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292

9393
% counter that allows enforcing of recompilation of models after
9494
% code changes
95-
compver = 15;
95+
compver = 16;
9696
end
9797

9898
properties ( GetAccess = 'public', SetAccess = 'public' )

@amimodel/generateC.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ function generateC(this)
458458
% they should act as placeholders
459459
fprintf(fid,' return(0);\n');
460460
else
461+
fprintf(fid,[' mexWarnMsgIdAndTxt("AMICI:mex:' iffun{1} ':NotAvailable","ERROR: The function ' iffun{1} ' was called but not compiled for this model.");\n']);
461462
fprintf(fid,' return(-1);\n');
462463
end
463464
end

@amimodel/generateM.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,15 @@ function generateM(this, amimodelo2)
377377
fprintf(fid,' sol.sx = bsxfun(@times,sol.sx,permute(theta(options_ami.sens_ind),[3,2,1]));\n');
378378
fprintf(fid,' sol.sy = bsxfun(@times,sol.sy,permute(theta(options_ami.sens_ind),[3,2,1]));\n');
379379
fprintf(fid,' sol.sz = bsxfun(@times,sol.sz,permute(theta(options_ami.sens_ind),[3,2,1]));\n');
380+
fprintf(fid,' sol.srz = bsxfun(@times,sol.srz,permute(theta(options_ami.sens_ind),[3,2,1]));\n');
380381
fprintf(fid,' sol.ssigmay = bsxfun(@times,sol.ssigmay,permute(theta(options_ami.sens_ind),[3,2,1]));\n');
381382
fprintf(fid,' sol.ssigmaz = bsxfun(@times,sol.ssigmaz,permute(theta(options_ami.sens_ind),[3,2,1]));\n');
382383
case 'log10'
383384
fprintf(fid,' sol.sllh = sol.sllh.*theta(options_ami.sens_ind)*log(10);\n');
384385
fprintf(fid,' sol.sx = bsxfun(@times,sol.sx,permute(theta(options_ami.sens_ind),[3,2,1])*log(10));\n');
385386
fprintf(fid,' sol.sy = bsxfun(@times,sol.sy,permute(theta(options_ami.sens_ind),[3,2,1])*log(10));\n');
386387
fprintf(fid,' sol.sz = bsxfun(@times,sol.sz,permute(theta(options_ami.sens_ind),[3,2,1])*log(10));\n');
388+
fprintf(fid,' sol.srz = bsxfun(@times,sol.srz,permute(theta(options_ami.sens_ind),[3,2,1])*log(10));\n');
387389
fprintf(fid,' sol.ssigmay = bsxfun(@times,sol.ssigmay,permute(theta(options_ami.sens_ind),[3,2,1])*log(10));\n');
388390
fprintf(fid,' sol.ssigmayz = bsxfun(@times,sol.ssigmaz,permute(theta(options_ami.sens_ind),[3,2,1])*log(10));\n');
389391
otherwise
@@ -581,6 +583,7 @@ function generateM(this, amimodelo2)
581583

582584
for fun = this.mfuns
583585
if(isfield(this.fun,fun{1}))
586+
fprintf([fun{1} ' | ']);
584587
this.fun.(fun{1}).writeMcode(this);
585588
end
586589
end

@amimodel/makeEvents.m

Lines changed: 240 additions & 169 deletions
Large diffs are not rendered by default.

@amimodel/parseModel.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ function parseModel(this)
8282
% compute functions
8383

8484
% do not change the ordering, it is essential for correct dependencies
85-
funs = {'xdot','w','dwdx','dwdp','J','x0','Jv','JBand','JSparse','y','z','deltax','dydp','dxdotdp','root','Jy','dJydx','dJydp','sJy','Jz','dJzdx','dJzdp','sJz'};
85+
funs = {'xdot','w','dwdx','dwdp','J','x0','Jv','JBand','JSparse','y','z','deltax','dydp','dxdotdp','root','Jy','Jz','sigma_y','sigma_z'};
8686

8787
if(this.forward)
88-
funs = {funs{:},'sxdot','sx0','sy','sz','sz_tf','deltasx','stau','sroot'};
88+
funs = {funs{:},'sxdot','sx0','sy','sz','sz_tf','deltasx','stau','sroot','sJy','sJz'};
8989
end
9090
if(this.adjoint)
91-
funs = {funs{:},'xBdot','qBdot','JB','JvB','JBandB','JSparseB','dydx','dzdx','dzdp','deltaxB','deltaqB','sigma_y','sigma_z','dsigma_ydp','dsigma_zdp','sx0'};
91+
funs = {funs{:},'xBdot','qBdot','JB','JvB','JBandB','JSparseB','dydx','dzdx','dzdp','deltaxB','deltaqB','dsigma_ydp','dsigma_zdp','sx0','dJydx','dJydp','dJzdx','dJzdp'};
9292
end
9393
if(this.o2flag)
9494
funs = {funs{:},'s2root'};
@@ -102,7 +102,8 @@ function parseModel(this)
102102

103103
this.funs = funs;
104104

105-
this.mfuns = {'J','dxdotdp'};
105+
%this.mfuns = {'J','dxdotdp'};
106+
this.mfuns = {};
106107

107108
% compute symbolic expressions
108109
for ifun = 1:length(funs)

amiwrap.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ function amiwrap( varargin )
9696
end
9797

9898
% generate the matlab wrapper
99+
disp('Generating M code ...')
99100
if(o2flag)
100101
model.generateM(modelo2);
101102
else

auxiliary/ami_mfun.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ function writeOutput(fid,expr)
182182
t = regexp(str,[var{1} '_([0-9]*)'],'tokens');
183183
ts = cellfun(@(x) [var{1} '_' x{1} ],t,'UniformOutput',false);
184184
td = cellfun(@(x) [var{1} '(' num2str(str2double(x)+1) ')'],t,'UniformOutput',false);
185+
ts = unique(ts);
186+
td = unique(td);
187+
[~,idx_ts] = sort(cellfun(@(x) length(x),ts),'descend');
188+
ts = ts(idx_ts);
189+
td = ts(idx_ts);
185190
for it = 1:length(ts)
186191
str = strrep(str,ts{it},td{it});
187192
end

include/symbolic_functions.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
double amilog(double x);
88
double heaviside(double x);
99

10-
double am_min(double a, double b);
11-
double Dam_min(int id,double a, double b);
12-
double am_max(double a, double b);
13-
double Dam_max(int id,double a, double b);
10+
double am_min(double a, double b, double c);
11+
double Dam_min(int id,double a, double b, double c);
12+
double am_max(double a, double b, double c);
13+
double Dam_max(int id,double a, double b, double c);
1414

1515
/* sign */
1616
double sign(double x);

src/symbolic_functions.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,26 @@ double sign(double x) {
102102
*
103103
* @param a value1 @type double
104104
* @param b value2 @type double
105+
* @param c bogus parameter do ensure correct parsing as a function @type double
105106
* @return if(a < b) then a else b @type double
106107
*
107108
*/
108-
double am_min(double a, double b) {
109+
double am_min(double a, double b, double c) {
109110
return(fmin(a,b));
110111
}
111112

112113
/**
113114
* parameter derivative of c implementation of matlab function min
114115
*
115116
* @param id argument index for differentiation
116-
* @param a bool1 @type double
117-
* @param b bool2 @type double
117+
* @param a value1 @type double
118+
* @param b value2 @type double
119+
* @param c bogus parameter do ensure correct parsing as a function @type double
118120
* @return id == 1: if(a < b) then 1 else 0 @type double
119121
* @return id == 2: if(a < b) then 0 else 1 @type double
120122
*
121123
*/
122-
double Dam_min(int id,double a, double b) {
124+
double Dam_min(int id,double a, double b, double c) {
123125
if (id == 1) {
124126
if (a < b) {
125127
return(1);
@@ -140,24 +142,26 @@ double Dam_min(int id,double a, double b) {
140142
*
141143
* @param a value1 @type double
142144
* @param b value2 @type double
145+
* @param c bogus parameter do ensure correct parsing as a function @type double
143146
* @return if(a > b) then a else b @type double
144147
*
145148
*/
146-
double am_max(double a, double b) {
149+
double am_max(double a, double b, double c) {
147150
return(fmax(a,b));
148151
}
149152

150153
/**
151154
* parameter derivative of c implementation of matlab function max
152155
*
153156
* @param id argument index for differentiation
154-
* @param a bool1 @type double
155-
* @param b bool2 @type double
157+
* @param a value1 @type double
158+
* @param b value2 @type double
159+
* @param c bogus parameter do ensure correct parsing as a function @type double
156160
* @return id == 1: if(a > b) then 1 else 0 @type double
157161
* @return id == 2: if(a > b) then 0 else 1 @type double
158162
*
159163
*/
160-
double Dam_max(int id,double a, double b) {
164+
double Dam_max(int id,double a, double b, double c) {
161165
if (id == 1) {
162166
if (a > b) {
163167
return(1);

sundials-2.6.2/src/cvodes/cvodes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,7 +2962,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
29622962
next_q = q;
29632963

29642964
/* Reset and check ewt, ewtQ, ewtS */
2965-
if (nst > 0) {
2965+
if (!reinit) {
29662966

29672967
ier = efun(zn[0], ewt, e_data);
29682968
if(ier != 0) {
@@ -5113,7 +5113,7 @@ static int cvStep(CVodeMem cv_mem)
51135113

51145114
/* If needed, adjust method parameters */
51155115

5116-
if ((nst > 0) && (hprime != h)) cvAdjustParams(cv_mem);
5116+
if ((!reinit) && (hprime != h)) cvAdjustParams(cv_mem);
51175117

51185118
/* Looping point for attempts to take a step */
51195119

@@ -5670,7 +5670,7 @@ static void cvSet(CVodeMem cv_mem)
56705670
rl1 = ONE / l[1];
56715671
gamma = h * rl1;
56725672
if (reinit) gammap = gamma;
5673-
gamrat = (nst > 0) ? gamma / gammap : ONE; /* protect x / x != 1.0 */
5673+
gamrat = (!reinit) ? gamma / gammap : ONE; /* protect x / x != 1.0 */
56745674
}
56755675

56765676
/*

0 commit comments

Comments
 (0)