The Assign object performs one or more Attribute assignments whenever it receives an incoming entity. Once the assignments have been performed, the received entity is passed to the next object without delay.
The Assign object is the only place where an Attribute's value can be modified. The Assign object can modify the value of any attribute in the model: its own attributes, the received entity's attributes, or any other object's attributes.
The attribute assignments to be performed are specified by the input to the AttributeAssignmentList keyword. Each assignment has the following form:
{ <left-hand side expression> = <right-hand side expression> }
The right side of each assignment equation is an expression to be evaluated. The left side is an expression that identifies the attribute whose value is to be modified. For example, if object Assign1 has a dimensionless numerical attribute A, then the following input to its AttributeAssignmentList keyword causes the attribute to be increased by 1:
{ 'this.A = this.A + 1' }
The Assign object attribute obj can be used to access the attributes of the received entity. For example, if the received entity has an attribute B whose value is a string, then the following input to the AttributeAssignmentList keyword causes this attribute to take the value 'New String':
{ 'this.obj.B = "New String"' }
If another object, say Server1, has an attribute C whose value is a number with units of distance, then the following input to the AttributeAssignmentList keyword causes this attribute to be increased by 1 kilometre:
{ '[Server1].C = [Server1].C + 1[km]' }
The entries in an array or map can also be modified. For example, the following input assigns the value 1 to the second entry in an array-valued attribute ArrayAttrib and the value 2 to the key "abc" in the map-valued attribute MapAttrib:
{ 'this.ArrayAttrib(2) = 1' } { 'this.MapAttrib("abc") = 2' }
Furthermore, the index for an array assignment or the key for a map can be a calculated quantity. For example, the following input assigns the value 1 to the index of ArrayAttrib that is given by the attribute N of the entity that is being processed:
{ 'this.ArrayAttrib(this.obj.N) = 1' }
An entry in a two-index array (an array of arrays) can be set by specifying two separate indices. For example, if the attribute MatrixAttrib is the two-index array {{0,0},{0,0}}, then the following input assigns the value 1 to the second entry in the first nested array:
{ 'this.MatrixAttrib(1)(2) = 1' }
An unlimited number of assignments can be performed by one Assign object. The assignments are processed in the order in which they appear in the AttributeAssignmentList input.