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 · 1 comment

Using salabim without global variables #13

jonglezb opened this issue Jan 28, 2019 · 1 comment


Copy link

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?

Copy link

salabim commented Aug 12, 2019

Just attach these variables to env, like env.queue ...

@salabim salabim closed this as completed Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants