Initializing help system before first use

Purchase - Definition of SOS-2


Type: Purchasing with pricebreaks
Rating: 3
Description: A model for optimal purchasing with price-breaks featuring a complex MIP model, data input from file and using SOS-2.
File(s): xbpurch.java
Data file(s): params.dat, maxperc.dat, required.dat, pricebk.dat


xbpurch.java
/********************************************************
  Xpress-BCL Java Example Problems
  ================================

  file xbpurch.java
  `````````````````
  Purchasing problem using SOS-2.

  (c) 2008 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.10;   /* Base coarsening factor */

 static XPRB bcl;
 static XPRBprob p;
                    
/***********************************************************************/

 static void modPurchase()
 {
  XPRBexpr lobj, lc;
  XPRBexpr[] lr;
  int s,b;
  XPRBvar[] x;
  XPRBvar[][] lam; 

  bcl = new XPRB();             /* Initialize BCL */
  p = bcl.newProb("Purchase");  /* Create a new problem in BCL */
 
/****VARIABLES****/
  x = new XPRBvar[NS];          /* Quantity to purchase from supplier s */
  for(s=0;s