Hello. I am tying to create a code in order to simulate the arrivals, service time and waiting time of vessels (deep-sea and inland barges). I use the following code but the activity times turn out to be wrong therefore affecting the waiting times. For the rgamma inputs I used (number of arrivals, shape, scale) for the add_generator function whereas for the timeout function it only lets me put 1 as the first input in rgamma or else I get the message "Expecting a single value". Perhaps this is my issue?
My code:
set.seed(1269)
terminal <- simmer("terminal")
deepsea <-
trajectory("Deep sea path") %>%
log_("Here I am") %>%
set_attribute("start_time", function() {now(terminal)}) %>%
seize("berth") %>%
timeout(function() {rgamma(1,2.53,0.4)}) %>%
log_(function() {paste("Waited: ", now(terminal) - get_attribute(terminal, "start_time"))}) %>%
release("berth") %>%
log_(function() {paste("Finished: ", now(terminal))})
barge <-
trajectory("Barge path") %>%
log_("Here I am") %>%
set_attribute("start_time", function() {now(terminal)}) %>%
seize("berth") %>%
log_(function() {paste("Waited: ", now(terminal) - get_attribute(terminal, "start_time"))}) %>%
timeout(function() {rgamma(1, 1.24,0.09)}) %>%
release("berth") %>%
log_(function() {paste("Finished: ", now(terminal))})
terminal <-
simmer("terminal") %>%
add_resource("berth",8) %>%
add_generator("Deep sea vessel", deepsea, function() {c(0, rgamma(79, 1.47,0.23))}) %>%
add_generator("Barge", barge, function() {c(0, rgamma(609,1.14,0.04))}) %>%
run(until = 500)
terminal %>%
get_mon_arrivals() %>%
transform(waiting_time = end_time - start_time - activity_time)