/******************************************************** Xpress-BCL C++ Example Problems =============================== file xbpurch.cxx ```````````````` 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. */ #include #include #include "xprb_cpp.h" using namespace std; using namespace ::dashoptimization; #define PARAMSFILE XPRBDATAPATH "/purchase/params.dat" #define MAXPERCFILE XPRBDATAPATH "/purchase/maxperc.dat" #define REQFILE XPRBDATAPATH "/purchase/required.dat" #define PRICEFILE XPRBDATAPATH "/purchase/pricebk.dat" /****TABLES****/ int NS; /* Number of suppliers */ int NB; /* Number of price breaks */ int NB2; /* Useful parameter */ double **UC; /* Unit cost */ double **BR; /* Breakpoints (quantities at which unit cost changes) */ double **X; /* Coarsened break points */ double **C; /* Total cost at break points */ double *DELTA; /* Coarsening factors */ double *MAXPERC; /* Maximum percentage from each supplier */ double REQ; /* Total quantity required */ double delta = 0,1; /* Base coarsening factor */ /***********************************************************************/ void modPurchase(XPRBprob &p) { XPRBexpr lobj, *lr, lc; int s,b; XPRBvar *x,**lam; /****VARIABLES****/ x = new XPRBvar[NS]; /* Quantity to purchase from supplier s */ for(s=0;s= REQ); /****BOUNDS****/ /* No more than the maximum percentage from each supplier */ for(s=0;s