Skip to content
  • There are no suggestions because the search field is empty.

Resource Modeling Walkthrough

A step-by-step guide to building a condition-based loop with resource consumption, production, and simulation tracking.

Introduction

In this walkthrough, we'll explore how to use Innoslate’s Resource Modeling capabilities to simulate a real-world operational loop: driving a car and refueling it based on fuel consumption. This example introduces basic resource dynamics and demonstrates how resources are consumed and produced within an Action Diagram using a simple behavioral scenario.

We will model a car that continuously drives until it consumes 80% of its fuel capacity, then refuels and repeats the process. This use case is ideal for understanding how to configure resource flows and loop conditions in Innoslate.

Scenario Overview

  • System Context: A car operating at 60 mph with a fuel efficiency of 30 miles per gallon
  • Tank Capacity: 20 gallons (initially full)
  • Fuel Consumption Rate: 2 gallons per hour
  • Operational Logic: The car will loop between driving and fuel consumption until the fuel level drops below 4 gallons (20% of the tank). Then, the car will exit the loop and refuel 16 gallons to full capacity.

This walkthrough will cover:

  • Overview of the Action Diagram model
  • Configuring consumption and production relationships
  • Using the Loop Script feature to control flow based on the fuel level
  • Using the Discrete Event Simulation to analyze the functional model

To follow along and try out the features mentioned in this walkthrough, click here to instantly download the Car Refuel Resource Modeling Walkthrough Project .INNO File and import it into a new Innoslate project.

Walkthrough Use Case

This example models a simplified operational loop of a car that alternates between driving and refueling based on fuel availability. The model is implemented as an Action Diagram in Innoslate, which captures the behavioral flow and integrates resource logic to simulate fuel consumption and replenishment.

ResourceModeling_Overview

The diagram begins with a Loop construct that encapsulates a series of actions simulating the car's operation. The loop continues iterating as long as the Fuel resource level is greater than 4 gallons (representing 20% of the tank). When the condition is no longer met, the loop exits and transitions to a refueling operation before reaching the model’s end.

Model Entities:

  • Drive-Refuel Loop (Ex.1): Governs the cyclic behavior of the system. The loop is configured with a Continue Condition tied to the Fuel resource: Fuel > 4
    This means the actions inside the loop (Drive and Consume Fuel) will repeat until fuel drops below this threshold.

  • Drive (Ex.2): Represents the car driving at 60 mph, consuming fuel at a rate of 2 gallons per hour. This action simulates forward motion while actively depleting fuel.

  • Consume Fuel (Ex.3): A placeholder action used to log and track the consumption of fuel. This step is where the fuel resource is explicitly consumed by 2 gallons per loop iteration.

  • Refill Tank (Ex.4): Triggered once the loop exits. It replenishes the fuel resource by adding 16 gallons, bringing the fuel tank back to full capacity (20 gallons). The model then proceeds to the END node.

  • Fuel (Resource): Represents the car’s fuel tank, initialized at 20 gallons. It is consumed during the “Consume Fuel” action and produced during the “Refill Tank” action. Its state directly controls the loop logic.

Notable Modeling Details

This section highlights key configurations that enable dynamic resource-based behavior in the model. These elements work together to create a condition-driven loop with visible, trackable fuel consumption during simulation.

1. Loop Condition Configuration

The Drive-Refuel Loop (Ex.1) is configured with a loop script that evaluates the Fuel resource amount before each iteration. The loop continues executing as long as the Fuel value is greater than 4 gallons:

  • Loop Resource: Fuel

  • Continue Condition: Fuel > 4

ResourceModeling_LoopScript

This setup ensures the system continues the driving behavior until fuel drops below 20% capacity. Once the condition is false, the model exits the loop and proceeds to refuel.


2. Resource Consumption and Production Relationships

The Fuel resource is defined with an initial amount of 20 gallons, and includes both consumption and production relationships:

  • Consumed by:

    • Ex.3 – Consume Fuel: 2 gallons per iteration

  • Produced by:

    • Ex.4 – Refill Tank: 16 gallons added to the resource pool

