-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualize_examples.py
More file actions
60 lines (45 loc) · 1.79 KB
/
Copy pathvisualize_examples.py
File metadata and controls
60 lines (45 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Generate Mermaid diagrams for all example models.
Run this script to create visual diagrams of each example system:
uv run python examples/visualize_examples.py
The output can be:
- Pasted directly into GitHub/GitLab markdown
- Rendered at https://mermaid.live
- Viewed in VS Code markdown preview
"""
import importlib
from gds_viz import system_to_mermaid
def main():
examples = [
("SIR Epidemic", "sir_epidemic.model"),
("SIR Epidemic (DSL)", "sir_epidemic_dsl.model"),
("Thermostat PID", "thermostat.model"),
("Insurance Contract", "insurance.model"),
("Lotka-Volterra", "lotka_volterra.model"),
("Prisoner's Dilemma", "prisoners_dilemma.model"),
("Crosswalk Problem", "crosswalk.model"),
("Double Integrator", "double_integrator.model"),
("Order Processing (DFD)", "software.order_processing.model"),
]
for name, module_path in examples:
print(f"\n{'=' * 60}")
print(f"{name}")
print(f"{'=' * 60}\n")
# Dynamically import the build_system function
module = importlib.import_module(module_path)
build_system = module.build_system
# Build and visualize
system = build_system()
mermaid = system_to_mermaid(system)
print("```mermaid")
print(mermaid)
print("```")
# Stats
print(f"\nStats: {len(system.blocks)} blocks, {len(system.wirings)} wirings")
feedback_count = sum(1 for w in system.wirings if w.is_feedback)
temporal_count = sum(1 for w in system.wirings if w.is_temporal)
if feedback_count > 0:
print(f" - {feedback_count} feedback wiring(s)")
if temporal_count > 0:
print(f" - {temporal_count} temporal wiring(s)")
if __name__ == "__main__":
main()