/******************************************************** BCL Example Problems ==================== file xbdlvriis2rep.c ```````````````````` Transportation problem (infeasible data). Repairing infeasibility. - Using Optimizer functions - (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 */ void printsolution(XPRBprob prob, int scode, XPRBvar x[][NCust]); void printsolution2(XPRSprob op, int scode, XPRBvar x[][NCust]); /****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; XPRBvar x[NSupp][NCust]; int ncol, nrow, scode; double *lrp, *grp, *lbp, *ubp; XPRSprob op; /****VARIABLES****/ for(s=0;s= rows) ax + aux_var = b ax + aux_var >= b lbp: x_i + aux_var >= l ubp: x_i - aux_var <= u */ /**** Simplified infeasibility repair: specifying preferences per constraint/bound type ****/ printf("\n**** Repair infeasibility:\n"); XPRSrepairinfeas(op, &scode, 'c', 'o', ' ', 10, 9, 0, 20, 0,001); printsolution2(op, scode, x); /* Print out the solution values */ /**** Weighted infeasibility repair: specifying preferences for every constraint/bound separately ****/ XPRSgetintattrib(op, XPRS_ORIGINALCOLS, &ncol); XPRSgetintattrib(op, XPRS_ORIGINALROWS, &nrow); lrp = (double *)malloc(nrow*sizeof(double)); grp = (double *)malloc(nrow*sizeof(double)); lbp = (double *)malloc(ncol*sizeof(double)); ubp = (double *)malloc(ncol*sizeof(double)); memset(lrp, 0, nrow*sizeof(double)); memset(grp, 0, nrow*sizeof(double)); memset(lbp, 0, ncol*sizeof(double)); memset(ubp, 0, ncol*sizeof(double)); /* Relax bounds due to van capacity */ /* Repairweightedinfeas for upper bounds of concerned flow variables */ for(s=0; s0,01) printf("%s:%g ", XPRBgetvarname(x[s][c]), XPRBgetsol(x[s][c])); printf("\n"); printf("Violations:\n"); for(c=0; cSUPPLY[s]) printf(" Supplier %d: %g\n", s, dem-SUPPLY[s]); } for(s=0; s=0 && sol[XPRBgetcolnum(x[s][c])]>0,01) printf("%s:%g ", XPRBgetvarname(x[s][c]), sol[XPRBgetcolnum(x[s][c])]); printf("\n"); printf("Violations:\n"); for(c=0; c=0) sup+=sol[XPRBgetcolnum(x[s][c])]; if(sup=0) dem+=sol[XPRBgetcolnum(x[s][c])]; if(dem>SUPPLY[s]) printf(" Supplier %d: %g\n", s, dem-SUPPLY[s]); } for(s=0; s=0 && VANCAP