Data2Dynamics / d2d

a modeling environment tailored to parameter estimation in dynamical systems
https://github.com/Data2Dynamics/d2d
57 stars 29 forks source link

setting models using non-continuous rates #142

Closed FabienCrauste closed 4 years ago

FabienCrauste commented 4 years ago

I am using Data2Dynamics for a new model of immune cell dynamics, and I tried to use a term that is not continuous (a step function, but not with respect to time): it equals 0 if one of the variables is below 1, and a constant "a" if the variable is larger than 1.

I tried both the environments REACTIONS and ODES, writing either " -> Y CUSTOM "amax(0,X-1)" or "-amax(0,X-1)X" (for X) "+amax(0,X-1)*X" (for Y) but when compiling I always get an error message (I also used the "sign" function of matlab, but it's the same result), see below. I also tried to use a matlab function, that I defined, but it does not work.

The error message says:

---- Error message (using name_of_the_file and name_of_the_function)---- Error using mex Undefined symbols for architecture x86_64: "_Dname_of_the_function", referenced from: _dvdp_name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA in name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA.o "_name_of_the_function", referenced from: _fv_name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA in name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA.o _dvdp_name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA in name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA.o _fx_name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA in name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA.o _fxdouble_name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA in name_of_the_file_E9FB27B93F865CCADA526D335E3E83CA.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Error in arCompile (line 569) mex(mexopt{:},verbose{:},'-output', ar.fkt, includesstr{:}, '-DHAS_PTHREAD=1', ...

Error in arCompileAll (line 586) arCompile(forcedCompile, false, false, source_dir);

Error in name_of_the_file (line 9) arCompileAll;

where name_of_the_function is either "max" or my matlab function.

I wonder if it is possible to use non continuous or non-smooth functions in Data2Dynamics, and if so how? I looked through the documentation and I thought that using ODES instead of REACTIONS could do the job, but it does not work, or I am not using it correctly.

I would really appreciate any advice. Thanks.

clemenskreutz commented 4 years ago

Dear Fabien. Custom formulas like "amax(0,X-1)" in the def files have to be committed by D2D to Matlab's Symbolic Math toolbox and have to be properly translated to C-code. This is the technical side which could be solved rather easily. For fitting, however, one has to properly account for the parameter dependency of such events. This is not yet implemented in D2D. Such general events are discussed in Fröhlich et al., DOI: 10.1093/bioinformatics/btw764