/******************************************************** Xpress-BCL Java Example Problems ================================ file xbpurch.java ````````````````` Purchasing problem using SOS-2. (c) 2008-2024 Fair Isaac Corporation author: S.Heipcke, Jan. 2000, rev. Mar. 2011 ********************************************************/ /* WARNING. This model is not for the novice, but it does contain many * * useful ideas. * * The formulation is tricky because the discounts are all-quantity, * * so the graph of cost against quantity purchased is discontinuous. * * To maintain sanity in the special ordered set formulation, we must * * coarsen the discontinuity by stopping purchases just at the break * * point. */ import java.io.*; import com.dashoptimization.*; public class xbpurch { static final String PARAMSFILE = System.getProperty("XPRBDATA") + "/purchase/params.dat"; static final String MAXPERCFILE= System.getProperty("XPRBDATA") + "/purchase/maxperc.dat"; static final String REQFILE = System.getProperty("XPRBDATA") + "/purchase/required.dat"; static final String PRICEFILE = System.getProperty("XPRBDATA") + "/purchase/pricebk.dat"; /****TABLES****/ static int NS; /* Number of suppliers */ static int NB; /* Number of price breaks */ static int NB2; /* Useful parameter */ static double[][] UC; /* Unit cost */ static double[][] BR; /* Breakpoints (quantities at which unit cost changes) */ static double[][] X; /* Coarsened break points */ static double[][] C; /* Total cost at break points */ static double[] DELTA; /* Coarsening factors */ static double[] MAXPERC; /* Maximum percentage from each supplier */ static double REQ; /* Total quantity required */ static final double delta = 0,1; /* Base coarsening factor */ /***********************************************************************/ static void modPurchase() { XPRBexpr lobj, lc; XPRBexpr[] lr; int s,b; XPRBvar[] x; XPRBvar[][] lam; try (XPRBprob p = new XPRBprob("Purchase")) { /* Initialize BCL and create a new problem */ /****VARIABLES****/ x = new XPRBvar[NS]; /* Quantity to purchase from supplier s */ for(s=0;s