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:

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 is 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