/******************************************************** Xpress-BCL Java Example Problems ================================ file xbelsc.java ```````````````` Economic lot sizing, ELS, problem, solved by adding (l,S)-inequalities) in a branch-and-cut heuristic (using the cut manager). ELS considers production planning over a horizon of T periods. In period t, t=1,...,T, there is a given demand DEMAND[t] that must be satisfied by production prod[t] in period t and by inventory carried over from previous periods. There is a set-up up cost SETUPCOST[t] associated with production in period t. The unit production cost in period t is PRODCOST[t]. There is no inventory or stock-holding cost. *** This model cannot be run with a Community Licence *** (c) 2008 Fair Isaac Corporation author: S.Heipcke, 2005, rev. Mar. 2011 ********************************************************/ import java.util.*; import com.dashoptimization.*; public class xbelsc { static final double EPS = 1e-6; static final int T = 6; /* Number of time periods */ /****DATA****/ static final int[] DEMAND = { 1, 3, 5, 3, 4, 2}; /* Demand per period */ static final int[] SETUPCOST = {17,16,11, 6, 9, 6}; /* Setup cost / period */ static final int[] PRODCOST = { 5, 3, 2, 1, 3, 1}; /* Prod. cost / period */ static int[][] D; /* Total demand in periods t1 - t2 */ static XPRBvar[] prod; /* Production in period t */ static XPRBvar[] setup; /* Setup in period t */ static class myobj { XPRBprob prob; double tol; }; /**************************************************************************/ /* Cut generation algorithm: */ /* get the solution values */ /* identify and set up violated constraints */ /* add cuts to the problem */ /**************************************************************************/ static class CutMgrCallback implements XPRScutMgrListener { public int XPRScutMgrEvent(XPRSprob oprob, Object data) { int t,l; boolean res; int ncut; /* Counter for cuts */ double[] solprod, solsetup; /* Solution values for var.s prod & setup */ double ds; XPRBexpr le; ArrayList cutlist; XPRBcut[] cuts; myobj mo; mo = (myobj)data; ncut = 0; cutlist = new ArrayList(); try { /* Get the solution values */ mo.prob.beginCB(oprob); mo.prob.sync(XPRB.XPRS_SOL); solprod = new double[T]; solsetup = new double[T]; for(t=0;t= D[0][l] */ if(ds < D[0][l] - mo.tol) { le = new XPRBexpr(); for(t=0;t<=l;t++) { if (solprod[t] < D[t][l]*solsetup[t] + mo.tol) le .add(prod[t]); else le .add(setup[t].mul(D[t][l])); } cutlist.add( mo.prob.newCut(le.gEql(D[0][l])) ); ncut++; } } /* Add cuts to the problem */ if(ncut>0) { cuts = new XPRBcut[ncut]; for(t=0;t