ResourceModeling_FuelRelationshipAttributes

These relationships are critical for simulating fuel dynamics during execution. As the model iterates through the loop, the resource is gradually reduced and replenished according to these links.


3. Resource Tracking with Simulation Script

To enable the Discrete Event Simulator to track fuel level changes over time, the "Ex.3 Consume Fuel" and "Ex.4 Refill Tank" actions includes a simple script that logs and sets a global Fuel variable. This allows the simulation to monitor and report the current fuel level at any point during execution.

function onStart/End() {
let Fuel = Sim.getAmount("Fuel");
console.log("Fuel:", Fuel);
globals.set("Fuel", Fuel);
}

This script uses Innoslate’s simulation API to access the Fuel resource, log its value, and store it in a global variable. This is especially useful when validating the simulation’s performance or visualizing fuel depletion over time in the simulator's timeline view.

Simulate using Discrete Event Simulator

Once the Action Diagram is complete and resource relationships are defined, the model is ready to be simulated using Innoslate’s Discrete Event Simulator (DES). This step enables you to validate the behavioral logic and track fuel consumption dynamically over time.

Simulation Setup

The layout of the simulator panels is fully customizable and is based on user preference. However, for this walkthrough, we recommend arranging the simulation interface to match the panel configuration shown below:

  • Status (Default) – Displays completion percentage

  • Total Time (Default) – Shows the full time elapsed in simulation

  • Action Trace 3D (Other) – Visually tracks execution flow

  • Tree Map (Time) – Highlights the most time-consuming actions

  • Global Tracker (Other) – Lists values of global variables over time

  • Resource Over Time (Resources) – Graphs fuel usage throughout the simulation

  • Final Amounts (Resources) – Compares fuel produced vs. consumed

📌 Tip: Click and append each panel into position before running the simulation for easier observation. Make sure to "Save Settings" in the Settings side panel to save this view for the simulation.

Simulation_PanelConstruction


Simulation Results

After running the simulation, the results confirm that the model correctly handles the drive-refuel loop logic and fuel resource behavior.

Simulation_Results

Here’s a breakdown of what the panels show:

  • Status and Total Time: The simulation completed successfully at 100%, with a total duration of 8.05 hours. This aligns with the expected behavior—8 hours of driving (consuming 16 gallons) followed by a refuel operation before reaching the end of the model.

  • Tree Map and Final Amounts: The Tree Map highlights Ex.2 Drive as the dominant action, reflecting the multiple driving iterations before refueling. The Final Amounts bar chart confirms fuel usage was balanced: 16 gallons consumed, 16 gallons produced, and 20 gallons remaining at the end, indicating a full tank post-refuel.
  • Action Trace 3D: 3D visualization of the model executed: looping through driving and consuming fuel, then transitioning to refuel.

  • Global Tracker: Logs the value of the Fuel global variable over time. You can observe fuel dropping in 2-gallon steps each hour, from 20 gallons down to 4 gallons. After the loop exits and the refuel occurs, fuel jumps back up to 20 gallons at 8.05 hours.

  • Resource Over Time: The line graph shows a steady linear decline in fuel from 20 to 4 gallons over the 8-hour loop period, followed by a sharp recovery to full capacity (20 gallons) after the refuel step.

These outputs validate that the loop logic, resource consumption, and production are functioning correctly, and that the resource tracking script is enabling proper visualization of fuel behavior over time.

Conclusion

This walkthrough demonstrated how to build a functional and resource-aware behavioral model in Innoslate using a simple yet powerful example: a car that drives, consumes fuel, and refuels once the tank reaches a critical level.

Whether you’re modeling vehicle systems, logistics operations, or energy-dependent workflows, this example can serve as a foundation for more advanced applications of Innoslate’s resource modeling capabilities.

To continue learning about Modeling and Simulation, Click Here.

(Next Article: SysML Modeling Use Case)