Discrete builtins

The discrete builtins provide access to attribute information on stocks and flows as well as information about the internal workings of the conveyor, queue, and oven stock types. These builtins tell you what a particular discrete stock is doing as the simulation progresses.

This section describes the following builtins:

AGECOUNT(<stock>, <minval> ,[<maxval>])

The AGECOUNT builtin returns the number of items (quantity of material) where the age is greater than or equal to minval and strictly less than maxval. If maxval is not specified then it returns the number of items with age greater than or equal to minval. This builtin can only be used on conveyors, queues, and non-negative stocks when using cycletime as the integration method (as specified in the Model Settings Properties Panel). It can also be used on conveyors with a constant transit time, and in this case will use time in the conveyor to determine age. It will return NAN when called on other variable types.

The AGECOUNT operates on time stamped material in the stocks. If there is no time stamped material it will return 0 except in the case of a conveyor with constant transit time. In this case it will return the number of items that have been in the conveyor for the specified amount of time.

Note You can use AGECOUNT on non-negative stocks if you have set Cycle-Time as the integration method. For other integration methods NAN will be returned.

Upstream flows must be time stamped for queues and stocks. See Attribute and Cycle Time Tracking for more discussion.

Note For conveyors with variables transit time (FIFO or not) the inflows must be time stamped to make use of AGECOUNT.

Note For conveyors with inflows that are not at the beginning and not time stamped material flowing in will be treated as having an age distribution.

Example:

age_3_to_less_than_5 = AGECOUNT(Population[Age0To9], 3, 5) returns the number of people at least 3 years old, but less than 5 (no time stamping with Population a conveyor).

age_13_to_less_than_15 = AGECOUNT(Population[Age10To19], 3, 5) returns the number of people at least 13 years old, but less than 15 (no time stamping with Population a conveyor).

waiting_longer_than_10 = AGECOUNT(call_waiting_queue,10,INF) returns the number of people waiting at least 10 minutes for their calls to be answered. The upstream flow must be timestamped.

Note Using the ranges (0,2), (2,5), (5,10) on a conveyor with transit time 10 will exactly account for all the content of the conveyor (their sum will be equal to the conveyor value).

ATTRCOUNT(<stock or flow>, <minval> [,<maxval>])

The ATTRCOUNT builtin returns the number of items where the attribute is between minval and maxval inclusive. If maxval is left off (the function is called with 2 arguments) it returns the number of items having the attribute specified by minval. If there are no batches with attributes in the stock or flow it returns 0, and it will also return 0 if there are batches with attributes, but none fall within the specified range.

When used on a stock ATTRCOUNT returns the quantity as contained in the stock. When used on a flow, ATTRCOUNT returns flow rate. Thus if everything has an attribute between 1 and 10 ATTRCOUNT(stock, 1,10) will return the value of the stock as reported in graphs and tables while ATTRCOUNT(flow,1,10) will return the value of the flow as reported in graphs (tables can be set to adjust flow values to match standard accounting practices).

Note You can use ATTRCOUNT on non-negative stocks and their outflows if you have set Cycle-Time as the integration method. For other integration methods 0 will always be returned.

Attributes are set on upstream flows. See Attribute and Cycle Time Tracking for more discussion.

Example:

number_small = ATTRCOUNT(In_Process, 1, 5) returns the number of items where the attribute is at least 1, but not more than 5.

Attributes are set on upstream flows. See Attribute and Cycle Time Tracking for more discussion.

ATTRMAX(<stock or flow> [,<missval>])

The ATTRMAX builtin returns the maximum value of the attributes across the content of a stock or flow, or it will return missval if there is no material with attribute values. For stocks, there can be a variety of material from different times and sources that is being computed over. For flows, there will often be a single batch of material with one attribute value (so min, max and mean are all the same). If there is nothing that has an attribute value (either because the stock or flow is 0, or because nothing with an attribute value has yet reached it) it will return missval, or 0 if only a single argument is used.

Note You can use ATTRMAX on non-negative stocks and their outflows if you have set Cycle-Time as the integration method. For other integration methods missval or 0 will always be returned.

Note If 0 is a valid attribute value then you should include the missval argument.

Attributes are set on flows. See Attribute and Cycle Time Tracking for more discussion.

Example:

