Skip to content

Using salabim without global variables #13

@jonglezb

Description

@jonglezb

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.enter(...)

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

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions