nlmixr2 / rxode2

rxode2
https://nlmixr2.github.io/rxode2/
GNU General Public License v3.0
30 stars 7 forks source link

iov simulation #323

Open mattfidler opened 2 years ago

mattfidler commented 2 years ago
  Hi,

I'm trying to incorporate iov in an rxode2 model using the instructions for RxODE. My code looks like

model<-RxODE({
  KA<-KA*exp(KA_eta)
  V<-V*exp(V_eta)
  CL<-CL*exp(CL_eta+iov.cl)
  cp=A2/V*(1+eps)
  d/dt(A1)<- -KA*A1;
  d/dt(A2)<- KA*A1-CL/V*A2;
})

#Create an eventTable
ev<-eventTable(amount.units = 'ug',time.units = "hours")
ev$add.dosing(dose=100000,nbr.doses = 1,dosing.to = 1,start.time = 0)
ev$add.dosing(dose=100000,nbr.doses = 1,dosing.to = 1,start.time = 100)
ev$add.sampling(0:200)
ev$occ<-ifelse(ev$time<100,1,2)

#Give initial conditions
init<-c(0,0) # Give starting values for each compartment

#Parameter values
params<-c(KA=1,CL=10,V=100)

#Omega matrix
omega<-lotri(lotri(V_eta+CL_eta~
               c(0.1,
                 0.01,0.1))|id(nu=100),
             lotri(iov.cl~0.1)|occ(nu=200))
#Sigma matrix
sigma<-lotri(eps~0.2)

#Run the simulation
sim<-rxSolve(model,events=ev,inits=init,params=params,
           sigma=sigma,omega=omega,nSub=100)

However, when I try to simulate on the model sim<-rxSolve(model,events=ev,inits=init,params=params, sigma=sigma,omega=omega,nSub=100) I get following error message Error in rxSolveSEXP(object, .ctl, .nms, .xtra, params, events, inits, : Not compatible with STRSXP: [type=NULL].

Am I doing something wrong or has iov implementation been changed for rxode2 ?

Best regards Johan Areberg

Originally posted by @jareberg in https://github.com/nlmixr2/rxode2/discussions/322

mattfidler commented 2 years ago

For me:

Thread 1 "R" received signal SIGSEGV, Segmentation fault.
0x00007ffff7c7b254 in TYPEOF () from /usr/lib/R/lib/libR.so
(gdb) bt
#0  0x00007ffff7c7b254 in TYPEOF () from /usr/lib/R/lib/libR.so
#1  0x00007fffee5ed44d in rxode2random_convertId_ (x=0x0)
    at /tmp/RtmpHDYEzV/R.INSTALL1f224c01d009/rxode2random/src/fast_factor.cpp:145
#2  0x00007fffee5dd7ea in nestingInfoSingle_ (col=<optimized out>, id=...)
    at /tmp/RtmpHDYEzV/R.INSTALL1f224c01d009/rxode2random/src/cvPost.cpp:1114
#3  0x00007fffee5de08d in nestingInfo_ (omega=<optimized out>, data=...)
    at /tmp/RtmpHDYEzV/R.INSTALL1f224c01d009/rxode2random/src/cvPost.cpp:1213
#4  0x00007fffee5e0511 in expandPars_ (objectS=0x555557d6c7b0, paramsS=<optimized out>, 
    eventsS=0x55555b83df98, controlS=<optimized out>)
    at /tmp/RtmpHDYEzV/R.INSTALL1f224c01d009/rxode2random/src/cvPost.cpp:824
#5  0x00007fffee5ccf99 in _rxode2random_expandPars_ (objectSSEXP=0x555557d6c7b0, paramsSSEXP=0x55555b96a0d8, 
    eventsSSEXP=0x55555b83df98, controlSSEXP=0x55555bf63ce0)
    at /tmp/RtmpHDYEzV/R.INSTALL1f224c01d009/rxode2random/src/RcppExports.cpp:137
