r-simmer / simmer

Discrete-Event Simulation for R
https://r-simmer.org
GNU General Public License v2.0
222 stars 42 forks source link

Renege-timer error "not previously seized" #268

Closed thigger closed 3 years ago

thigger commented 3 years ago

simmer 4.4.3 on R 4.04 on Windows 64-bit

As mentioned on the list - I've now managed to create a reproducible example (from the bank) which is attached

   39.0866 |      task: Renege-Timer     |          :                  | 
   39.0866 |  resource: BRI pen          |   arrival: Customer13       | DEPART
   39.0866 |  resource: BRI counter      |   arrival: Customer13       | DEPART
   39.0866 |  resource: BRI counter      |   arrival: Customer13       | DEPART
Error: 'Renege-Timer' at 39.09:
 'BRI counter' not previously seized

Like my hospital example, this can be fixed by switching the order of the seize of "counter" and "notepad". I assume it has something to do with the fact we're seizing two counters on occasion.

crashattempt.R.txt

Enchufa2 commented 3 years ago

From the highlighted trace, it looks like an incorrect double dispatch of the departure routine on the counter resource. The second departure should be on the notepad resource instead. This is very useful, thanks, will investigate.

Enchufa2 commented 3 years ago

Shorter MCVE:

library(simmer)

t <- trajectory() %>%
  renege_in(5) %>%
  seize("res1") %>%
  seize("res2") %>%
  seize("res3") %>%
  wait()

simmer(verbose=TRUE) %>%
  add_resource(paste0("res", 1:3)) %>%
  add_generator("dummy", t, at(0)) %>%
  run()
#>          0 |    source: dummy            |       new: dummy0           | 0
#>          0 |   arrival: dummy0           |  activity: RenegeIn         | 5, 0, 0 paths
#>          0 |   arrival: dummy0           |  activity: Seize            | res1, 1, 0 paths
#>          0 |  resource: res1             |   arrival: dummy0           | SERVE
#>          0 |   arrival: dummy0           |  activity: Seize            | res2, 1, 0 paths
#>          0 |  resource: res2             |   arrival: dummy0           | SERVE
#>          0 |   arrival: dummy0           |  activity: Seize            | res3, 1, 0 paths
#>          0 |  resource: res3             |   arrival: dummy0           | SERVE
#>          0 |   arrival: dummy0           |  activity: Wait             | 
#>          5 |      task: Renege-Timer     |          :                  | 
#>          5 |  resource: res1             |   arrival: dummy0           | DEPART
#>          5 |  resource: res3             |   arrival: dummy0           | DEPART
#>          5 |  resource: res3             |   arrival: dummy0           | DEPART
#> Error: 'Renege-Timer' at 5.00:
#>  'res3' not previously seized
Enchufa2 commented 3 years ago

This was a subtle one. Please, try the current master branch.

thigger commented 3 years ago

Brilliant, all fixed! Thanks.