Hello,
I am trying to run a Simile model from R on a Windows machine.
mHandle <- load.model("mymodel.dll")
df_objects <- model_objects_as_df(mHandle)
iHandle <- create.model(mHandle)
set.model.step(iHandle, 3, 1)
set.model.step(iHandle, 2, 1)
set.model.step(iHandle, 1, 30)
pfile <- tcl("file", "join", getwd(), "mymodel.spf")
consult.parameter.metafile(iHandle, pfile)
# initialize the model, including default slider values
reset.model(iHandle , -2)
However when I run the last line, I got this error:
Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") : [tcl] can't use non-numeric string as operand of "-".
RStudio:
2022.07.1 Build 554
© 2009-2022 RStudio, PBC
"Spotted Wakerobin" Release (7872775e, 2022-07-22) for Windows
R:
version.string R version 4.2.1 (2022-06-23 ucrt)
nickname Funny-Looking Kid
Simile:
Simile v6.12.12p5 enterprise, 64-bit
Prolog: GNUProlog 1.4.4
TclTl: 8.6.9
MinGW g++: 4.9.0
Best regards
Error in running Simile from R on Windows
Thanks for posting!
Could you get the Tcl procedure stack to give us a clue where this error happened?
tcl("set", "errorInfo")
Thanks for the prompt reply!
Thanks for the prompt reply!
I run the tcl procedure as requested and this is the output:
> tcl("set", "errorInfo")
<Tcl> can't use non-numeric string as operand of "-"
while executing
"expr {$howInt-1}"
(procedure "ResetModel" line 5)
invoked from within
"ResetModel dummy $intMethod $t0 $depth"
(procedure "DoResetModel" line 5)
invoked from within
"DoResetModel q¤³
Fix
Looks like the R package is providing 'Euler' as the default integration method, while Simile is expecting a code of 0 for Euler or 1 for Runge-Kutta.
If you add 0 as a 3rd argument to reset.model(...), that should be passed straight to Simile and avoid this error. You may need to do the same for execute.model(...)
It works
Thank you very much for your support! The solution you proposed did the trick!
All the best!