Labeling constraints

Shows how to label constraints in OPL.

Type the character string you want, followed by the colon (:) sign, before the constraint you want to label, as shown in Labelling constraints (production.mod). If you used to declare constraint names in your existing OPL models, see Compatibility between constraint names and labels.
Note:

A constraint label or name cannot start with a number.

Labeling constraints (production.mod)

minimize
  sum( p in Products ) 
    ( InsideCost[p] * Inside[p] + OutsideCost[p] * Outside[p] );
   
subject to {
  forall( r in Resources )
    ctCapacity: 
      sum( p in Products ) 
        Consumption[p][r] * Inside[p] <= Capacity[r];

  forall(p in Products)
    ctDemand:
      Inside[p] + Outside[p] >= Demand[p];
}

This is equivalent to Stating constraints by means of an optimization instruction. The only difference is that the constraint on the production capacity has been labeled


ctCapacity:

and the constraint on the demand of products has been labeled


ctDemand:

These labels can be used to display the data.