/******************************************************** Xpress-BCL Java Example Problems ================================ file xbcutstk.java `````````````````` Cutting stock problem, solved by column (= cutting pattern) generation heuristic looping over the root node. (c) 2008-2024 Fair Isaac Corporation author: S.Heipcke, 2001, rev. Mar. 2014 ********************************************************/ import java.lang.*; import com.dashoptimization.*; public class xbcutstk { static final int NWIDTHS = 5; static final int MAXWIDTH = 94; static final double EPS = 1e-6; static final int MAXCOL = 10; /****DATA****/ static final double[] WIDTH = {17, 21, 22.5, 24, 29,5}; /* Possible widths */ static final int[] DEMAND = {150, 96, 48, 108, 227}; /* Demand per width */ static int[][] PATTERNS; /* (Basic) cutting patterns */ static XPRBvar[] pat; /* Rolls per pattern */ static XPRBctr[] dem; /* Demand constraints */ static XPRBctr cobj; /* Objective function */ /***********************************************************************/ static void modCutStock(XPRBprob p) throws XPRSexception { int i,j; XPRBexpr le; PATTERNS = new int[NWIDTHS][NWIDTHS]; for(j=0;j EPS) { dem[i].add(pat[npatt].mul(x[i])); if((int)Math.ceil((double)DEMAND[i]/x[i]) > dw) dw = (int)Math.ceil((double)DEMAND[i]/x[i]); } pat[npatt].setUB(dw); /* Change the upper bound on the new var.*/ npatt++; p.loadMat(); /* Reload the problem */ p.loadBasis(basis); /* Load the saved basis */ basis=null; /* No need to keep the basis any longer */ } } p.mipOptimize(""); /* Solve the MIP */ System.out.println("(" + (XPRB.getTime()-starttime)/1.000 + " sec) Optimal solution: " + p.getObjVal() + " rolls, " + npatt + " patterns"); System.out.print(" Rolls per pattern: "); for(i=0;i