Scenario lab
Create synthetic entities, simulate their decisions in bounded concurrent batches, and aggregate counts and percentages. A seed makes fixture populations reproducible. Even when a live model decides, the outcomes remain simulated rather than observed real-world behavior.
Capabilities
| Capability | Kind | Signature | Module | Summary |
|---|---|---|---|---|
aggregate_and_analyze | skill | (decisions: list[dict], options: list[str]) -> dict | examples/python/scenario_lab/main.py | |
decompose_scenario | traversal | (scenario: str, options: list[str] | None = None) -> dict | examples/python/scenario_lab/main.py | |
generate_entity | traversal | (entity_id: str, scenario_analysis: dict, seed: int, factor_graph: dict | None = None) -> dict | examples/python/scenario_lab/main.py | |
generate_factor_graph | traversal | (scenario_analysis: dict) -> dict | examples/python/scenario_lab/main.py | |
run_simulation | traversal | (scenario: str, population_size: int = 5, parallel_batch_size: int = 2, seed: int = 42, options: list[str] | None = None) -> dict | examples/python/scenario_lab/main.py | |
simulate_entity_decision | traversal | (entity: dict, scenario_analysis: dict) -> dict | examples/python/scenario_lab/main.py |
Commands
EXAMPLE_MODE=fixture python -m atfgraph.worker --module examples.python.scenario_lab.main:app
atfg install ./examples/python/scenario_lab
atfg run scenario_lab
atfg server start
atfg traverse scenario_lab.run_simulation --in '{"scenario": "Travellers choose budget or flexible fares", "population_size": 5, "parallel_batch_size": 2, "options": ["budget", "flexible"]}'
python -m examples.python.scenario_lab.call
Files
examples/python/scenario_lab/README.mdexamples/python/scenario_lab/__init__.pyexamples/python/scenario_lab/agentnode.yamlexamples/python/scenario_lab/call.pyexamples/python/scenario_lab/main.pyexamples/python/scenario_lab/node.pyexamples/python/scenario_lab/requirements.txtexamples/python/scenario_lab/support.py
README
Create synthetic entities, simulate their decisions in bounded concurrent batches, and aggregate counts and percentages. A seed makes fixture populations reproducible. Even when a live model decides, the outcomes remain simulated rather than observed real-world behavior.
Run locally
Run from the repository root with the SDK installed:
atfg server start
EXAMPLE_MODE=fixture python -m atfgraph.worker --module examples.python.scenario_lab.main:app
# In a second terminal:
python -m examples.python.scenario_lab.call
Alternatively, install this folder as a managed local node:
atfg install ./examples/python/scenario_lab
atfg run scenario_lab
node.py also supports a copied project folder. The default server is http://127.0.0.1:18880; open /ui/ to inspect simulated runs and child calls.
Call with the CLI
atfg traverse scenario_lab.run_simulation --in '{"scenario": "Travellers choose budget or flexible fares", "population_size": 5, "parallel_batch_size": 2, "options": ["budget", "flexible"]}'
Providers
Fixture mode is the default and needs no external model/search calls. Deterministic results check the simulation mechanics, not predictive accuracy.
For model-based simulation, set EXAMPLE_MODE=live, model URL/name and any required key before starting the worker. Misconfiguration and provider failures remain errors rather than switching to fixture decisions.
Python client
from atfgraph import Client
async with Client("http://127.0.0.1:18880") as client:
result = await client.traverse(
"scenario_lab.run_simulation",
{'scenario': 'Travellers choose budget or flexible fares', 'population_size': 5, 'parallel_batch_size': 2, 'options': ['budget', 'flexible']},
timeout=300,
)
print(result)