Quantity Resources

A Quantity Resource represents discrete elements which are stored in a resource pool when not in use, and are allocated to MLDesigner data structures as they move through a system.

Typically, a data structure will enter an Allocate block to request resource units. Any quantity of units can be requested. The Allocate block provides queuing if the resource units cannot be allocated immediately. When the resource units can be allocated, the data structure exits the Allocate block and continues its journey through the model. At some later point in the processing of the data structure (and usually at a later time), the resource units may be returned to the resource pool for allocation to other requests.

When using nonaddressed resources, units can be identical and indistinguishable, in which case the resource represents a token pool. On the other hand, the addressed resources are distinguishable and each has an integer address. Requests for an addressed Quantity Resource require a contiguous block of units, which is allocated using either a first-fit or best-fit policy.

The two fundamental blocks for manipulation of quantity resources are the Allocate and Free blocks. The Allocate block is used to make a request for resource units. When the units are available, the output ports on the right side of the Allocate block are enabled to indicate that the resource units have been granted. The Free block is used to release resource units when they are no longer needed.

General operation

A quantity resource begins a simulation with an initial capacity, the number of resource units in the pool at the beginning of the simulation. The initial capacity is specified with the Initial Capacity resource attribute. During simulation, requests for quantities of the resource are made by enabling all of the inputs of an Allocate block. Input values, which includes one data structure of any type, are collectively called the transaction. The other inputs specify the attributes of the transaction. One attribute of the transaction is the number of units of the resource requested. If there is an unused quantity of the resource greater than or equal to the number of units requested and there are no transactions with a higher priority waiting in the queue, that number of units of the resource will be removed from the pool and granted to the transaction.

Any time resource units are granted to a transaction, the outputs of the Allocate block where the request was made are enabled. One of the outputs is the data structure which is associated with the transaction. The other outputs are the number of units granted and the starting index if the resource is addressed. Resource units can then be held for an arbitrary amount of time (as the data structure is delayed by other blocks in your model). The resource units can be freed by enabling the inputs of a Free block. One of the inputs specifies the number of units of the resource to free. Normally, you will need a field in your data structure to store the number of resource units held by each resource that can be possessed. If you use addressed resources, you may also need a field to store the starting index.

Modifying capacity during a simulation

If the Addressing Mode is NonIndexed, the capacity of the resource may be increased or decreased during the simulation by using the ChangeCap block. If the capacity is increased, new resource units are immediately placed in the resource pool, and the resource queue is checked. If any waiting transactions can be granted their requested number of units, they are immediately given the requested units.

If the capacity is decreased, the resource units are removed from the pool, provided the pool contains at least that number of units. If the pool does not contain the number to be removed, all unused units in the pool are removed, and the remaining units are removed when they become freed. The capacity of the resource cannot be less than zero. If you attempt to set the capacity below zero, the capacity of the resource is not changed, the output of the ChangeCap block is not enabled, but the simulation continues executing.

Overview of resource attributes

Quantity Resource Attributes



Possible values

Number of Dimensions

The number of dimensions which can be modeled with each grouping of resource blocks and arguments.


Initial Capacity

The number of resource units in the pool when the simulation starts.


Blocking Mechanism

The action to be taken if a transaction cannot be granted the requested number of resource units when it enters the Allocate block. This attribute must be set to Wait_for_Resource for the values of the next three resource attributes to be used (Maximum Occupancy, Queue Discipline and Queue Reject Mechanism).

Wait_for_Resource, Exit_without_any_Resource_Units, Seize_Available_Units

Maximum Occupancy

The maximum number of transactions which can wait in the queue at any one time.


Queue Discipline

The ordering of transactions in the queue which have the same priority.

First_In_First_Out, Last_In_First_Out

Queue Reject Mechanism

The way a transaction is chosen for rejection when a new transaction would cause the overall occupancy to exceed the Maximum Occupancy.

Incoming_DS_Rejected, Lowest_Priority_Rejected

Addressing Mode

This attribute determines whether each resource unit has a unique integer identifier (Indexed) or if resource units are indistinguishable.

Indexed, NonIndexed

Addressed Fit Policy

The policy by which available resource units are searched for when the Addressing Mode is Indexed. The value of this attribute is ignored if the Addressing Mode is NonIndexed.

FirstFit, BestFit

Resource attributes in detail

Number of Dimensions

One of the resource attributes, Number of Dimensions, allow a single set of resource block arguments to represent a collection of identical resources distinguished by an integer index, called the dimension. The Allocate, Free, and other resource models have an input (or parameter) which is the dimension of the resource to be accessed. The dimension is zero-based, with valid values between zero, inclusive, and the number of dimensions attribute of the resource, exclusive.

When you use multiple dimensions, separate queues and resource pools are created for each dimension. The resource attributes are the same for every dimension.

Blocking Mechanism

There are a few options if the requested quantity of the resource cannot be allocated immediately when the request is made. The transaction can be put into a queue to wait for the resource according to a specified queuing discipline (either FIFO or LIFO), it can be sent out the reject output without seizing any resource units, or it can take the available resource units. The first possibility is called Wait_for_Resource, the second Exit_without_any_Resource_Units, the third Seize_Available_Units. These are chosen with the Blocking Mechanism resource attribute, which has these three possible values. The default value is Wait_for_Resource.

Addressing mode

A quantity resource has two fundamental modes of operation specified by the Addressing Mode resource attribute. The default value is NonIndexed, which makes resource units indistinguishable from one another. Resource units are viewed simply as tokens. The other possible setting for this attribute is Indexed. In this mode, each unit of the resource is assigned an integer index, beginning with zero. The status of each resource unit is maintained and can be either in use (not in the pool) or idle (in the pool). A request for resource units is then a request for a contiguous block of resource units. An integer vector, called the Indexed Usage Vector, is maintained to store the state of each resource unit. In this vector, a 1 indicates that a particular resource unit is in use, while a 0 means that the resource unit is not in use.

Addressed Fit Policy

When the Addressing Mode is Indexed, the Addressed Fit Policy resource attribute controls how the Indexed Usage Vector is searched when a transaction enters an Allocate block. Possible values for this attribute are FirstFit and BestFit.