-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
set_source does not deactivate the old source #322
Comments
Thanks for the report. Please do not open several issues/discussions for the same thing in the future. I've closed the two other discussions in favour of this issue. Now, here's a simpler reproducible example: library(simmer)
set.seed(123)
sim <- simmer(" Simulation")
traj1 <- trajectory("traj1") %>%
timeout(function() 100)
traj2 <- trajectory("traj2") %>%
deactivate("Gen")
# set_source("Gen", function() -10)
env <- sim %>%
add_generator("Gen", traj1, from(0, function() 1)) %>%
add_generator("Stopper", traj2, at(1.5), mon=2) %>%
run(600)
arrivals <- get_mon_arrivals(env)
arrivals[order(arrivals$start_time), ]
#> name start_time end_time activity_time finished replication
#> 2 Gen0 0.0 100.0 100 TRUE 1
#> 3 Gen1 1.0 101.0 100 TRUE 1
#> 1 Stopper0 1.5 1.5 0 TRUE 1 vs. library(simmer)
set.seed(123)
sim <- simmer(" Simulation")
traj1 <- trajectory("traj1") %>%
timeout(function() 100)
traj2 <- trajectory("traj2") %>%
# deactivate("Gen")
set_source("Gen", function() -10)
env <- sim %>%
add_generator("Gen", traj1, from(0, function() 1)) %>%
add_generator("Stopper", traj2, at(1.5), mon=2) %>%
run(600)
arrivals <- get_mon_arrivals(env)
arrivals[order(arrivals$start_time), ]
#> name start_time end_time activity_time finished replication
#> 2 Gen0 0.0 100.0 100 TRUE 1
#> 3 Gen1 1.0 101.0 100 TRUE 1
#> 1 Stopper0 1.5 1.5 0 TRUE 1
#> 4 Gen2 2.0 102.0 100 TRUE 1 The main difference is that |
Thank you for looking into this and your work on this great package What about the second issue that when the generator is stopped using set_source(), it remains permanently stopped in next runs despite the simulation being resetted, whereas when stopped with deactivate() it is re-started at each run of the simulation ? |
|
I am learning and experimenting with Simmer.
In the following code, an entity in traj2 will deactivate at t= 75 a generator for traj1 (Gen1).
This deactivation can be made using deactivate("Gen1") or set_source("Gen1", function() -1).
I run the simulation two times until t = 300.
With deactivate("Gen1") it works fine : Gen1 stops producing entities at t = 75 and both runs show similar behaviours.
There are two issues when using set_source("Gen1", function() -1) :
Are these issues bugs or am I missing something ?
Thanks
The text was updated successfully, but these errors were encountered: