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

Batching at the second node #168

Open
lec00q opened this issue Feb 4, 2020 · 2 comments
Open

Batching at the second node #168

lec00q opened this issue Feb 4, 2020 · 2 comments

Comments

@lec00q
Copy link

lec00q commented Feb 4, 2020

When creating a network with two nodes, and the second node has a batching distribution set to more than one customer, I would expect that the customers arrive in batches (at the same time) at the second node, but this seems not the case.

That is, if I create a network like this:

N = ciw.create_network(
    arrival_distributions=[ciw.dists.Deterministic(1), ciw.dists.NoArrivals()],
    service_distributions=[ciw.dists.Deterministic(1), ciw.dists.Deterministic(2)],
    batching_distributions=[ciw.dists.Deterministic(1), ciw.dists.Deterministic(3)],
    routing=[[0.0, 1.0],
             [0.0, 0.0]],
    number_of_servers=[1, 1]
)

I would expect that:

  • they get served at the first node one at a time
  • after 3 customers are served, they all arrive at the same time at the second node (at time 4)
  • then they get served by the second node one at a time

In reality I observe the following:

ciw.seed(1)
Q = ciw.Simulation(N)
Q.simulate_until_max_time(10)

recs = Q.get_all_records()
df = pd.DataFrame(recs)
df

Screenshot 2020-02-04 at 15 17 06

It this the expected behaviour?
If so, I can I simulate the behaviour I want?

Many thanks

@geraintpalmer
Copy link
Member

Dear @lec00q

You are correct, and this is the expected behaviour. In Ciw, "batching" only applies to external arrivals. Arrivals from another node are not batched.

I am note sure immediately how to model the behaviour you want. It may be possible to use Ciw's custom node feature: https://ciw.readthedocs.io/en/latest/Guides/behaviour.html to overwrite the node's release methods (line 394 in https://github.com/CiwPython/Ciw/blob/master/ciw/node.py), so that if there are less than three individuals reasy to be released it passes, but once there are 3 individuals waiting to be released then all three are released simultaneously.

I hope that helps somewhat.

@lec00q
Copy link
Author

lec00q commented May 5, 2020

Dear @geraintpalmer,

thank you for your suggestion and sorry for the delayed answer. I have managed to obtain the behaviour described by inheriting from the custom node, as you said.

However, it came out a bit complicated and I had to modify quite a lot of methods: begin_service_if_possible_change_shift, begin_service_if_possible_accept, begin_service_if_possible_release, detatch_server. Not sure if I have made something wrong and if it could have been easier (probably!) but if you need some hints on how I did let me know. I think that for many real cases this can be a very nice add-on functionality.

Thanks!

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

No branches or pull requests

2 participants