Skip to content

Functions

A function works out a value while your model runs. You call one by name inside any expression or action-logic statement, and it hands back a number or a piece of text: the current clock time, how many entities are in an activity, the free units of a resource, an entity’s cost so far.

A statement does something and sits on its own line. A function returns a value and goes wherever a value is allowed: the right-hand side of an assignment, a processing time, a route or gate condition, an arrival quantity.

Functions are grouped by what they read. Use this to find the right page fast:

FamilyWhat it readsReach for it when
System ValuesThe run as a whole: the clock, work in process, entity counts, random drawsYou need the time of day, the size of the backlog, or a random number
Activity QueriesThe state of one activity: contents, capacity, queue length, throughput, whether it is blockedYou are routing around a bottleneck or holding work back until there is room
Resource QueriesThe state of one resource: free units, utilization, shift, units downYou are choosing between people or machines, or waiting for one to come free
Entity PropertiesValues carried by the entity being processed: age, cost, type, time so farYou are branching on what this particular entity is, or how long it has waited
Gate, Signal, and Inventory QueriesWhether a gate is open, a signal is on, or how much stock is on hand, on order, and worthYou are coordinating one part of the model with another
Math FunctionsNothing in the model; they work on the numbers you give themYou need to round, cap, or otherwise tidy a calculated value
String FunctionsNothing in the model; they work on the text you give themYou are building an entity name or comparing a text attribute

Type the function wherever a value is allowed. Object queries name the object in double quotes, for example Resource("Doctor").FreeUnits or Activity("Inspect").Contents. Math and string functions take their arguments in parentheses instead, and system values such as CLOCK need no argument at all.

As you type in the editor, ProcessModel suggests the function, shows what it returns, and lists its parameters, so you rarely have to remember the exact form.

// A query names its object in double quotes, then the value you want
SET v_Free TO Resource("Doctor").FreeUnits
// A math or string function takes its arguments in parentheses
SET a_Price TO ROUND(a_Raw * 1.08, 2)
// A system value needs nothing at all
SET a_StartTime TO CLOCK

Notes in action logic start with //, as above. An apostrophe is not a comment marker, so write notes with // and names with double quotes. See Comments.

Two small functions do not fit a family and are documented on this page:

FunctionWhat it returns
IF(condition, valueIfTrue, valueIfFalse)One of two values, depending on a test.
PERCENT(p)True p percent of the time, for a quick random split.
// Inline IF returns a value, so it fits where only one value is allowed
// A rush job is allowed 2 minutes, everything else 10
SET a_Allowed TO IF(a_Priority = 1, 2, 10)
// PERCENT is true p percent of the time: a quick 30 to 70 split
SET a_Branch TO IF(PERCENT(30), 1, 0)

Do not confuse the inline IF(…) function here with the IF … THEN … ENDIF statement on the Flow Control page. The function returns a value; the statement runs different lines.

Four families in one activity. A claim arrives, and the logic works out how long it will take, waits for someone to do it, and decides where it goes next:

// Entity property: is this a rush claim
SET a_Rush TO IF(Entity.TypeName = "Rush", 1, 0)
// Math function: hold the handling time between 1 and 20 minutes
SET a_Handle TO CLAMP(a_BaseTime * a_Complexity, 1, 20)
// Rush claims are given a quarter off that time
IF a_Rush = 1 THEN SET a_Handle TO a_Handle * 0.75 ENDIF
// Resource query: wait for an assessor, then spend the time
WAIT UNTIL Resource("Assessor").FreeUnits > 0
TIME a_Handle min
// Activity query: send it to whichever review desk is emptier
IF Activity("Review1").Contents < Activity("Review2").Contents THEN ROUTE 1 ELSE ROUTE 2 ENDIF
LegacyHow this worked in the previous version

Functions provide you with critical system information at any given time during the simulation. They can be used in an assignment statement to set the value of a variable or attribute or in an IF…THEN statement to make a decision based on system information. There are several system functions:

System reserved words cannot be used as variable names, attributes, or scenario parameters.