New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error for NaN value in timout() function #97

Closed
mmarks13 opened this Issue May 9, 2017 · 10 comments

Comments

Projects
None yet
2 participants
@mmarks13

mmarks13 commented May 9, 2017

I ran into an issue with some code similar to below. The underlying issue was that one of my timeout functions was returning a NaN value. Unfortunately, no error was thrown and it took me about 3 hours to track down the root cause. Not sure if this is something you're interested in doing in the future, but I figured I'd log it.

    library(triangle)
    
    Material1 <- trajectory("Material1") %>%
      seize("Resource1") %>%  
      timeout(function() rtriangle(1,10,15,25))%>% 
      release("Resource1")
    
  
      env <- simmer("test_sim")
      env %>%
        add_resource("Resource1", 1) %>%
        add_generator("Case", Material1,at(seq(1,5)), mon = 2) %>%
        run(500)
      
      get_mon_arrivals(env)

@Enchufa2 Enchufa2 added the duplicate label May 10, 2017

@Enchufa2

This comment has been minimized.

Member

Enchufa2 commented May 10, 2017

This was solved in #96. ;-) Sorry for the lost time, and thanks for the report.

@Enchufa2 Enchufa2 closed this May 10, 2017

@mmarks13

This comment has been minimized.

mmarks13 commented May 10, 2017

Wow. You're one step ahead of me. Haha.

So I reinstalled the master from GitHub, and I'm getting the same issue.

Confirm I have the latest install

> install_github("r-simmer/simmer")
Skipping install of 'simmer' from a github remote, the SHA1 (e7570058) has not changed since last install.
  Use `force = TRUE` to force installation

re-run code

> env <- simmer("test_sim")
> env %>%
+   add_resource("Resource1", 1) %>%
+   add_generator("Case", Material1,at(seq(1,3)), mon = 2) %>%
+   run(500)
simmer environment: test_sim | now: NaN | next: 
{ Resource: Resource1 | monitored: 1 | server status: 0(1) | queue status: 0(Inf) }
{ Generator: Case | monitored: 2 | n_generated: 3 }
> 
> get_mon_arrivals(env)
   name start_time end_time activity_time finished replication
1 Case0          1      NaN           NaN     TRUE           1
2 Case1          2      NaN           NaN     TRUE           1
3 Case2          3      NaN           NaN     TRUE           1
@Enchufa2

This comment has been minimized.

Member

Enchufa2 commented May 10, 2017

You are right: it is detecting NAs but not NaNs. Thanks for checking!

@Enchufa2 Enchufa2 reopened this May 10, 2017

@Enchufa2 Enchufa2 added the bug label May 10, 2017

@mmarks13

This comment has been minimized.

mmarks13 commented May 10, 2017

I thought that would be the case, but I'm getting the same thing for NAs as well.

library(simmer)
Material1 <- trajectory("Material1") %>%
  seize("Resource1") %>%  
  timeout(NA)%>% 
  release("Resource1")

env <- simmer("test_sim")
env %>%
  add_resource("Resource1", 1) %>%
  add_generator("Case", Material1,at(seq(1,3)), mon = 2) %>%
  run(500) 
> get_mon_arrivals(env)
   name start_time end_time activity_time finished replication
1 Case0          1       NA            NA     TRUE           1
2 Case1          2       NA            NA     TRUE           1
3 Case2          3       NA            NA     TRUE           1

@Enchufa2 Enchufa2 closed this in dedde07 May 10, 2017

@Enchufa2

This comment has been minimized.

Member

Enchufa2 commented May 10, 2017

Apparently, the R/C API for checking NAs and NaNs has some peculiarities... It should be solved now.

@mmarks13

This comment has been minimized.

mmarks13 commented May 10, 2017

Hmm. I reinstalled from github and am getting the same issues.

> install_github("r-simmer/simmer")
Skipping install of 'simmer' from a github remote, the SHA1 (dedde075) has not changed since last install.

for NaNs

> library(simmer)
> Material1 <- trajectory("Material1") %>%
+   seize("Resource1") %>%  
+   timeout(NaN)%>% 
+   release("Resource1")
> 
> env <- simmer("test_sim")
> env %>%
+   add_resource("Resource1", 1) %>%
+   add_generator("Case", Material1,at(seq(1,3)), mon = 2) %>%
+   run(500)
simmer environment: test_sim | now: NaN | next: 
{ Resource: Resource1 | monitored: 1 | server status: 0(1) | queue status: 0(Inf) }
{ Generator: Case | monitored: 2 | n_generated: 3 }
> 
> get_mon_arrivals(env)
   name start_time end_time activity_time finished replication
1 Case0          1      NaN           NaN     TRUE           1
2 Case1          2      NaN           NaN     TRUE           1
3 Case2          3      NaN           NaN     TRUE           1

and NAs

> library(simmer)
> Material1 <- trajectory("Material1") %>%
+   seize("Resource1") %>%  
+   timeout(NA)%>% 
+   release("Resource1")
> 
> env <- simmer("test_sim")
> env %>%
+   add_resource("Resource1", 1) %>%
+   add_generator("Case", Material1,at(seq(1,3)), mon = 2) %>%
+   run(500)
simmer environment: test_sim | now: NA | next: 
{ Resource: Resource1 | monitored: 1 | server status: 0(1) | queue status: 0(Inf) }
{ Generator: Case | monitored: 2 | n_generated: 3 }
> 
> get_mon_arrivals(env)
   name start_time end_time activity_time finished replication
