Initializing help system before first use

Variables

In BCL, variables are created one-by-one with a call to the function XPRBnewvar. These variables may belong to multi-dimensional arrays declared within C. Since one-dimensional arrays of variables are used as input to a number of functions, BCL also provides a specific object for this purpose, the type XPRBarrvar. This object stores a one-dimensional array of variables together with information about its size. That means such an array of variables may be used as a parameter to a function without having to specify its size separately. Details on specific functions for creating and accessing variable arrays are given in the following Section Variable arrays.

The length of variable names (like the names of all BCL objects) is unlimited. If no name is specified the system generates default names ("VAR" followed by an index). A name may occur repeatedly and, if so, BCL starts indexing the name, commencing with an index of 0.

All types of branching directives available in Xpress can be set via the function XPRBsetvardir, including priorities, choice of the preferred branching direction and definition of pseudo costs. Bounds on variables are redefined by functions XPRBsetub, XPRBsetlb, XPRBfixvar, and XPRBsetlim. Function XPRBsetlim only applies to partial integer, semi-continuous and semi-integer variables, setting the lower bound of the continuous part or the semi-integer lower bound. Function XPRBgetbyname retrieves variables or arrays of variables via their name. Information on variables can be accessed with function XPRBgetvarname, XPRBgetvartype, XPRBgetcolnum, XPRBgetbounds, and XPRBgetlim. Function XPRBsetvartype changes the variable type. Figure Functions for creation, update, deletion and access of variables within BCL gives an overview of functions related to the creation, update and deletion of variables and arrays of variables.

Creating variables
XPRBvar y, s[4];
y = XPRBnewvar(prob,XPRB_PL,"y",1,10);
for(i=0;i<4;i++)
s[i]=XPRBnewvar(prob,XPRB_UI,"st",1,10);
Creating variable arrays
XPRBarrvar av1, av2;
av1=XPRBnewarrvar(prob,5,XPRB_SC,"a1",0,7);
av2=XPRBstartarrvar(prob,3,"a2");
XPRBapparrvarel(av2,y);
XPRBsetarrvarel(av2,2,s[3]);
XPRBendarrvar(av2);
Accessing variables
double ubd, lbd, lim;
XPRBgetvarname(y);
XPRBgetvartype(s[1]);
XPRBgetcolnum(av2[0]);
XPRBgetbounds(y,&lbd,&ubd);
XPRBgetlim(y,&lim);
XPRBsetvartype(av1[1],XPRB_BV);
Accessing arrays
XPRBgetarrvarname(av2);
XPRBgetarrvarsize(av1);
Delete a variable array
XPRBdelarrvar(av2);
Find by name
XPRBvar y1; XPRBarrvar a1;
y1 = XPRBgetbyname(prob,"y",XPRB_VAR);
a1 = XPRBgetbyname(prob,"a1",XPRB_ARR);
Branching directives
XPRBsetvardir(s[0],PR,1);
XPRBcleardir(prob);
Setting bounds
XPRBsetlb(y,4);
XPRBsetub(s[0],9);
XPRBfixvar(av[2],6);
XPRBsetlim(y,5);

Figure 2.3: Functions for creation, update, deletion and access of variables within BCL

Variable arrays

BCL provides a specific object for representing one-dimensional arrays of variables, as these are used as input to a number of functions. Variable arrays can be created either in one go, with a single function call to XPRBnewarrvar, or incrementally by copying single references to previously defined variables into an array of type XPRBarrvar.

If a variable array is created by a call to XPRBnewarrvar, all of the variables in the array receive the same type and bounds (these can be modified individually following creation). Otherwise, if the array is being defined incrementally, any previously defined variables (including elements of variable arrays) may be added to the array in an arbitrary order. In this case, the definition of the array is started by indicating its model name and size in XPRBstartarrvar and terminated by XPRBendarrvar. Entries can be positioned via XPRBsetarrvarel or simply placed at the first available free position by XPRBapparrvarel. For instance, assume we have defined four continuous variables s[0],..., s[3] and a binary variable b. We may then wish to create an array av with the following three elements: av[0] = b, av[1] = s[2], av[2] = s[0]. Regrouping different variables this way into a single data structure may help render the formulation of constraints or the access to information about model objects more transparent.

A variable may be copied into several arrays (function XPRBsetarrvarel or XPRBapparrvarel), but it is created only once as a variable or part of a variable array (using function XPRBnewvar or XPRBnewarrvar).

Function XPRBgetbyname retrieves arrays of variables via their name. It is also possible to obtain the name of an array (XPRBgetarrvarname) and its size, that is, the number of variables it contains (XPRBgetarrvarsize).

Note:
all variables that are added to an array of variables must belong to the same problem as the array itself.

© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.