AnswerBun.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!

Related Questions

Issues with manipulating a drop down in Javascript

0  Asked on November 15, 2021 by orgg

   

How to find all the sub matrix of a N*N matrix?

1  Asked on November 15, 2021 by dronzer

     

How to make new person in class player?

2  Asked on November 15, 2021 by joshmann15

   

Accessing elements in Set

0  Asked on November 15, 2021 by lost_and_found

   

WebView onKeyListener not working

3  Asked on November 15, 2021 by federico-ponzi

   

Why is docker not completely deleting my file?

4  Asked on November 15, 2021 by schoon

   

How to update the elastic search document with python?

1  Asked on November 15, 2021 by user6882757

   

Breaking up conditionals in order to reduce DRAM usage

3  Asked on November 15, 2021 by saxpy

       

Ansible Create SubFolders Matching Pattern

1  Asked on November 15, 2021 by switch

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP