queue with group delay

38 views
Skip to first unread message

Dominique Cirkel

unread,
May 5, 2017, 4:38:18 AM5/5/17
to simmer-devel
Hi!

I am doing a simulation of the patient-path to an outpatient clinic:

Whenever a patient requests to be submitted to the clinic, a letter from a physician with this request will be sent to the clinic. Administrative staff will print out this letter and put it in a certain mailbox. This mailbox is emptied by a doctor in order to perform triage (i.e. determining the priority of patients' treatments based on the severity of their condition). This usually happens once every 1 to 3 days, and takes no more than a couple of hours. After this, the patient is called by the administrative staff and is scheduled for an appointment.

I am pretty new to this package and my problem is the following:

How can I make sure the mailbox is emptied with a timeout=(function() rgamma(1, shape = 2, rate = 0.1)), which should vary every time? 
I feel as if I should use batch() as I've done below, but it obviously doesn't work since batch() only accepts a numeric (10000 could be any number that is big enough to ensure it is only emptied when the doctor arrives).

triage <- trajectory("Patient's path") %>%
  log_
("arrive at queue") %>%
  batch
(10000, timeout=(function() rgamma(1, shape = 2, rate = 0.1))) %>%  
  log_
("triage") %>%
  seize
("triage_doctor", 1) %>%
  timeout(function() rgamma(1, shape = 2, rate = 0.8)) %>%
  release
("triage_doctor", 1) %>%
  separate
() %>%
  seize
("administrative_empl",1) %>%
  log_
("patient is being called") %>%
  timeout
(0.1) %>%
  log_
("Appointment is made") %>%
  release
("administrative_empl", 1)

env
<- simmer()  %>%
  add_resource
("triage_doctor", capacity = 1) %>%
  add_resource
("administrative_empl", capacity = 1) %>%
  add_generator
("person", triage, function() rpois(1, 2)) %>%
  run
(800)

I've also tried the following things:
- Taking the function out of batch(): but that either results in a constant timeout for every batch, or in a constant delay for every patient.
- Using synchronize(): I don't even know what I was thinking while using this.
- Doint something with send(), trap() and wait(): got no clue how though.

Does anyone have an idea how to solve this?

Thanks in advance,

Kind regards,

Dominique


Iñaki Úcar

unread,
May 5, 2017, 5:06:56 AM5/5/17
to simmer-devel

Hi Dominique,

You have a couple of options. Both of them involve the definition of a secondary trajectory for managing the mailbox. Given your description, and assuming that, whenever it is checked, the mailbox is emptied completely, I would use trap-wait-send as follows:

triage <- trajectory("Patient's path") %>%
  log_("arrive at queue"
) %>%
  trap("check mailbox") %>%
  wait() %>%
  log_("triage")
  # etc.

mailbox <- trajectory() %>%
  timeout(function() rgamma(1, shape = 2, rate = 0.1)) %>%
  send("check mailbox") %>%
  rollback(2, Inf)

env <- simmer()  %>%
  add_resource("triage_doctor", capacity = 1) %>%
  add_resource("administrative_empl", capacity = 1) %>%
  add_generator("person", triage, function() rpois(1, 2)) %>%
  add_generator("mailbox", mailbox, at(0)) %>%
  run(800)

If at some point you need a finer-grained control of the number of letters read at a time, then I would define a new resource for the mailbox with capacity=0. Then, the trap-wait would be replaced by a seize-set_capacity(0) of that resource, and the send activity, by a set_capacity(n), where n is the required number of letters.

Regards,
Iñaki


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to simmer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simmer-devel/dc9f7114-432e-4e6d-bcab-f0adf1f7c5ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Dominique Cirkel

unread,
May 5, 2017, 5:33:29 AM5/5/17
to simmer-devel
Thanks for your fast and helpfull response!
This is exactly what I needed.

Kind Regards,

Dominique


Op vrijdag 5 mei 2017 11:06:56 UTC+2 schreef Iñaki Úcar:
To unsubscribe from this group and stop receiving emails from it, send an email to simmer-devel...@googlegroups.com.

To post to this group, send email to simmer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simmer-devel/dc9f7114-432e-4e6d-bcab-f0adf1f7c5ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Iñaki Úcar

unread,
May 5, 2017, 6:05:36 PM5/5/17
to simmer-devel

BTW, I’ve implemented this enhancement. Therefore, with the next release, you’ll be able to do this:

triage <- trajectory("Patient's path") %>%
  log_("arrive at queue"
) %>%
  batch(Inf, timeout=function() rgamma(1, shape = 2, rate = 0.1)) %>%
  separate() %>%
  log_("triage")
  # etc.

env <- simmer()  %>%
  add_generator("person", triage, function() rpois(1, 2)) %>%
  run(25)

Regards,
Iñaki


To unsubscribe from this group and stop receiving emails from it, send an email to simmer-devel+unsubscribe@googlegroups.com.

To post to this group, send email to simmer...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dominique Cirkel

unread,
May 6, 2017, 8:01:44 AM5/6/17
to simmer-devel
That's great! 


Op zaterdag 6 mei 2017 00:05:36 UTC+2 schreef Iñaki Úcar:
Reply all
Reply to author
Forward
0 new messages