#6  0x00007fffee4162bc in rxSolve_ (obj=..., rxControl=..., specParams=..., extraArgs=..., params=..., 
    events=..., inits=..., setupOnly=0)
    at /usr/lib/R/site-library/Rcpp/include/Rcpp/storage/PreserveStorage.h:75
#7  0x00007fffee42374d in rxSolveSEXP (objS=<optimized out>, rxControlS=<optimized out>, 
    specParamsS=<optimized out>, extraArgsS=0x55555c074548, paramsS=<optimized out>, eventsS=0x55555b83df98, 
    initsS=0x55555c0f7db8, setupOnlyS=0x555558d66070)
    at /tmp/Rtmpo5SVP6/R.INSTALL1f46e1bb4cab1/rxode2/src/rxData.cpp:5641
#8  0x00007fffee33af8f in _rxode2_rxSolveSEXP_try (objSSEXP=0x555557d6c7b0, rxControlSSEXP=0x55555bf63ce0, 
    specParamsSSEXP=0x55555c072728, extraArgsSSEXP=0x55555c074548, paramsSSEXP=0x55555b96a0d8, 
    eventsSSEXP=0x55555b83df98, initsSSEXP=0x55555c0f7db8, setupOnlySSEXP=0x555558d66070)
    at /tmp/Rtmpo5SVP6/R.INSTALL1f46e1bb4cab1/rxode2/src/RcppExports.cpp:965
#9  0x00007fffee33b1db in _rxode2_rxSolveSEXP (objSSEXP=0x555557d6c7b0, rxControlSSEXP=0x55555bf63ce0, 
    specParamsSSEXP=0x55555c072728, extraArgsSSEXP=0x55555c074548, paramsSSEXP=0x55555b96a0d8, 
    eventsSSEXP=0x55555b83df98, initsSSEXP=0x55555c0f7db8, setupOnlySSEXP=0x555558d66070)
    at /tmp/Rtmpo5SVP6/R.INSTALL1f46e1bb4cab1/rxode2/src/RcppExports.cpp:973
