Specification-Driven Generation and Evaluation of Discrete-Event World Models via the DEVS Formalism

1Zhili College, Tsinghua University
2School of Transportation Science and Engineering, Beihang University
3Department of Industrial Engineering, Tsinghua University
arXiv, 2026

A discrete-event world-model framework for queues, deadlines, logistics, and other event-driven domains

DEVS-Gen turns a natural-language environment specification into a DEVS simulator with explicit components, interfaces, event logic, and timing. A trace-based benchmark checks the resulting simulator's operational validity and behavioral conformance, while the same model can support what-if analysis and event-driven visualization.

Specification to Simulator

Infer a modular simulator with explicit components and interfaces from natural-language requirements.

Trace-Based Evaluation

Check emitted event traces against operational contracts and specification-derived behavioral requirements.

Execution and Reuse

Run the simulator under alternative inputs or configurations and connect its event stream to downstream analysis or visualization.

Why Discrete-Event World Models?

A world model describes how an environment changes in response to actions. In operational domains such as supply chains and service systems, those changes depend on discrete events: arrivals trigger queues, service takes time, and concurrent activities compete for shared resources.

To compare possible actions in these environments, an agent needs an executable model that preserves event order, timing, and shared-resource constraints. The Discrete Event System Specification (DEVS) formalism provides explicit components, event transitions, and timing semantics for representing these interactions.

DEVS-Gen generates these simulators from natural-language specifications using DEVS. It plans the component hierarchy and port interfaces before synthesizing component behavior, so each component is implemented with its communication boundaries already specified.

The generated simulator is then executed on benchmark inputs, and its event traces are checked against the specification. Operational checks cover execution, I/O, and trace format. Behavioral checks cover component transitions, cross-component dependencies, and aggregate behavior.

What-if Analysis with a Generated Model

The Strategic Airlift example keeps one environment model fixed while changing the number of aircraft. Executing each configuration exposes queue expiration and delivery latency, allowing an agent to choose the smallest tested fleet that satisfies the stated constraints.

Strategic Airlift what-if analysis with a generated DEVS model

DEVS-Gen constructs the simulator once. The agent then evaluates fleet sizes of 3, 4, 5, and 6 aircraft over the same 1,000-second scenario using expiration counts and delivery latency measures.

Why the Execution Matters

  • The intervention changes a configuration input; it does not require regenerating the simulator.
  • The event trace records arrivals, assignments, flight phases, deliveries, and expirations.
  • The fleet comparison illustrates how an agent can reuse a generated simulator for what-if analysis.

How DEVS-Gen Works

DEVS-Gen turns a natural-language specification into an executable discrete-event simulator in two stages: top-down structural planning and bottom-up behavioral synthesis. The figure follows Strategic Airlift from the specification to the generated model and its visualization.

DEVS-Gen: top-down structural planning produces a PlanTree; bottom-up behavioral synthesis assembles an executable discrete-event simulator

Structural planning produces a PlanTree that specifies the model hierarchy, component responsibilities, and interfaces. Behavioral synthesis implements the components and assembles them into an executable simulator. The lower panels show a visualization extension driven by simulator events. Click the figure to inspect the hierarchy and port connections at full resolution.

1

Structural Planning

Construct a PlanTree, a hierarchy in which each node has a ModelPlan specifying its responsibilities, port interfaces, and coupling relationships before implementation begins.

2

Behavioral Synthesis

Generate atomic components that implement local state transitions, timing, and trace emission. Assemble coupled components bottom-up, reconciling their interfaces with the generated child components.

3

Execution and Reuse

Run the generated simulator through its external interface and use the emitted trace for evaluation, what-if analysis, or downstream visualization.

Examples

The tabs below present recorded generation-and-evaluation artifacts for Strategic Airlift and downstream-use demonstrations for ICU and Wet-Lab. Select components and expand details to inspect the saved plans, code, and traces.

Strategic Airlift is the running example in the paper. It models pallet arrivals, queue expiration, aircraft assignment, flight phases, delivery, return, and maintenance; its tab also shows how the event stream drives a 3D scene.

Adapting Policies to a Changed Environment

When warehouse B closes, five stores are supplied through warehouse A and one store receives direct factory supply with a different lead time and weekday–weekend demand pattern. The decision agent interacts with an updated simulator to select a policy for the changed supply network.

(a) Simulator-supported policy adaptation

The network diagrams summarize the original and revised environment specifications. DEVS-Gen builds or updates the simulator from the corresponding specification; the decision agent uses simulator feedback to select a policy.
The network diagrams summarize the original and revised environment specifications. DEVS-Gen builds or updates the simulator from the corresponding specification; the decision agent uses simulator feedback to select a policy.

(b) Independent evaluation

Independent Stockpyl evaluation uses 20 common environment seeds and a 100-day horizon. Bars show mean total cost; error bars show sample standard deviation. In the changed environment, adaptation reduces mean cost by 89.65% relative to retaining the original policy.
Independent Stockpyl evaluation uses 20 common environment seeds and a 100-day horizon. Bars show mean total cost; error bars show sample standard deviation. In the changed environment, adaptation reduces mean cost by 89.65% relative to retaining the original policy.

