Bounded Variables
Whereas @FREE sets the upper and lower bounds of the specified variable to plus and minus infinity (effectively removing any bounds on the variable), the @BND function lets you set specific upper and lower bounds on a variable. In other words, @BND limits a variable's range within some specified interval. The syntax for @BND is:
@BND( lower_bound, variable_name, upper_bound);
where variable_name is the variable to be bounded below by the quantity lower_bound and bounded above by the quantity upper_bound. Both lower_bound and upper_bound must be either numeric values or variables whose values have been set in a data section or calc section. @BND may be used wherever you would normally enter a constraint in a model—including inside an @FOR looping function.
In mathematical terms, LINGO interprets this @BND function as:
lower_bound ≤ variable_name ≤ upper_bound
It is certainly possible to add constraints in lieu of the @BND function, but, from the standpoint of the optimizer, @BND is an extremely efficient way of representing simple bounds on variables. Specifying variable bounds using @BND rather than explicitly adding constraints can noticeably speed up the solution times for larger models. Furthermore, @BND does not count against the limit on the total number of constraints LINGO imposes on some versions. So, in general, it is a good idea to use @BND in place of constraints whenever possible.
Some examples of @BND are:
Example 1: @BND( -1, X, 1);
constrains the variable X to lie in the interval [-1,1],
Example 2: @BND( 100, QUANTITY( 4), 200);
constrains the variable QUANTITY( 4) to fall within 100 to 200,
Example 3: @FOR( ITEMS: @BND( 10, Q, 20));
sets the bounds on all variables in the Q attribute to 10 and 20,
Example 4: @FOR( ITEMS: @BND( QL, Q, QU));
sets the bounds on all variables in the Q attribute to QL and QU (QL and QU must have been previously set to some values in a data section).