Associating Units with Model Identifiers

The Unit attribute

To associate units with scalar or multi-dimensional identifiers in your model, you can specify a unit definition for such identifiers through the Unit attribute. The Unit attribute is only supported for the following identifier types:

  • parameters,

  • variables,

  • constraints,

  • arcs,

  • nodes,

  • function and procedure arguments, and

  • internal and external functions.

Visibility of the Unit attribute

Within the AIMMS Model Explorer, the Unit attribute is only visible in the attribute forms of the identifier types listed above if your model already contains the declarations of one or more quantities. If you only want to use the Unit attribute to specify a scale factor for an identifier (see below), you can make the Unit attribute visible in all attribute forms by adding a unitless quantity to your model (i.e. a quantity with base unit 1).

Unit attribute value

In its simplest form, the unit definition of a parameter, variable or constraint is just a reference to a base or compound unit symbol. In general, it can be a unit expression based on the same syntax as described previously for specifying a derived unit expression in a Quantity declaration. The complete syntax of unit expressions is discussed in Unit Expressions.


The declaration

Variable VelocityOfItem
    IndexDomain  : i;
    Unit         : km/h;

introduces a variable VelocityOfItem(i) with a corresponding unit km/h. This declaration could also have been written as

Variable VelocityOfItem {
    IndexDomain  : i;
    Unit         : 1000*m/h;

which contains an explicit scale factor of 1000, instead of using the derived unit symbol km.

Units also for scaling

When you do not use unit symbols, you can still use the Unit attribute to indicate the appropriate scale factor to be used for an identifier. These scale factors, whether or not in the presence of unit symbols, will be used by AIMMS to scale the corresponding data during various computations, as explained in Unit-based Scaling.

Use of units

By specifying units for some or all the identifiers in your model, AIMMS will perform the following unit-related tasks for you:

The .Unit suffix

For all identifier types for which you can specify a Unit attribute, there is also an associated .Unit suffix. The value of the .Unit suffix is a unit expression that equals the unit specified within the Unit attribute of the identifier at hand.

Use of the .Unit suffix

The .Unit suffix is most commonly used in the following situations:

Indices not always required

If you want to reference the .Unit suffix of a multidimensional identifier, it is not always necessary to use the corresponding indices of the identifier in its .Unit suffix reference. The use of indices is only necessary if the Unit attribute actively depends on the indices, for instance, because it

  • contains a multidimensional scale factor, or

  • refers to a multidimensional unit parameter (see also Unit-valued Parameters).

In all other cases, a reference to just the identifier name is sufficient.


Consider the declaration of the variable VelocityOfItem(i) above. Its UNIT attribute is the constant unit km/h, whence it can be obtain through the (scalar) reference


Unit-valued parameters are permitted

When the Unit attribute of an identifier contains references to unit-valued parameters (see Unit-valued Parameters), such references will be evaluated, within the context of the .Unit suffix, to their corresponding unit expressions. Thus, the .Unit suffix will always result in a unit expression containing only unit symbols declared in one or more Quantity declarations.