Setting infinite queue size on a schedule

7 views
Skip to first unread message

Philemon Cyclone

unread,
May 4, 2023, 11:51:24 AM5/4/23
to simmer-devel
For my simulation I am setting the queue size for certain resources to change based on a schedule: when the resource is on shift, the queue size should be infinite; when the resource is off, the queue size should be zero. 

However, during the simulation the actual queue size when on shift is 1 instead of Inf. If I change the queue size to a positive integer, the actual queue size equals that positive integer, so the problem only occurs when Inf is used in a vector (see bold lines below).

I have this set up as follows:

for (i in 1:nrow(res_df)) {
    # Get shift in 24-hour period
    start <- res_df[[i, 'ShiftStart']]
    end <- res_df[[i, 'ShiftEnd']]

    # Get resource name
    res_name <- res_df[[i, 'EquipmentNbr']]

    # Shelves have infinite capacity, otherwise capacity = 1
    if (res_name == 'Shelf') {
      capacity_sched <- Inf
    } else {
      capacity_sched <- 1
    }

    # Queue size is infinite except for operators when they go off shift
    # (handled below)
    queue_sched <- Inf  # This works - the queue size in the sim is infinite

    # If shift is finite, set the schedule
    if (!is.infinite(end)) {
      t1 <- start
      t2 <- end
      cap_values <- c(1, 0)
      queue_values <- c(Inf, 0) # Inf is converted to 1 in the sim

      # If shift ends before it starts (in terms of 24-hour clock time),
      # we need to reverse order for compatibility with simmer::schedule()
      if (end < start) {
        t1 <- end
        t2 <- start
        cap_values <- c(0, 1)
        queue_values <- c(0, Inf)  # Inf is converted to 1 in the sim
      }

      capacity_sched <- simmer::schedule(
        timetable = c(t1, t2),
        values = cap_values,
        period = 24
        )

      queue_sched <- simmer::schedule(
        timetable = c(t1, t2),
        values = queue_values,
        period = 24
      )
    }

    # Add the resource
    env |>
      simmer::add_resource(
        name = res_name,
        capacity = capacity_sched,
        queue_size = queue_sched,
        queue_size_strict = TRUE,
        preemptive = TRUE,
        preempt_order = 'fifo'
        )
  }

Is there a specific way that Inf needs to be specified when using it in a vector?

Thanks!

Iñaki Ucar

unread,
May 4, 2023, 12:10:52 PM5/4/23
to simmer...@googlegroups.com
Do you have a specific (short) reproducible example where we can see that the size is not being set to infinity? Here it works nicely:

library(simmer)

simmer() %>%
  add_resource("res", 0, queue_size=schedule(c(0, 1), c(0, Inf), period=24)) %>%
  add_generator("dummy", trajectory() %>% seize("res"), at(0:5)) %>%
  run(100) %>%
  get_mon_resources()
#>    resource time server queue capacity queue_size system limit replication
#> 1       res    1      0     0        0        Inf      0   Inf           1
#> 2       res    1      0     1        0        Inf      1   Inf           1
#> 3       res    2      0     2        0        Inf      2   Inf           1
#> 4       res    3      0     3        0        Inf      3   Inf           1
#> 5       res    4      0     4        0        Inf      4   Inf           1
#> 6       res    5      0     5        0        Inf      5   Inf           1
#> 7       res   24      0     5        0          0      5     0           1
#> 8       res   25      0     5        0        Inf      5   Inf           1
#> 9       res   48      0     5        0          0      5     0           1
#> 10      res   49      0     5        0        Inf      5   Inf           1
#> 11      res   72      0     5        0          0      5     0           1
#> 12      res   73      0     5        0        Inf      5   Inf           1
#> 13      res   96      0     5        0          0      5     0           1
#> 14      res   97      0     5        0        Inf      5   Inf           1

--
You received this message because you are subscribed to the Google Groups "simmer-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simmer-devel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simmer-devel/7bd077ca-9752-4984-9db1-15b1e59474dbn%40googlegroups.com.


--
Iñaki Úcar

Philemon Cyclone

unread,
May 18, 2023, 9:18:55 PM5/18/23
to simmer-devel
Unfortunately, I have not been able to make a small reprex for this issue. My workaround of setting it to a larger integer (e.g., 999) works well enough, however :)
Reply all
Reply to author
Forward
0 new messages