TransWikia.com

R simmer - Discrete Event Simulation - Resources available depending on attribute

Stack Overflow Asked by Dries on December 19, 2020

Let’s say I have a store where I sell apples and oranges. In the store I have 4 jars that can contain 10 pieces of fruit. I want an empty jar to be available to every kind of fruit, but a partially filled jar only to pieces of the same fruit. Is that possible in simmer?

So when a piece of fruit arrives:

  • first check if there is a partially filled jar containing the same fruit, if yes, select that one
  • otherwise select an empty jar

The following pseudo-code may provide a better overview:

apples <- trajectory("apple")%>%
   set_attribute("fruit", 1)%>%
   select( function() this is the difficult part - I hope the fruit attribute can be used)%>%
   seize_selected(1)%>%
   timeout(function()rexp(1,10))%>%
   release_selected(1)

oranges <- trajectory("orange")%>%
   set_attribute("fruit", 2)%>%
   select( function() this is the difficult part)%>%
   seize_selected(1)%>%
   timeout(function()rexp(1,10))%>%
   release_selected(1)

env <- simmer("mystore")%>%
     add_resource("jar1", 10) %>%
     add_resource("jar2", 10) %>%
     add_resource("jar3", 10) %>%
     add_resource("jar4", 10) %>%
     add_generator("apple", apples, function() rnorm(1, 10, 2))%>%
     add_generator("orange", oranges, function() rnorm(1, 10, 2))

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP