In my simulation, certain resources are on a capacity schedule, which alternates between 0 and 1 based on the time of day. If a resource cannot complete its task by the time its capacity goes to zero, the arrival should be dropped, wait a short period, and rollback to try to select an available resource. If no resource is available, the arrival goes through a timeout --> rollback loop until a resource becomes available.
The relevant code is as follows:
# Use a reject trajectory used to go back and select a new resource if the
# current resource runs out of time (i.e., its shift ends)
... |>
simmer::seize_selected(
continue = TRUE,
reject = simmer::trajectory('dropped') |>
simmer::timeout(\() runif(1, min = 0.07, max = 0.1)) |>
simmer::rollback(target = 'select_resource')
) |>
# Clear the queue of the selected resource when its capacity is zero
simmer::renege_if(
signal = 'clear_queue'
) |>
simmer::send(
signals = \() {
cap <- simmer::get_capacity_selected(env)
res_name <- simmer::get_selected(env)
now <- simmer::now(env)
queue_count <- simmer::get_queue_count_selected(env)
if (res_name == 'Operator_Bill' & now > 41 & queue_count > 0) {
browser()
}
if (cap == 0) {
'clear_queue'
} else {
''
}
}
) |> ...
The debug condition is never triggered for some reason, but on inspecting mon_resources it shows that arrivals are being served/in queue when capacity == 0. What would be the correct code to handle this situation?