#10 0x00007ffff7be7652 in ?? () from /usr/lib/R/lib/libR.so
#11 0x00007ffff7c2b97b in ?? () from /usr/lib/R/lib/libR.so
#12 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#13 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#14 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#15 0x00007ffff7c32db5 in ?? () from /usr/lib/R/lib/libR.so
#16 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#17 0x00007ffff7c13deb in ?? () from /usr/lib/R/lib/libR.so
#18 0x00007ffff7c1ddf8 in ?? () from /usr/lib/R/lib/libR.so
#19 0x00007ffff7c2b729 in ?? () from /usr/lib/R/lib/libR.so
#20 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#21 0x00007ffff7c13deb in ?? () from /usr/lib/R/lib/libR.so
#22 0x00007ffff7c1ddf8 in ?? () from /usr/lib/R/lib/libR.so
#23 0x00007ffff7c2b729 in ?? () from /usr/lib/R/lib/libR.so
#24 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#25 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#26 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#27 0x00007ffff7c32db5 in ?? () from /usr/lib/R/lib/libR.so
#28 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#29 0x00007ffff7c13deb in ?? () from /usr/lib/R/lib/libR.so
#30 0x00007ffff7c1ddf8 in ?? () from /usr/lib/R/lib/libR.so
#31 0x00007ffff7c2b729 in ?? () from /usr/lib/R/lib/libR.so
#32 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#33 0x00007ffff7c13deb in ?? () from /usr/lib/R/lib/libR.so
#34 0x00007ffff7c1ddf8 in ?? () from /usr/lib/R/lib/libR.so
#35 0x00007ffff7c2b729 in ?? () from /usr/lib/R/lib/libR.so
#36 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#37 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#38 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#39 0x00007ffff7c32db5 in ?? () from /usr/lib/R/lib/libR.so
#40 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#41 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#42 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#43 0x00007ffff7c32db5 in ?? () from /usr/lib/R/lib/libR.so
#44 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#45 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#46 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#47 0x00007ffff7c32db5 in ?? () from /usr/lib/R/lib/libR.so
#48 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#49 0x00007ffff7c13deb in ?? () from /usr/lib/R/lib/libR.so
#50 0x00007ffff7c1ddf8 in ?? () from /usr/lib/R/lib/libR.so
#51 0x00007ffff7c2b729 in ?? () from /usr/lib/R/lib/libR.so
#52 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#53 0x00007ffff7c13deb in ?? () from /usr/lib/R/lib/libR.so
#54 0x00007ffff7c1ddf8 in ?? () from /usr/lib/R/lib/libR.so
#55 0x00007ffff7c2b729 in ?? () from /usr/lib/R/lib/libR.so
#56 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#57 0x00007ffff7c13deb in ?? () from /usr/lib/R/lib/libR.so
#58 0x00007ffff7c1ddf8 in ?? () from /usr/lib/R/lib/libR.so
#59 0x00007ffff7c2b729 in ?? () from /usr/lib/R/lib/libR.so
#60 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#61 0x00007ffff7c13deb in ?? () from /usr/lib/R/lib/libR.so
#62 0x00007ffff7c1ddf8 in ?? () from /usr/lib/R/lib/libR.so
#63 0x00007ffff7c2b729 in ?? () from /usr/lib/R/lib/libR.so
#64 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#65 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#66 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#67 0x00007ffff7c32db5 in ?? () from /usr/lib/R/lib/libR.so
#68 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#69 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#70 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#71 0x00007ffff7c32db5 in ?? () from /usr/lib/R/lib/libR.so
#72 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#73 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#74 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#75 0x00007ffff7c32db5 in ?? () from /usr/lib/R/lib/libR.so
#76 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#77 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#78 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#79 0x00007ffff7c32db5 in ?? () from /usr/lib/R/lib/libR.so
#80 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#81 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#82 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#83 0x00007ffff7c82cf7 in ?? () from /usr/lib/R/lib/libR.so
#84 0x00007ffff7d84c4a in ?? () from /usr/lib/R/lib/libR.so
#85 0x00007ffff7c830b1 in ?? () from /usr/lib/R/lib/libR.so
#86 0x00007ffff7c23e80 in ?? () from /usr/lib/R/lib/libR.so
#87 0x00007ffff7c0cc18 in Rf_eval () from /usr/lib/R/lib/libR.so
#88 0x00007ffff7c1520f in ?? () from /usr/lib/R/lib/libR.so
#89 0x00007ffff7c0c968 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#90 0x00007ffff7c0cd4a in Rf_eval () from /usr/lib/R/lib/libR.so
#91 0x00007ffff7c19f32 in ?? () from /usr/lib/R/lib/libR.so
#92 0x00007ffff7c0d027 in Rf_eval () from /usr/lib/R/lib/libR.so
#93 0x00007ffff7c6b3b2 in Rf_ReplIteration () from /usr/lib/R/lib/libR.so
#94 0x00007ffff7c6b770 in ?? () from /usr/lib/R/lib/libR.so
#95 0x00007ffff7c6c529 in run_Rmainloop () from /usr/lib/R/lib/libR.so
#96 0x000055555555509f in main ()
#97 0x00007ffff78fdd90 in __libc_start_call_main (main=main@entry=0x555555555080 <main>, argc=argc@entry=1, 
    argv=argv@entry=0x7fffffffe978) at ../sysdeps/nptl/libc_start_call_main.h:58
#98 0x00007ffff78fde40 in __libc_start_main_impl (main=0x555555555080 <main>, argc=1, argv=0x7fffffffe978, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe968)
    at ../csu/libc-start.c:392
#99 0x00005555555550d5 in _start ()
mattfidler commented 2 years ago
> sim<-rxSolve(model,events=ev,inits=init,params=params,
           sigma=sigma,omega=omega,nSub=100)
+ 
Thread 1 "R" hit Catchpoint 1 (exception thrown), 0x00007ffff521a4e1 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0  0x00007ffff521a4e1 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007ffff25cd57c in Rcpp::internal::r_true_cast<16> (x=0x555555570d80)
    at /usr/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h:131
#2  0x00007ffff25f4ee4 in Rcpp::r_cast<16> (x=0x555555570d80)
    at /usr/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h:176
#3  Rcpp::Vector<16, Rcpp::PreserveStorage>::Vector (this=<optimized out>, x=<optimized out>, 
    this=<optimized out>, x=<optimized out>) at /usr/lib/R/site-library/Rcpp/include/Rcpp/vector/Vector.h:74
#4  0x00007ffff25ed616 in cvPost_ (nuS=0x55555f509a28, omegaS=0x555555570d80, nS=<optimized out>, 
    omegaIsCholS=0x55555bf17f58, returnCholS=0x55555bf17f90, typeS=0x55555bf17fc8, 
    diagXformTypeS=0x55555f502e88) at /usr/lib/R/site-library/Rcpp/include/Rcpp/storage/PreserveStorage.h:75
#5  0x00007ffff25f3701 in expandPars_ (objectS=<optimized out>, paramsS=<optimized out>, 
    eventsS=0x55555d212f98, controlS=<optimized out>)
    at /usr/lib/R/site-library/Rcpp/include/Rcpp/storage/PreserveStorage.h:75
#6  0x00007ffff25def99 in _rxode2random_expandPars_ (objectSSEXP=0x5555591adaa0, paramsSSEXP=0x55555d22aef8, 
    eventsSSEXP=0x55555d212f98, controlSSEXP=0x55555f584f50)
    at /tmp/Rtmp2sqUJY/R.INSTALL17dc64111417e/rxode2random/src/RcppExports.cpp:137
#7  0x00007ffff24282bc in rxSolve_ (obj=..., rxControl=..., specParams=..., extraArgs=..., params=..., 
    events=..., inits=..., setupOnly=0)
    at /usr/lib/R/site-library/Rcpp/include/Rcpp/storage/PreserveStorage.h:75
#8  0x00007ffff243574d in rxSolveSEXP (objS=<optimized out>, rxControlS=<optimized out>, 
    specParamsS=<optimized out>, extraArgsS=0x55555f50a8d8, paramsS=<optimized out>, eventsS=0x55555d212f98, 
    initsS=0x55555d214d08, setupOnlyS=0x55555f5035f8)
    at /tmp/RtmpRNcDE8/R.INSTALL17ef221c63f8/rxode2/src/rxData.cpp:5641
#9  0x00007ffff234cf8f in _rxode2_rxSolveSEXP_try (objSSEXP=0x5555591adaa0, rxControlSSEXP=0x55555f584f50, 
    specParamsSSEXP=0x55555f1c41d8, extraArgsSSEXP=0x55555f50a8d8, paramsSSEXP=0x55555d22aef8, 
    eventsSSEXP=0x55555d212f98, initsSSEXP=0x55555d214d08, setupOnlySSEXP=0x55555f5035f8)
    at /tmp/RtmpRNcDE8/R.INSTALL17ef221c63f8/rxode2/src/RcppExports.cpp:965
#10 0x00007ffff234d1db in _rxode2_rxSolveSEXP (objSSEXP=0x5555591adaa0, rxControlSSEXP=0x55555f584f50, 
    specParamsSSEXP=0x55555f1c41d8, extraArgsSSEXP=0x55555f50a8d8, paramsSSEXP=0x55555d22aef8, 
    eventsSSEXP=0x55555d212f98, initsSSEXP=0x55555d214d08, setupOnlySSEXP=0x55555f5035f8)
    at /tmp/RtmpRNcDE8/R.INSTALL17ef221c63f8/rxode2/src/RcppExports.cpp:973