1 Case0          1       NA            NA     TRUE           1
2 Case1          2       NA            NA     TRUE           1
3 Case2          3       NA            NA     TRUE           1
@Enchufa2

This comment has been minimized.

Member

Enchufa2 commented May 10, 2017

Force the reinstallation and try again, please.

@mmarks13

This comment has been minimized.

mmarks13 commented May 10, 2017

> install_github("r-simmer/simmer",force= TRUE)
Downloading GitHub repo r-simmer/simmer@master
from URL https://api.github.com/repos/r-simmer/simmer/zipball/master
Installing simmer
"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL "C:/Users/marks/AppData/Local/Temp/RtmpofY669/devtools72fc6ae239df/r-simmer-simmer-dedde07"  \
  --library="C:/Users/marks/Documents/R/win-library/3.3" --install-tests 

* installing *source* package 'simmer' ...
** libs

*** arch - i386
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o
c:/Rtools/mingw_32/bin/gcc  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O3 -Wall  -std=gnu99 -mtune=core2 -c init.c -o init.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c policy.cpp -o policy.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c process.cpp -o process.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c resource.cpp -o resource.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c simmer_rcpp.cpp -o simmer_rcpp.o
c:/Rtools/mingw_32/bin/g++ -shared -s -static-libgcc -o simmer.dll tmp.def RcppExports.o init.o policy.o process.o resource.o simmer_rcpp.o -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.1/bin/i386 -lR
installing to C:/Users/marks/Documents/R/win-library/3.3/simmer/libs/i386

*** arch - x64
c:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o
c:/Rtools/mingw_64/bin/gcc  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c init.c -o init.o
c:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c policy.cpp -o policy.o
c:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c process.cpp -o process.o
c:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c resource.cpp -o resource.o
c:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -DBOOST_NO_LONG_LONG   -I"C:/Users/marks/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/marks/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c simmer_rcpp.cpp -o simmer_rcpp.o
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o simmer.dll tmp.def RcppExports.o init.o policy.o process.o resource.o simmer_rcpp.o -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.1/bin/x64 -lR
installing to C:/Users/marks/Documents/R/win-library/3.3/simmer/libs/x64
Warning in file.copy(files, dest, overwrite = TRUE) :
  problem copying .\simmer.dll to C:\Users\marks\Documents\R\win-library\3.3\simmer\libs\x64\simmer.dll: Permission denied
** R
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
*** arch - x64
* DONE (simmer)
Reloading installed simmer

Attaching package: ‘simmer’

The following object is masked from ‘package:devtools’:

    release

Warning message:
GitHub repo contains submodules, may not function as expected! 
> library(simmer)
> Material1 <- trajectory("Material1") %>%
+   seize("Resource1") %>%  
+   timeout(NA)%>% 
+   release("Resource1")
> 
> env <- simmer("test_sim")
> env %>%
+   add_resource("Resource1", 1) %>%
+   add_generator("Case", Material1,at(seq(1,3)), mon = 2) %>%
+   run(500)
simmer environment: test_sim | now: NA | next: 
{ Resource: Resource1 | monitored: 1 | server status: 0(1) | queue status: 0(Inf) }
{ Generator: Case | monitored: 2 | n_generated: 3 }
> 
> get_mon_arrivals(env)
   name start_time end_time activity_time finished replication
1 Case0          1       NA            NA     TRUE           1
2 Case1          2       NA            NA     TRUE           1
3 Case2          3       NA            NA     TRUE           1
> library(simmer)
> Material1 <- trajectory("Material1") %>%
+   seize("Resource1") %>%  
+   timeout(NaN)%>% 
+   release("Resource1")
> 
> env <- simmer("test_sim")
> env %>%
+   add_resource("Resource1", 1) %>%
+   add_generator("Case", Material1,at(seq(1,3)), mon = 2) %>%
+   run(500)
simmer environment: test_sim | now: NaN | next: 
{ Resource: Resource1 | monitored: 1 | server status: 0(1) | queue status: 0(Inf) }
{ Generator: Case | monitored: 2 | n_generated: 3 }
> 
> get_mon_arrivals(env)
   name start_time end_time activity_time finished replication
1 Case0          1      NaN           NaN     TRUE           1
2 Case1          2      NaN           NaN     TRUE           1
3 Case2          3      NaN           NaN     TRUE           1
@Enchufa2

This comment has been minimized.

Member

Enchufa2 commented May 10, 2017

Check this, in your log:

Warning in file.copy(files, dest, overwrite = TRUE) :
  problem copying .\simmer.dll to C:\Users\marks\Documents\R\win-library\3.3\simmer\libs\x64\simmer.dll: Permission denied

It is not being properly installed. I would say that you are still running an old version of simmer.

@mmarks13

This comment has been minimized.

mmarks13 commented May 10, 2017

I would say that you were correct! Fixed that issue and we are good to go. Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment