/******************************************************** BCL Example Problems ==================== file xbmt2.c ```````````` Implementing multiple threads with BCL and Xpress-Optimizer. Win32 version (c) 2008 Fair Isaac Corporation author: Y. Colombani, 2001, rev. Mar. 2011 ********************************************************/ #include #include #include #include "xprb.h" #include "xprs.h" /* Constants for contr1() */ #define District 6 /* Number of districts */ #define Contract 10 /* Number of contracts */ const int OUTPUT[] = {50, 40, 10, 20, 70, 50}; /* Max. output per district */ const int COST[] = {50, 20, 25, 30, 45, 40}; /* Cost per district */ const int VOLUME[] = {20, 10, 30, 15, 20, 30, 10, 50, 10, 20}; /* Volume of contracts */ /* Constants for portf() */ #define NVal 30 /* Total number of values */ #define LIMIT 20 /* Maximum number to be chosen */ #define QFILE XPRBDATAPATH "/portf/pfqcost.dat" /* Quadratic cost coeff.s */ #define BFILE XPRBDATAPATH "/portf/pfubds.dat" /* Upper bounds on percentages */ #define CFILE XPRBDATAPATH "/portf/pflcost.dat" /* Linear cost coefficients */ /* The problems to solve */ DWORD WINAPI contr1(LPVOID param); DWORD WINAPI portf(LPVOID param); /**********************/ /* Where things start */ /**********************/ int main(int argc,char *argv[]) { HANDLE tosolve1, tosolve2; XPRBprob modcontr1, modfolio; /* Initialize BCL and create two problems (separate initialization of BCL only for clarity's sake, it could as well be left to be done during the creation of the first problem) */ XPRBinit(); modcontr1=XPRBnewprob("Contr1"); modfolio=XPRBnewprob("Folio"); /* Start the building+solving in parallel */ tosolve1=CreateThread(NULL, 0, contr1, modcontr1,0,0); tosolve2=CreateThread(NULL, 0, portf, modfolio ,0,0); /* Wait for results */ WaitForSingleObject(tosolve1, INFINITE); WaitForSingleObject(tosolve2, INFINITE); /* Clear up everything (not really required here since the program terminates immediately afterwards) */ XPRBdelprob(modcontr1); XPRBdelprob(modfolio); XPRBfinish(); return 0; } /*********************/ /* Problem 'contr1' */ /*********************/ DWORD WINAPI contr1(LPVOID param) { int d,c; XPRBprob bprob; XPRSprob oprob; XPRBctr c1,c2,cobj; XPRBvar x[District][Contract]; /* Variables indicating whether a project is chosen */ XPRBvar y[District][Contract]; /* Quantities allocated to contractors */ int i, ncol, len, stat, offset; double *sol, val; char *names; bprob=(XPRBprob)param; /**** VARIABLES ****/ for(d=0;d