/******************************************************** BCL Example Problems ==================== file xbdlvriis2iso.c ```````````````````` Transportation problem (infeasible data). Retrieving and printing IIS. - Using Optimizer functions to retrieve detailed IIS information including isolation rows/bounds - (c) 2008 Fair Isaac Corporation author: S.Heipcke, Jan. 2008, rev. Mar. 2011 ********************************************************/ #include #include #include #include "xprb.h" #include "xprs.h" #define NSupp 10 /* Number of suppliers */ #define NCust 7 /* Number of customers */ #define MaxArcs 100 /* Max. num. of non-zero cost values */ #define VANFILE XPRBDATAPATH "/delivery/ifvan.dat" /* Van data file */ #define COSTFILE XPRBDATAPATH "/delivery/cost.dat" /* Cost data file */ /****DATA****/ /* Supplier: London Luton B'ham Bristl Derby Stckpt York */ double SUPPLY[] = {140.0, 200.0, 50.0, 10.0, 400.0, 200.0, 20.0, /* Supplier: Derby Soton Scnthp */ 90.0, 30.0, 12}; /* Customer: London Livpol Doncst York Hull Manchr Shffld */ double DEMAND[] = {1230.3, 560.4, 117.1, 592.8, 310.0, 1247.0, 86}; double COST[NSupp][NCust]; /* Cost per supplier-customer pair */ double IFVAN[NSupp][NCust]; /* Non-zero if route uses vans instead of lorries */ double VANCAP=40; /* Capacity on routes that use vans */ /***********************************************************************/ void moddelivery(XPRBprob prob) { XPRBctr ctr, CSupply[NSupp], CDemand[NCust]; int s,c,i; XPRBvar x[NSupp][NCust]; int numv, numc, numiis, len, ncol, nrow, namelength; double bnd, rhs; char *vnames, *cnames; int *viis,*ciis; char **vindex,**cindex; char *ctrtype = NULL; char *bndtype = NULL; double *duals = NULL; double *rdcs = NULL; char *isolationrows = NULL; char *isolationbnds = NULL; char *isotype[] = {"N/A", "No ", "Yes"}; XPRSprob op; /****VARIABLES****/ for(s=0;snamelength) namelength=strlen(vindex[i]); /* Retrieve constraint names */ XPRSgetintattrib(op, XPRS_ORIGINALROWS, &nrow); XPRSgetnamelist(op, 1, NULL, 0, &len, 0, nrow-1); cnames = (char *)malloc(len * sizeof(char)); cindex = (char **)malloc(nrow * sizeof(char *)); XPRSgetnamelist(op, 1, cnames, len, NULL, 0, nrow-1); cindex[0]=cnames; for(i=1; inamelength) namelength=strlen(cindex[i]); /**** Retrieve detailed IIS info (incl. isolations) ****/ for(s=1;s<=numiis;s++) { XPRSgetiisdata(op, s, &numc, &numv, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); XPRSiisisolations(op, s); /* Find isolations */ ciis = (int *)malloc(numc * sizeof(int)); viis = (int *)malloc(numv * sizeof(int)); ctrtype = (char *)malloc(numc*sizeof(char)); bndtype = (char *)malloc(numv*sizeof(char)); duals = (double *)malloc(numc*sizeof(double)); rdcs = (double *)malloc(numv*sizeof(double)); isolationrows = (char *)malloc(numc*sizeof(char)); isolationbnds = (char *)malloc(numv*sizeof(char)); XPRSgetiisdata(op, s, &numc, &numv, ciis, viis, ctrtype, bndtype, duals, rdcs, isolationrows, isolationbnds); printf("IIS %d: %d variables, %d constraints\n", s, numv, numc); printf(" %-*s Type Sense Bound Dual values In iso. \n", namelength, "Name"); if (numv>0) { /* Print all variables in the IIS */ for(i=0;i0) { /* Print all constraints in the IIS */ for(i=0;i