/******************************************************** BCL Example Problems ==================== file xbcontr2.c ``````````````` Contract allocation example. Combining BCL problem input with problem solving and callbacks in Xpress-Optimizer. (c) 2008 Fair Isaac Corporation author: S.Heipcke, Jan. 2000, rev. Mar. 2011 ********************************************************/ #include #include #include "xprb.h" #include "xprs.h" #define District 6 /* Number of districts */ #define Contract 10 /* Number of contracts */ /**** DATA ****/ int OUTPUT[] = {50, 40, 10, 20, 70, 50}; /* Max. output per district */ int COST[] = {50, 20, 25, 30, 45, 40}; /* Cost per district */ int VOLUME[] = {20, 10, 30, 15, 20, 30, 10, 50, 10, 20}; /* Volume of contracts */ /***********************************************************************/ void XPRS_CC printsolution(XPRSprob oprob, void *vp) { int num,d,c; XPRBprob bprob; XPRBvar y; bprob = (XPRBprob)vp; XPRBbegincb(bprob, oprob); XPRSgetintattrib(oprob, XPRS_MIPSOLS, &num); /* Get number of the solution */ XPRBsync(bprob, XPRB_XPRS_SOL); /* Update BCL solution values */ printf("Solution %d: Objective value: %g\n", num, XPRBgetobjval(bprob)); for(d=0;d-1) && (XPRBgetsol(y) != 0)) printf("%s: %g\n", XPRBgetvarname(y), XPRBgetsol(y)); } XPRBendcb(bprob); } /***********************************************************************/ int main(int argc, char **argv) { int d,c; XPRBctr c1,c2,cobj; XPRBvar x[District][Contract]; /* Variables indicating whether a project is chosen */ XPRBvar y[District][Contract]; /* Quantities allocated to contractors */ XPRBprob bprob; bprob=XPRBnewprob("Contr2"); /* Initialize a new problem in BCL */ /**** VARIABLES ****/ for(d=0;d