/******************************************************** Xpress-BCL Java Example Problems ================================ file xbdlvriis2rep.java ``````````````````````` Transportation problem (infeasible data). Repairing infeasibility. - Using Optimizer functions - (c) 2008-2023 Fair Isaac Corporation author: S.Heipcke, Jan. 2008, rev. Mar. 2011 ********************************************************/ import java.io.*; import java.util.*; import java.text.DecimalFormat; import com.dashoptimization.*; public class xbdlvriis2rep { static final int NSupp = 10; /* Number of suppliers */ static final int NCust = 7; /* Number of customers */ static final int MaxArcs = 100; /* Max. num. of non-zero cost values */ static final String VANFILE = System.getProperty("XPRBDATA") + "/delivery/ifvan.dat"; static final String COSTFILE = System.getProperty("XPRBDATA") + "/delivery/cost.dat"; /****DATA****/ /* Supplier: London Luton B'ham Bristl Derby Stckpt */ static final double SUPPLY[] = {140.0, 200.0, 50.0, 10.0, 400.0, 200.0, /* Supplier: York Derby Soton Scnthp */ 20.0, 90.0, 30.0, 12}; /* Customer: London Livpol Doncst York Hull Manchr */ static final double DEMAND[] = {1230.3, 560.4, 117.1, 592.8, 310.0, 1247.0, /* Customer: Shffld */ 86}; static double[][] COST; /* Cost per supplier-customer pair */ static double[][] IFVAN; /* Non-zero if route uses vans instead of lorries */ static final double VANCAP=40; /* Capacity on routes that use vans */ static XPRSprob op; /***********************************************************************/ static void modDelivery() { XPRBexpr lobj, lc; int s,c,i; XPRBvar[][] x; XPRBctr[] CSupply, CDemand; int nrow, ncol; IntHolder iscode; double[] lrp, grp, lbp, ubp; try (XPRBprob p = new XPRBprob("Delivery"); /* Initialize BCL and create a new problem */ XPRS xprs = new XPRS()) { /* Initialize Xpress-Optimizer */ /****VARIABLES****/ x = new XPRBvar[NSupp][NCust]; 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 ****/ System.out.println("\n**** Repair infeasibility:"); iscode = new IntHolder(); op.repairInfeas(iscode, 'c', 'o', ' ', 10, 9, 0, 20, 0,001); printSolution(p, iscode.value, x); /**** Weighted infeasibility repair: specifying preferences for every constraint/bound separately ****/ ncol=op.getIntAttrib(XPRS.ORIGINALCOLS); nrow=op.getIntAttrib(XPRS.ORIGINALROWS); lrp = new double[nrow]; grp = new double[nrow]; lbp = new double[ncol]; ubp = new double[ncol]; /* Relax bounds due to van capacity */ /* Repairweightedinfeas for upper bounds of concerned flow variables */ for(s=0; s0,01) System.out.print(x[s][c].getName()+ ":" + x[s][c].getSol() + " "); System.out.println(); System.out.println("Violations:"); for(c=0; cSUPPLY[s]) System.out.println(" Supplier " + s + ": " + (dem-SUPPLY[s]) ); } for(s=0; s=0 && sol[x[s][c].getColNum()]>0,01) System.out.print(x[s][c].getName()+ ":" + sol[x[s][c].getColNum()] + " "); System.out.println(); System.out.println("Violations:"); for(c=0; c=0) sup+=sol[x[s][c].getColNum()]; if(sup=0) dem+=sol[x[s][c].getColNum()]; if(dem>SUPPLY[s]) System.out.println(" Supplier " + s + ": " + (dem-SUPPLY[s]) ); } for(s=0; s=0 && VANCAP