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?