Attributes and Custom Outputs

Users can define two types of variables for individual objects in a model:

ˇ         Attribute.  A variable whose value can be changed be changed by one or more Assign objects in a model.  Attributes are a useful way to add application-specific information to generated entities or to the permanent objects in a model.  For example, if there are two types of customers in a model that require different service times, an attribute named "type" can be added to the generated customer objects and randomly assigned the value 1 or 2.  When the customer arrives at the server, its service time can then be calculated based on its type attribute.

ˇ         Custom Output.  A variable whose value is calculated on demand by evaluating a specified expression during the simulation run.  Custom outputs are a way for the user to supplement the JaamSim's built-in outputs or to avoid repeating a complicated calculation in more than one expression.

Attributes and custom outputs can have same types of values as expressions, i.e. numbers with or without units, strings, entities, arrays, maps, or lambda functions.  They appear in the Output Viewer as outputs under the Entity heading.

The name for an attribute or custom output can be any alphanumeric text provided that no spaces, commas, or special symbols are included.

Attributes and custom outputs can be defined for any of the objects in a model using the AttributeDefinitionList and CustomOutputList keywords described in the following table.

Keywords for Attributes and Custom Outputs

Keyword

Description

AttributeDefinitionList

Defines one or more attributes for the object.  The following format is used for the input:

{ <Name1> <InitValue1> } ... { <NameN> <InitValueN> }

where Name is the name of the attribute and InitValue is an expression that returns the initial value for the attribute.  The expression is evaluated when the simulation is first started or re-started.  Normally, the expression is a simple constant, such as 5[km].  The attribute type (number, string, etc.) is determined by its initial value.  Do not reference any attributes, outputs, or custom outputs of any object in the InitValue expression.

The following example defines a series of attributes of various types:

{ A 1 } { B 9[km] } { C '"abc"' } { D [Server1] } { E '{5,3,7}' }

 

CustomOutputList

Defines one or more custom outputs for the object.  The following format is used for the input:

{ <Name1> <Exp1> <Unit1> } ... { <NameN> <ExpN> <UnitN> }

where Name is the name of the custom output, Exp is the expression to be evaluated on demand, and Unit is the unit type for the output.

For example, the following example defines a custom output called TwiceSimTime, whose value is equal to two times the present simulation time:

{ TwiceSimTime  '2 * this.SimTime'  TimeUnit }