largest_size = ATTRMAX(In_Process) returns the maximum size in the In Process stock when the attribute is a size.

ATTRMEAN(<stock or flow> [,<missval>])

The ATTRMEAN builtin returns the mean value of the attributes across the content of a stock or flow, or it will return missval if there is no material with attribute values. For stocks, there can be a variety of material from different times and sources that is being computed over. For flows, there will often be a single batch of material with one attribute value (so min, max and mean are all the same). If there is nothing that has an attribute value (either because the stock or flow is 0, or because nothing with an attribute value has yet reached it) it will return missval, or 0 if only a single argument is used.

Note You can use ATTRMEAN on non-negative stocks and their outflows if you have set Cycle-Time as the integration method. For other integration methods missval or 0 will always be returned.

Note If 0 is a valid attribute value then you should include the missval argument.

Attributes are set on flows. See Attribute and Cycle Time Tracking for more discussion.

Example:

average_size = ATTRMEAN(In_Process) returns the average size in the In Process stock when the attribute is a size.

ATTRMIN(<stock or flow> [,<missval>])

The ATTRMIN builtin returns the minimum value of the attributes across the content of a stock or flow, or it will return missval if there is no material with attribute values. For stocks, there can be a variety of material from different times and sources that is being computed over. For flows, there will often be a single batch of material with one attribute value (so min, max and mean are all the same). If there is nothing that has an attribute value (either because the stock or flow is 0, or because nothing with an attribute value has yet reached it) it will return missval, or 0 if only a single argument is used.

Note You can use ATTRMIN on non-negative stocks and their outflows if you have set Cycle-Time as the integration method. For other integration methods missval or 0 will always be returned.

Note If 0 is a valid attribute value then you should include the missval argument.

Example:

smallest_size = ATTRMIN(In_Process returns the smallest size in the In Process stock when the attribute is a size.

ATTRSTDDEV(<stock or flow> [,<missval>])

The ATTRSTDDEV builtin returns the standard deviation of the attributes across the content of a stock or flow, or it will return missval if there is no material with attribute values. For stocks, there can be a variety of material from different times and sources that is being computed over. For flows, the function will return 0 if a single batch of material with one attribute value is flowing. If there is nothing that has an attribute value (either because the stock or flow is 0, or because nothing with an attribute value has yet reached it) it will return missval, or 0 if only a single argument is used.

Note You can use ATTRSTDDEV on non-negative stocks and their outflows if you have set Cycle-Time as the integration method. For other integration methods missval or 0 will always be returned.

Note If 0 is a valid attribute value then you should include the missval argument.

Example:

Size_Variance = ATTRSTDDEV(In_Process)^2 return the variance of sizes in the In Process stock when the attribute is a size.

CAPACITY(<oven or conveyor> )

The CAPACITY builtin returns the capacity associated with a conveyor or an oven, where conveyor is defined as a conveyor stock type, and oven is defined as an oven stock type. Often, you'll want to use an oven's capacity as an input to other model variables. Similarly, you may want to use a conveyor's capacity as an input to other model variables. The CAPACITY function allows you to accomplish these tasks.

Example:

Mixer_Capacity = CAPACITY(Mixer) returns the capacity you've specified for the Oven named Mixer.

OSTATE(<oven>)

The OSTATE function returns the status of an Oven, where oven is a discrete "oven" stock. If the oven is filling, OSTATE returns 0. If the oven is "cooking," OSTATE returns 1. If the oven is "emptying" and it will accept new material OSTATE returns 2. If the oven is "emptying" but is preparing to be cleaned and will not accept new material OSTATE returns 3. If the oven is being cleaned (so that it has 0 content and can't take new content) OSTATE returns 4. For more information about ovens, seeOven Computation.

Example:

Status = OSTATE(Mixer) returns the status of Mixer, where Mixer is a discrete oven stock.

PROCTIME(<conveyor or oven>)

The PROCTIME builtin returns the processing time associated with the flow of material that's currently entering the conveyor or oven stock type. When the inflow goes to zero, the PROCTIME builtin holds the value of processing time from the most recent inflow.

Example:

Process_time = PROCTIME(Work_in_Process) returns the processing time associated with material that's currently entering the Conveyor or Oven "Work in Process".

Concept Link IconSee Also