A Smarter Way to Number Simulation Scenarios in Transportation Studies

By Maryam Shirinzad, Ph.D., PE

The Problem

Traditional methods of naming or tracking simulation runs rely on manually labeled combinations or arbitrary file names. But what if you want to automate everything, reproduce results months later, or scale to hundreds of configurations?

You need a deterministic and scalable indexing strategy.

Our Solution: Hierarchical Scenario Numbering

We treat every simulation scenario as a unique combination of input variables. Each variable has discrete options, and every scenario is like a "leaf" in a big simulation tree. We flatten this tree into a simple counter using a positional math trick borrowed from computer science: mixed-radix numeral systems.

Example

Let’s say your study includes the following 4 variables:

Total combinations = 24 = 16 scenarios

# Assume: i, j, k, l are the indices (0 or 1) of the 4 variable options
counter = (2*2*2)*i + (2*2)*j + (2)*k + l + 1

For scenario (1, 0, 1, 0):

counter = 8*1 + 4*0 + 2*1 + 0 + 1 = 11

Why This Works (The Math)

This method is mathematically equivalent to converting a 4-digit number in a base-[I, J, K, L] system into base-10. Each variable acts like a "digit," and the result is a unique number for each configuration.

Reverse It Too

Need to go backward? You can recover variable values from any scenario number:

s = scenario_id - 1
l = s % L; s //= L
k = s % K; s //= K
j = s % J; s //= J
i = s

Who Should Use This

Try It Yourself

You can implement this strategy in any programming language, but we’ve found Python to be especially intuitive. Drop this into your loop logic, and every run will be perfectly traceable.

Have questions or want us to implement a scenario numbering engine for your next project? Contact us for a free consultation.

About Proxisco

Proxisco specializes in data-driven solutions at the intersection of transportation engineering, data science, and simulation modeling. We help public agencies and private firms design safer, smarter systems through innovative tools and rigorous analysis.

Explore our services or follow us on LinkedIn for updates.