Simulation

Build live digital twins of your model — track real-world data over time, project scenarios into the future, and let agent behavior animate the graph.

Live Twins: A First Look

Beginner

What live twins are, when to use them, and how they sit on top of your existing model. Read this first before creating a twin or entering data.

Creating Twins and Scenarios

Beginner

Set up your first twin, choose its scope, then add one or more scenarios to compare alternatives.

Adding Agents to a Scenario

Beginner

Bring nodes to life as agents by dragging them from the Simulation Toolbox onto a simulation diagram. One node, many agents — the scaling pattern.

Entering Time Series Data

Beginner

Use the Time Series Grid in the agent properties panel to record values across timesteps — the spreadsheet inside your model.

Simulation Diagrams

Beginner

A simulation diagram is a canvas tied to a scenario — agents, links, charts, and controls all updating live as you scrub through time.

Adding Charts, Sliders, and Checkboxes

Intermediate

Drop charts, sliders, and checkboxes onto a simulation diagram to turn it into an interactive dashboard your stakeholders can play with.

Writing Property Formulas

Intermediate

Compute property values automatically with short Rhai expressions — spreadsheet formulas that know about your graph.

Writing Act Methods

Advanced

When property formulas aren't enough — write a Rhai script that runs once per agent per timestep and updates several properties together.

Reading Connected Agents in Rhai

Intermediate

Use get_connected, sum_prop, and count_prop to let agents read each other's state through the graph — the way Metapad agents coordinate.

Diagnosing Simulation Errors and Warnings

Intermediate

The Scenario Diagnostics tab tells you whether a scenario is healthy — cycles, unresolved references, runtime warnings, authoring errors all in one place.

agent.get_propRhaiboth

Read a property's value on the current agent. The simplest form returns the value at the current timestep. Add a negative offset to look back in time — useful for self-referential formulas where the new value depends on the old one. The return type matches the property's data type: a number for Number properties, true/false for Boolean, a string for everything else.

agent.set_propRhaiact_method

Write a value to one of the agent's properties at the current timestep. Only available inside an act method — property formulas don't use set_prop, they return their result instead. set_prop can override values that property formulas just computed for the same timestep, so use it when behavior touches multiple properties or depends on state-machine-like logic.

agent.has_propRhaiboth

Check whether a property exists on the agent. Returns true if the property is defined on the agent's node type, false otherwise. Useful when working with optional properties or when writing formulas that adapt to different agent types in the same model.

sum_propRhaiboth

Sums a numeric property across an array of agents. Most often used in combination with get_connected to roll up values from connected agents — total payroll, total inventory, total revenue. Non-numeric or missing properties evaluate to 0, so a partially-filled set still produces a clean number.

count_propRhaiboth

Counts how many agents in an array have a specific value for a given property. Common pattern: counting connected agents in a particular state (e.g., active members of a team, completed steps of a process). The comparison is exact — string equality for text properties, numeric equality for numbers.

__timestepRhaiboth

The current timestep's index — 0 at the start of the scenario, 1 at the next step, and so on. Available as a scope variable inside every formula and act method. Useful for periodic logic ('once per year'), startup conditions, or any rule that depends on absolute time within the scenario.

__dtRhaiboth

The scenario's step size — for example, 1.0 if start and end times are in months and dt is 1, or 1/12 if start and end are in years and you're stepping monthly. Use it to scale rates that are expressed per unit of natural time, so a formula stays correct even if the scenario's granularity changes later.

get_connectedRhaiboth

Returns the agents connected to the given agent via a relationship type. Walks the link in either direction, so the same call works whether your agent is the source or the target. The 3-argument form adds a negative offset, returning what those agents looked like one or more timesteps ago — used for modeling delivery delays, propagation lags, or any time-shifted observation. The 3-argument form is currently available in property formulas only; in act methods, use the 2-argument form and read history through agent.get_prop on individual members.