Function cp::ActivitySize(optionalActivity, absentValue)


The function cp::ActivitySize(a,d) returns the size of activity \(a\) when it is present or default value \(d\) when it is absent.

Mathematical Formulation

The function cp::ActivitySize(a,d) is equivalent to

\[\begin{split}\left\{ \begin{array}{ll} a.\texttt{size} & \textrm{if } a.\texttt{present} \\ d & \textrm{otherwise } \end{array} \right.\end{split}\]

This function is typically used in scheduling problems to link activities to other components of the problem.

        optionalActivity,   ! (input) an expression
        absentValue         ! (input) an expression



An expression resulting in an activity. This activity may have the property optional.


An expression that results in the value used when activity optionalActivity is absent. This expression cannot involve variables.

Return Value

This function returns the size of an activity when that activity is present or a specified default value when it is not.


In the example below, we require that the size of the shift represented by element variable evShift matches the size of the optional activity myAct.

Constraint linkShiftActivity {
    Definition :  cp::ActivitySize( myAct, 3) =, shiftSize(evShift);

See also

The functions cp::Count and cp::ActivityBegin.