Initializing help system before first use

Output and printing

BCL provides printing functions for variables, constraints, Special Ordered Sets, and index sets (XPRBprintvar, XPRBprintarrvar, XPRBprintctr, XPRBprintsos, XPRBprintidxset, XPRBprintsol) as well as the entire model definition (XPRBprintprob). Any program output may be printed with XPRBprintf in a similar way to the C function printf. The output of all functions mentioned above is intercepted by the callback XPRBdefcbmsg if this function has previously been defined by the user.

It is also possible to output the problem to a file in extended LP format or as a matrix in extended MPS format (function XPRBexportprob). Note that unlike standard LP format, the extended LP format supports Special Ordered Sets and non-standard variable types (semi-continuous, semi-integer, or partial integers). Like the standard LP format it requires the sense of the objective function to be defined.

File output
XPRBexportprob(prob,XPRB_MPS,"expl2");
Print model objects
XPRBvar y;
XPRBprintvar(y);
XPRBarrvar av;
XPRBprintarrvar(av);
XPRBctr c;
XPRBprintctr(c);
XPRBsos s;
XPRBprintsos(s);
XPRBidxset is;
XPRBprintidxset(is);
XPRBsol sol;
XPRBprintsol(sol);
Print a given problem
XPRBprintprob(prob);
Print program output
XPRBprintf("Print this text");
Compose a name string
int i = 3;
XPRBnewname("abc%d",i);

Figure 3.3: File output and printing.

Example

We may now augment the last few lines of the model definition (cmodel or cmodel_array) of our example with some output functions. Note that these output functions may be added at any time to print the current problem definition in BCL. The function XPRBprintprob prints the complete BCL problem definition to the standard output. The function XPRBexportprob writes the problem definition in LP format or as a matrix in extended MPS format to the indicated file.

XPRBprintprob(prob);         /* Print out the problem definition */
XPRBexportprob(prob,XPRB_MPS,"expl1");
                             /* Output matrix to MPS file */

Instead of printing the entire problem with function XPRBprintprob, it is also possible to display single variables or constraints as soon as they have been defined. The following modified extract of the model definition may serve as an example.

#include <stdio.h>
#include "xprb.h"

#define NJ    4              /* Number of jobs */
#define NT   10              /* Time limit */

double DUR[] = {3,4,2,2};    /* Durations of jobs   */
XPRBvar start[NJ];           /* Start times of jobs  */
XPRBprob prob;               /* BCL problem */
...
void cmodel(void)
{
 XPRBctr ctr;
 int j,t;

 prob=XPRBnewprob("Jobs");   /* Initialization */

 for(j=0;j<NJ;j++)           /* Create start time variables */
 {
  start[j] = XPRBnewvar(prob,XPRB_PL,"start",0,NT);
  XPRBprintvar(start[j]);
  XPRBprintf(", ");
 }
 ...
                             /* Precedence relation betw. jobs */
 ctr = XPRBnewprec(prob,"Prec",start[0],DUR[0],start[2]);
 XPRBprintctr(ctr);
 ...
}