Abstract State Machine Framework for Discrete Event Simulation
Project description
SimASM
Abstract State Machine Framework for Discrete Event Simulation
SimASM is a Python package for modeling, simulating, and verifying discrete event systems using Abstract State Machines (ASM) as a common semantic foundation.
Features
- DSL for Simulation Models: Write discrete event simulation models in a clean, readable syntax
- Multiple Formalisms: Support for Event Graph and Activity Cycle Diagram modeling styles
- Stutter Equivalence Verification: Formally verify that two models produce equivalent observable behavior
- Jupyter Integration: Interactive modeling with
%%simasmmagic commands - Statistics Collection: Built-in support for time-average, utilization, and count statistics
Installation
pip install simasm
For Jupyter support:
pip install simasm[jupyter]
Quick Start
In Jupyter/Colab
import simasm # Auto-registers %%simasm magic
Define a model:
%%simasm model --name mm1_queue
domain Event
domain Load
var sim_clocktime: Real
var queue: List<Load>
// ... model definition
Run an experiment:
%%simasm experiment
experiment MyExperiment:
model := "mm1_queue"
replication:
count: 10
warm_up_time: 100.0
run_length: 1000.0
endreplication
statistics:
stat AvgQueueLength: time_average
expression: "lib.length(queue)"
endstat
endstatistics
endexperiment
From Python
from simasm.experimenter.engine import ExperimenterEngine
# Run an experiment
engine = ExperimenterEngine("experiments/my_experiment.simasm")
result = engine.run()
print(f"Average queue length: {result['L_queue']}")
Model Syntax
SimASM uses a domain-specific language for defining simulation models:
// Domain declarations
domain Load
domain Server
// Constants and variables
const server: Server
var sim_clocktime: Real
var queue: List<Load>
// Random stream variables
var interarrival_time: rnd.exponential(1.25) as "arrivals"
var service_time: rnd.exponential(1.0) as "service"
// Rules
rule arrive() =
let load = new Load
lib.add(queue, load)
// Schedule next arrival
endrule
// Main rule
main rule main =
if sim_clocktime < sim_end_time then
run_routine()
endif
endrule
// Initial state
init:
sim_clocktime := 0.0
queue := []
endinit
Verification
SimASM can verify stutter equivalence between two models:
%%simasm verify
verification EG_vs_ACD:
models:
import EG from "event_graph_model.simasm"
import ACD from "acd_model.simasm"
endmodels
seed: 42
labels:
label queue_empty for EG: "queue_count() == 0"
label queue_empty for ACD: "queue_count() == 0"
endlabels
observables:
observable queue_empty:
EG -> queue_empty
ACD -> queue_empty
endobservable
endobservables
check:
type: stutter_equivalence
run_length: 1000.0
endcheck
endverification
Documentation
License
MIT License - see LICENSE for details.
Citation
If you use SimASM in your research, please cite:
@software{simasm,
title = {SimASM: Abstract State Machine Framework for Discrete Event Simulation},
author = {Steve},
year = {2024},
url = {https://github.com/yourusername/simasm}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simasm-0.2.2.tar.gz.
File metadata
- Download URL: simasm-0.2.2.tar.gz
- Upload date:
- Size: 228.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44c3f79a3be28220deff5d2a6d77807a9a7f06dda534960c846a88c0020eb218
|
|
| MD5 |
d4413289505618636444ffc9244df0e9
|
|
| BLAKE2b-256 |
d8642ab8213269b7a20ee4a7aadcae8829290aeffe59c6fc7e384f4f9277b12a
|
File details
Details for the file simasm-0.2.2-py3-none-any.whl.
File metadata
- Download URL: simasm-0.2.2-py3-none-any.whl
- Upload date:
- Size: 208.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f3447c4c35b5eb06ac9ebe95bca301577c7fdea71736a300a8d706e1fef723f
|
|
| MD5 |
e4ff8e029de22a82f4cb4cb7e1a8fb3b
|
|
| BLAKE2b-256 |
aa6f8d35cc4fa2cad04d1e3751e9ee6572bdc4f66c5a033fc06a04d85707efba
|