Skip to content

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

Closed

Description

@mmarks13

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)

Activity

  1. Enchufa2 commented on May 10, 2017

    @Enchufa2
    Member

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

  2. mmarks13 commented on May 10, 2017

    @mmarks13
    Author

    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
    
  3. Enchufa2 commented on May 10, 2017

    @Enchufa2
    Member

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

  4. mmarks13 commented on May 10, 2017

    @mmarks13
    Author

    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
    
  5. Enchufa2 commented on May 10, 2017

    @Enchufa2
    Member

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

  6. mmarks13 commented on May 10, 2017

    @mmarks13
    Author

    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
    
  7. Enchufa2 commented on May 10, 2017

    @Enchufa2
    Member

    Force the reinstallation and try again, please.

  8. mmarks13 commented on May 10, 2017

    @mmarks13
    Author
    > 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
    
  9. Enchufa2 commented on May 10, 2017

    @Enchufa2
    Member

    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.

  10. mmarks13 commented on May 10, 2017

    @mmarks13
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions