-
-
Notifications
You must be signed in to change notification settings - Fork 42
Implement post.seize and reject subtrajectories in seize #49
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
Comments
By virtue of #56, retries can be implemented using |
Linking with #52, there should be a |
Following #57, the |
#69 alleviates seize(traj, resource, amount = 1,
continue = NULL, post.seize = NULL, reject = NULL)
seize_selected(traj, amount = 1, id = 0,
continue = NULL, post.seize = NULL, reject = NULL) so that their default behaviour is the same. But now, we can execute a t <- create_trajectory() %>%
seize("dummy", 1, continue=FALSE,
post.seize = create_trajectory() %>%
timeout(2) %>%
release("dummy", 1)) %>%
timeout(1) # this is not executed in any case, as continue=FALSE
simmer() %>%
add_resource("dummy", 1, 0) %>%
add_generator("arrival", t, at(0, 1)) %>%
run() %>% get_mon_arrivals()
#> name start_time end_time activity_time finished replication
#> 1 arrival1 1 1 0 FALSE 1
#> 2 arrival0 0 2 2 TRUE 1 or a t <- create_trajectory() %>%
seize("dummy", 1, continue=FALSE,
reject = create_trajectory() %>%
timeout(1) %>% # wait
rollback(2, Inf)) %>% # and then retry, until the resource is seized
timeout(2) %>%
release("dummy", 1)
simmer() %>%
add_resource("dummy", 1, 0) %>%
add_generator("arrival", t, at(0, 1)) %>%
run() %>% get_mon_arrivals()
#> name start_time end_time activity_time finished replication
#> 1 arrival0 0 2 2 TRUE 1
#> 2 arrival1 1 4 3 TRUE 1 or we can do both and then continue: t <- create_trajectory() %>%
seize("dummy", 1, continue=c(TRUE, TRUE),
post.seize = create_trajectory() %>%
timeout(2) %>%
release("dummy"),
reject = create_trajectory() %>%
timeout(3)) %>%
timeout(3) # all arrivals, rejected or not, execute this, as continue=c(TRUE, TRUE)
simmer() %>%
add_resource("dummy", 1, 0) %>%
add_generator("arrival", t, at(0, 1)) %>%
run() %>% get_mon_arrivals()
#> name start_time end_time activity_time finished replication
#> 1 arrival0 0 5 5 TRUE 1
#> 2 arrival1 1 7 6 TRUE 1 |
Many models require an arrival to do something if it gets rejected when trying to seize a resource. So we need something in between a
seize
and abranch
: anifseize
activity would work similarly to the R functionifelse
. For instance,Use case: a WiFi station trying to seize the wireless channel to transmit a frame:
@bart6114, review this proposal, please.
The text was updated successfully, but these errors were encountered: