Preemptive priority with resume vs restart

Hello! As you can see below I am trying to run the same code which includes preemptive priority (of the vessels) in the first case I decide to run it with resume and then with restart. However, the results of these codes turns out to be the same which is not correct although I set restart=False and restart=true accordingly.

RESTART CASE:

library(simmer)

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,shape=2.53,scale=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, shape=1.24,scale=0.09)}) %>%
release("berth") %>%
log_(function() {paste("Finished: ", now(terminal))})

terminal <-
simmer("terminal") %>%
add_resource("berth",8,preemptive=TRUE) %>%
add_generator("Deep sea vessel", deepsea, function() {c(0, rgamma(79, shape=1.47,scale=0.23))},priority=1,restart=TRUE) %>%
add_generator("Barge", barge, function() {c(0, rgamma(609,shape=1.14,scale=0.04))}) %>%
run(until = 500)

terminal %>%
get_mon_arrivals() %>%
transform(waiting_time = end_time - start_time - activity_time)

RESUME CASE

library(simmer)

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,shape=2.53,scale=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, shape=1.24,scale=0.09)}) %>%
release("berth") %>%
log_(function() {paste("Finished: ", now(terminal))})

terminal <-
simmer("terminal") %>%
add_resource("berth",8,preemptive=TRUE) %>%
add_generator("Deep sea vessel", deepsea, function() {c(0, rgamma(79, shape=1.47,scale=0.23))},priority=1,restart=FALSE) %>%
add_generator("Barge", barge, function() {c(0, rgamma(609,shape=1.14,scale=0.04))}) %>%
run(until = 500)

terminal %>%
get_mon_arrivals() %>%
transform(waiting_time = end_time - start_time - activity_time)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.