Resource not dropping arrival when capacity --> 0

7 views
Skip to first unread message

Philemon Cyclone

unread,
Apr 19, 2023, 12:11:06 PM4/19/23
to simmer-devel
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? 


Thank you!

Iñaki Ucar

unread,
Apr 19, 2023, 12:37:02 PM4/19/23
to simmer...@googlegroups.com
On Wed, 19 Apr 2023 at 18:11, Philemon Cyclone <phil.m.f...@gmail.com> wrote:

See my answer there. 

--
Iñaki Úcar
Reply all
Reply to author
Forward
0 new messages