Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transfer/share resources and attributes between clones #207

Open
Enchufa2 opened this issue Aug 2, 2019 · 3 comments
Open

Transfer/share resources and attributes between clones #207

Enchufa2 opened this issue Aug 2, 2019 · 3 comments

Comments

@Enchufa2
Copy link
Member

Enchufa2 commented Aug 2, 2019

Currently, each cloned arrival is a separate entity that is reponsible for its own seized resources and attributes (which, e.g., makes parallel tasks a bit tricky). Some mechanism to transfer or share this responsibility may be interesting.

@thigger
Copy link

thigger commented Aug 2, 2019

Hehe, sorry - ignore my comment in #206 - great minds think alike!

@Enchufa2
Copy link
Member Author

It might also be interesting to set some kind of clone index.

@Enchufa2
Copy link
Member Author

Enchufa2 commented Oct 16, 2024

@thigger The following may be of interest to you. Discussing a similar issue, I've come up with an alternative, more general way of dealing with this kind of situation:

library(simmer)

t <- trajectory() %>%
  seize("room") %>%
  clone(
    n = 3,
    trajectory("controller") %>%
      trap("clone end"),
    trajectory("doctor") %>%
      timeout(1) %>%
      send("clone end"),
    trajectory("nurse") %>%
      timeout(2) %>%
      send("clone end")) %>%
  synchronize(wait = FALSE) %>%
  wait() %>%
  wait() %>%
  timeout(0.5) %>%
  release("room")

simmer() %>%
  add_resource("room") %>%
  add_generator("visit", t, at(0)) %>%
  run()

Particularly, in the case I was discussing, two units were seized at the beginning (one per clone), and then they were released one by one after each wait(). So I think this approach is quite flexible. I may even change the implementation of simmer.bricks::do_parallel to this simpler one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants