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

Using salabim without global variables #13

jonglezb opened this Issue Jan 28, 2019 · 0 comments


None yet
1 participant
Copy link

jonglezb commented Jan 28, 2019

First of all, thank you for this very nice package, it is a real pleasure to write simulations with salabim!

I am only wondering how to avoid using global variables for the simulation state (queues, etc).

All examples from the documentation (along with all the examples I looked at in the git repo) use a pattern like the following:

class MyObject(sim.Component):

queue = sim.Queue("myqueue")
obj = MyObject()

That is, important state objects are created in the global context, and they are accessed directly by components.

This prevents two usages:

  • setup and run the simulation in a function, so that I could easily run several simulations in a row with different parameters
  • separate the components and the simulation setup in different source files

What would be the best way to make these state objects available to components? Put everything in a big class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.