/\ ATFGraph /docs
README Downloads
Examples / ATFGraph
Framework reference

This article is retained from the existing framework docs. Self-hosting commands and server-admin access differ from the managed CLI workflow. Start with Get started for the installed product.

Scenario lab

Directory examples/python/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.

Agent node label scenario_lab, version 1.0.0.

Capabilities

CapabilityKindSignatureModuleSummary
aggregate_and_analyzeskill(decisions: list[dict], options: list[str]) -> dictexamples/python/scenario_lab/main.py
decompose_scenariotraversal(scenario: str, options: list[str] | None = None) -> dictexamples/python/scenario_lab/main.py
generate_entitytraversal(entity_id: str, scenario_analysis: dict, seed: int, factor_graph: dict | None = None) -> dictexamples/python/scenario_lab/main.py
generate_factor_graphtraversal(scenario_analysis: dict) -> dictexamples/python/scenario_lab/main.py
run_simulationtraversal(scenario: str, population_size: int = 5, parallel_batch_size: int = 2, seed: int = 42, options: list[str] | None = None) -> dictexamples/python/scenario_lab/main.py
simulate_entity_decisiontraversal(entity: dict, scenario_analysis: dict) -> dictexamples/python/scenario_lab/main.py

Commands

Taken from this example's own README and module docstrings.

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.md
  • examples/python/scenario_lab/__init__.py
  • examples/python/scenario_lab/agentnode.yaml
  • examples/python/scenario_lab/call.py
  • examples/python/scenario_lab/main.py
  • examples/python/scenario_lab/node.py
  • examples/python/scenario_lab/requirements.txt
  • examples/python/scenario_lab/support.py

README

Rendered from examples/python/scenario_lab/README.md; the source file is not modified.

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)
ATFGraph documentationHosted workflow · Framework reference