Hi Lindsay,
The whole point behind the concept of trajectory is being a common path for arrivals of the same type. If you have two types of arrivals, cats and dogs, the natural way to model this problem with simmer is having two distinct trajectories, because they do different things even though they share some activities. In terms of your example,
t.cat <- create_trajectory("cat") %>%
seize("receptionist", 1) %>% #Both dogs and cats go to the receptionist
timeout(function() max(0,rnorm(1,5,2))) %>%
release("receptionist", 1) %>%
seize("catDoc", 1) %>%
timeout(function() max(0,rnorm(1,30,10))) %>%
release("catDoc", 1)
t.dog <- create_trajectory("dog") %>%
seize("receptionist", 1) %>% #Both dogs and cats go to the receptionist
timeout(function() max(0,rnorm(1,5,2))) %>%
release("receptionist", 1) %>%
seize("dogDoc", 1) %>%
timeout(function() max(0,rnorm(1,30,10))) %>%
release("dogDoc", 1)
env <- simmer("Lab6") %>%
add_resource("receptionist", 1) %>%
add_resource("catDoc", 1) %>%
add_resource("dogDoc", 1) %>%
add_generator("cat", t.cat, function() rexp(1,rate = (1/45)), mon = 2) %>%
add_generator("dog", t.dog, function() rexp(1,rate = (1/30)), mon = 2) %>%
run(until=720) #720 = 12 hours * 60 min
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...@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/CAC3jZor8OoXV9BOkOM-p%2Bg_uPLqU_5twqj4M9Snm9pRDM-RWVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
I think the previous email answered the question. But, as a side discussion, certainly it would be nice not to have to repeat the common activities in each trajectory. So I’ll examine the possibility of adding trajectories, of trajectory concatenation, as a future feature. This way, we could define
t.common <- create_trajectory("common") %>%
seize("receptionist", 1) %>% #Both dogs and cats go to the receptionist
timeout(function() max(0,rnorm(1,5,2))) %>%
release("receptionist", 1)
t.cat <- create_trajectory("cat") %>%
seize("catDoc", 1) %>%
timeout(function() max(0,rnorm(1,30,10))) %>%
release("catDoc", 1)
t.dog <- create_trajectory("dog") %>%
seize("dogDoc", 1) %>%
timeout(function() max(0,rnorm(1,30,10))) %>%
release("dogDoc", 1)
And then, we could simply concatenate them (tentative syntax follows):
env %>%
add_generator("cat", t.common + t.cat, function() rexp(1,rate = (1/45)), mon = 2) %>%
add_generator("dog", t.common + t.dog, function() rexp(1,rate = (1/30)), mon = 2)
Opinions welcome!
Regards,
Iñaki
That definitely makes sense - I had considered that as an option but wanted to be sure there was not a more succinct solution.
Thank you much! Your quick and thorough responses are super helpful and appreciated.
Cheers
L
To view this discussion on the web visit https://groups.google.com/d/msgid/simmer-devel/CALEXWq29Uo8fGMUyCegOeJjtvkQvTNCOGoOwGPKUdziBqgy_rg%40mail.gmail.com.
t.common <- create_trajectory("common") %>%
seize("receptionist", 1) %>% #Both dogs and cats go to the receptionist
timeout(function() max(0,rnorm(1,5,2))) %>%
release("receptionist", 1)
t.cat <- create_trajectory("cat") %>%
include(t.common) %>%
seize("catDoc", 1) %>%
timeout(function() max(0,rnorm(1,30,10))) %>%
release("catDoc", 1)
t.dog <- create_trajectory("dog") %>%
include(t.common) %>%
seize("dogDoc", 1) %>%
timeout(function() max(0,rnorm(1,30,10))) %>%
release("dogDoc", 1)
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/CAC3jZor8OoXV9BOkOM-p%2Bg_uPLqU_5twqj4M9Snm9pRDM-RWVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
I like your proposal for two reasons:
So I vote for it. Do you think it would be preferable include(t.common) instead of concatenate(t.common)? Other? I’m just brainstorming. I have no favorite.
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/CAC3jZor8OoXV9BOkOM-p%2Bg_uPLqU_5twqj4M9Snm9pRDM-RWVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
--
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/30d379f6-901b-47cb-b7e9-eae40cc81090%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simmer-devel/CALEXWq05FJQJ5KyeU3zEGJLPDsOij85b50zepc-BPBex%2BNwYnQ%40mail.gmail.com.
Of course, it depends on the simulation. But from the performance point of view, it is always better to define multiple trajectories and multiple generators. You can create them in a very easy way, with very few lines of code, using lapply, and the performance gains are huge (see this example).
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/b3fb5a39-2371-4514-9a3b-8bdaab155f18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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/651fc01f-3bfc-4b5e-8526-aa25b17add53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.