mattfidler commented 2 years ago
#0  0x00007ffff521a4e1 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007fffee5bba14 in Rcpp::internal::r_true_cast<16> (x=0x5555555718f0)
    at /usr/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h:131
#2  0x00007fffee5e4804 in Rcpp::r_cast<16> (x=0x5555555718f0)
    at /usr/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h:176
#3  Rcpp::Vector<16, Rcpp::PreserveStorage>::Vector (this=<optimized out>, x=<optimized out>, 
    this=<optimized out>, x=<optimized out>) at /usr/lib/R/site-library/Rcpp/include/Rcpp/vector/Vector.h:74
#4  0x00007fffee5de016 in cvPost_ (nuS=0x55555b557738, omegaS=0x5555555718f0, nS=<optimized out>, 
    omegaIsCholS=0x55555b314b58, returnCholS=0x55555b314b20, typeS=0x55555b314ae8, 
    diagXformTypeS=0x55555a70a350) at /tmp/Rtmp4P9mXM/R.INSTALL185561f4362c6/rxode2random/src/cvPost.cpp:480
#5  0x00007fffee5e2f61 in expandPars_ (objectS=<optimized out>, paramsS=<optimized out>, 
    eventsS=0x55555b93e3b8, controlS=<optimized out>)
    at /tmp/Rtmp4P9mXM/R.INSTALL185561f4362c6/rxode2random/src/cvPost.cpp:890
#6  0x00007fffee5cd34a in _rxode2random_expandPars_ (objectSSEXP=0x555557d358e0, paramsSSEXP=0x55555b80cc08, 
    eventsSSEXP=0x55555b93e3b8, controlSSEXP=0x55555bb5f090)
    at /tmp/Rtmp4P9mXM/R.INSTALL185561f4362c6/rxode2random/src/RcppExports.cpp:137
#7  0x00007fffee4216d6 in rxSolve_ (obj=..., rxControl=..., specParams=..., extraArgs=..., params=..., 
    events=..., inits=..., setupOnly=0) at /tmp/RtmpSxM9pm/R.INSTALL18679149efe5f/rxode2/src/rxData.cpp:4574
#8  0x00007fffee42f4cd in rxSolveSEXP (objS=<optimized out>, rxControlS=<optimized out>, 
    specParamsS=<optimized out>, extraArgsS=0x55555b3ef668, paramsS=<optimized out>, eventsS=0x55555b93e3b8, 
    initsS=0x55555b9b9f58, setupOnlyS=0x55555a71c580)
    at /tmp/RtmpSxM9pm/R.INSTALL18679149efe5f/rxode2/src/rxData.cpp:5641
#9  0x00007fffee33b89f in _rxode2_rxSolveSEXP_try (objSSEXP=0x555557d358e0, rxControlSSEXP=0x55555bb5f090, 
    specParamsSSEXP=0x55555c1a7c68, extraArgsSSEXP=0x55555b3ef668, paramsSSEXP=0x55555b80cc08, 
    eventsSSEXP=0x55555b93e3b8, initsSSEXP=0x55555b9b9f58, setupOnlySSEXP=0x55555a71c580)
    at /tmp/RtmpSxM9pm/R.INSTALL18679149efe5f/rxode2/src/RcppExports.cpp:965
#10 0x00007fffee33bafb in _rxode2_rxSolveSEXP (objSSEXP=0x555557d358e0, rxControlSSEXP=0x55555bb5f090, 
    specParamsSSEXP=0x55555c1a7c68, extraArgsSSEXP=0x55555b3ef668, paramsSSEXP=0x55555b80cc08, 
    eventsSSEXP=0x55555b93e3b8, initsSSEXP=0x55555b9b9f58, setupOnlySSEXP=0x55555a71c580)
    at /tmp/RtmpSxM9pm/R.INSTALL18679149efe5f/rxode2/src/RcppExports.cpp:973