Skip to content

Conversation

@steveant
Copy link

Summary

  • Complete Python 3.12+ port of C++SIM using SimPy as the underlying simulation engine
  • Preserves C++SIM API while adapting to Python idioms (generator-based coroutines instead of OS threads)
  • PRNG produces identical sequences to C++SIM with same seeds
  • 77 validation tests pass against C++ expected_output files

What's Included

Core Classes:

  • Process, Scheduler, Entity, Semaphore, TriggerQueue
  • SimSet linked lists (Head, Link, Linkage)

Random Streams:

  • Uniform, Exponential, Normal, Erlang, HyperExponential, Triangular, Draw

Statistics:

  • Mean, Variance, Histogram, PrecisionHistogram, SimpleHistogram, Quantile

Documentation:

  • Comprehensive README with API reference and migration guide
  • CHANGELOG documenting the port
  • Three runnable examples (producer_consumer, machine_shop, stats_demo)
  • Type hints throughout with py.typed marker

Test Plan

  • All 77 validation tests pass (uv run pytest tests/ -v)
  • All three examples run successfully
  • Package installs cleanly (uv pip install -e .)
  • Import verification: python -c "from pysim import Process, Scheduler; print('OK')"

PySim is a Python port of the C++SIM discrete event simulation library,
using SimPy as the underlying simulation engine.

Features:
- Process-based simulation with SIMULA-style API
- Entity/Semaphore/TriggerQueue for non-causal event handling
- SimSet linked lists (Head, Link, Linkage)
- Random streams: Uniform, Exponential, Normal, Erlang, etc.
- Statistics: Mean, Variance, Histogram, Quantile
- 77 validation tests against C++ expected_output files
- PRNG produces identical sequences to C++SIM

Examples included:
- producer_consumer.py: Bounded buffer with semaphores
- machine_shop.py: Job processing with optional failures
- stats_demo.py: Statistics classes demonstration
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

Successfully merging this pull request may close these issues.

1 participant