Explore the environment specifications, simulators, policies, and evaluation records →

Experiments

The benchmark evaluates simulator generation across ten scenarios, four model backbones, and both execution-enabled and execution-disabled comparison methods.

Benchmark

Each task is a self-contained evaluation package with a specification that states the execution interface and scored behavioral requirements, test inputs, and a checker that scores observable traces rather than source-code similarity.

Scoreope

Measures whether the generated simulator successfully runs, follows the required I/O contract, and emits valid trace logs.

Scorebeh

Averages the micro-level consistency and macro-level causality scores, giving the two categories equal weight. A test case that fails operational checks receives a behavioral score of zero.

  • Each scenario includes the specification, test inputs, and checker scripts.
  • Operational validity and behavioral conformance are reported separately.
  • Different implementations can receive credit when they satisfy the same stated behavior.
ABPNetwork BarbershopService FileTransferNetwork HouseHeatingControl IOBSBanking OTrainTransport SAASecurity SEIRDBio-Math StoreCashierService StratAirliftLogistics

The ten benchmark scenarios span service and banking workflows, network protocols, transport and logistics, access control, thermal control, and epidemic modeling.


Main Results

Click either result figure to open it at full resolution.

Operational validity and behavioral conformance across four backbones

Mean scores across ten scenarios. For each backbone, scores are first averaged across scenarios within each repetition; the table reports the mean and sample standard deviation across three repetitions. Avg. is the mean across the four backbones.

Generation time and token use at different outcome levels

Resource-versus-outcome curves for generation completion, operational validity, and behavioral conformance. The top row reports generation time and the bottom row token use.

PRIMARY OUTCOMES

  • 1. Highest average scores: Across the four backbones, DEVS-Gen has the highest mean operational score (0.669) and behavioral score (0.576).
  • 2. Statistical comparisons: A two-sided permutation test, stratified by backbone and scenario, finds significant behavioral gains over both execution-disabled Lite baselines. The smaller gains over the execution-enabled Standard agents do not reach significance.

RESOURCE USE AND ABLATION

  • 3. Resource use: DEVS-Gen generally requires less time and fewer tokens at higher completion and score levels, while some baselines are cheaper at lower levels.
  • 4. Staged synthesis: When both methods are required to generate an xdevs.py-based simulator, DEVS-Gen outperforms a single LLM call that generates the entire simulator directly on both scores for every backbone.

Try the Framework

The release contains DEVS-Gen, four baseline configurations, two direct-generation controls, the ten benchmark packages, generated programs, evaluation records, and plotting scripts. Generation is launched through src/generation/run_generation.py; evaluation uses devs_eval.cli.

1. Environment & Configuration

Run the commands below on Linux or WSL with Python 3.10 available. Create an isolated environment and add your model-provider API key to .env. Re-evaluating the bundled programs requires no API key.

git clone https://github.com/czyarl/devs_gen_code.git
cd devs_gen_code

python3.10 -m venv .venvs/devs-gen
.venvs/devs-gen/bin/python -m pip install -r envs/devs_gen.txt
.venvs/devs-gen/bin/python -m pip install . src/third_party/xdevspy simpy==4.1.1

cp .env.example .env
# Add the API key for the model provider used during generation.

2. Generate a DEVS Model

The example below generates a Strategic Airlift simulator. Replace MODEL_ID with a model ID accepted by your provider, such as openai/gpt-5.2 for the OpenAI API. The runner reports the generated project directory; use that directory in the evaluation command.

cd src/generation
../../.venvs/devs-gen/bin/python run_generation.py \
  --framework devs_gen \
  --model MODEL_ID \
  --benchmark SA \
  --workspace /tmp/devs_sa_generation
cd ../..

3. Run Benchmark-Style Evaluation

The evaluator needs unshare, bwrap, prlimit, and working Linux user and network namespaces. On Debian or Ubuntu, these tools are provided by util-linux and bubblewrap. Validate the scenario manifest, then evaluate the generated project using the directory reported above. Choose a new output directory for each run.

.venvs/devs-gen/bin/python -m devs_eval.cli validate-manifest benchmark/SA/manifest.json

.venvs/devs-gen/bin/python -m devs_eval.cli run-scenario \
  --manifest benchmark/SA/manifest.json \
  --simulator-directory /path/to/generated/project \
  --output-directory /tmp/devs_sa_eval

For the experiment setup, including baseline agents, benchmark assets, and configuration, see the GitHub repository linked above.

BibTeX

@misc{chen2026specificationdrivengenerationevaluationdiscreteevent,
      title={Specification-Driven Generation and Evaluation of Discrete-Event World Models via the DEVS Formalism}, 
      author={Zheyu Chen and Huiteng Zhuang and Zhuohuan Li and Chuanhao Li},
      year={2026},
      eprint={2603.03784},
      archivePrefix={arXiv},
      primaryClass={cs.AI},
      url={https://arxiv.org/abs/2603.03784}, 
}