| /********************************************************
  Xpress-BCL C++ Example Problems
  ===============================
  file xbdelvr.cxx
  `````````````````
  Transportation problem.
  (c) 2008 Fair Isaac Corporation
      author: S.Heipcke, Jan. 2000, rev. Mar. 2011
********************************************************/
#include 
#include 
#include "xprb_cpp.h"
using namespace std;
using namespace ::dashoptimization;
#define NSupp 10                  /* Number of suppliers */
#define NCust 7                   /* Number of customers */
#define MaxArcs 100               /* Max. num. of non-zero cost values */
#define VANFILE XPRBDATAPATH "/delivery/ifvan.dat"    /* Van data file */
#define COSTFILE XPRBDATAPATH "/delivery/cost.dat"    /* Cost data file */
/****DATA****/
/* Supplier:      London  Luton  B'ham Bristl  Derby Stckpt   York */
double SUPPLY[] = {140.0, 600.0,  50.0,  10.0, 400.0, 200.0,  20.0,
/* Supplier: Derby  Soton Scnthp */
             90.0,  30.0,  12.0};
/* Customer:      London Livpol Doncst   York   Hull Manchr Shffld */
double DEMAND[] = {123.3,  56.4,  17.1, 192.8, 310.0,  47.0,  86.0};
double COST[NSupp][NCust];        /* Cost per supplier-customer pair */
double IFVAN[NSupp][NCust];       /* Non-zero if route uses vans instead 
                                     of lorries */
double VANCAP=40.0;               /* Capacity on routes that use vans */
XPRBprob p("Delivery");           /* Initialize a new problem in BCL */
/***********************************************************************/
void modDelivery()
{
 XPRBexpr lobj, lc;
 int s,c;
 XPRBvar x[NSupp][NCust];
 
/****VARIABLES****/
 for(s=0;s= DEMAND[c]);
 }
        
 for(s=0;s | 
| /********************************************************
  Xpress-BCL C++ Example Problems
  ===============================
  file xbdlvriis.cxx
  ``````````````````
  Transportation problem (infeasible data).
  Retrieving and printing IIS.
  (c) 2008 Fair Isaac Corporation
      author: S.Heipcke, 2005, rev. Mar. 2011
********************************************************/
#include 
#include 
#include 
#include "xprb_cpp.h"
#include "xprs.h"
using namespace std;
using namespace ::dashoptimization;
#define NSupp 10                  // Number of suppliers
#define NCust 7                   // Number of customers
#define MaxArcs 100               // Max. num. of non-zero cost values
#define VANFILE XPRBDATAPATH "/delivery/ifvan.dat"    // Van data file
#define COSTFILE XPRBDATAPATH "/delivery/cost.dat"    // Cost data file
/****DATA****/
// Supplier:      London  Luton  B'ham Bristl  Derby Stckpt   York
double SUPPLY[] = {140.0, 200.0,  50.0,  10.0, 400.0, 200.0,  20.0,
// Supplier:       Derby  Soton Scnthp
                   90.0,  30.0,  12.0};
// Customer:       London Livpol Doncst   York   Hull  Manchr Shffld
double DEMAND[] = {1230.3, 560.4, 117.1, 592.8, 310.0, 1247.0,  86.0};
double COST[NSupp][NCust];        // Cost per supplier-customer pair
double IFVAN[NSupp][NCust];       // Non-zero if route uses vans instead 
                                  // of lorries
double VANCAP=40.0;               // Capacity on routes that use vans
XPRBprob p("Delivery");           // Initialize a new problem in BCL
/***********************************************************************/
void modDelivery()
{
 XPRBexpr lobj, lc;
 int s,c,i;
 XPRBvar x[NSupp][NCust];
 int numv, numc, numiis, len, ncol, nrow, scode, ct;
 char *vnames, *cnames;
 int *viis,*ciis,*vsizes,*csizes;
 char **vindex,**cindex;
 double *suminfeas = NULL;
 XPRSprob op;
  
/****VARIABLES****/
 for(s=0;s= DEMAND[c]);
 }
 for(c=4; c= DEMAND[c]);
 }
        
 for(s=0;s<5;s++)                 // Keep within supply at each supplier
 {
  lc=0;
  for(c=0; c<4; c++)  lc+= x[s][c];
  p.newCtr("Supply", lc <= SUPPLY[s]);
 }          
 for(s=5;s0)
   {
    cout << "  Variables: ";      // Print all variables in the IIS
    for(i=0;i0)
   {
    cout << "  Constraints: ";    // Print all constraints in the IIS
    for(i=0;i | 
| /********************************************************
  Xpress-BCL C++ Example Problems
  ===============================
  file xbdlvriis2iso.cxx
  ``````````````````````
  Transportation problem (infeasible data).
  Retrieving and printing IIS.
  - Using Optimizer functions to retrieve detailed
    IIS information including isolation rows/bounds -
  (c) 2008 Fair Isaac Corporation
      author: S.Heipcke, Jan. 2008, rev. Mar. 2011
********************************************************/
#include 
#include 
#include 
#include "xprb_cpp.h"
#include "xprs.h"
using namespace std;
using namespace ::dashoptimization;
#define NSupp 10                  // Number of suppliers
#define NCust 7                   // Number of customers
#define MaxArcs 100               // Max. num. of non-zero cost values
#define VANFILE XPRBDATAPATH "/delivery/ifvan.dat"    // Van data file
#define COSTFILE XPRBDATAPATH "/delivery/cost.dat"    // Cost data file
/****DATA****/
// Supplier:      London  Luton  B'ham Bristl  Derby Stckpt   York
double SUPPLY[] = {140.0, 200.0,  50.0,  10.0, 400.0, 200.0,  20.0,
// Supplier:       Derby  Soton Scnthp
                   90.0,  30.0,  12.0};
// Customer:       London Livpol Doncst   York   Hull  Manchr Shffld
double DEMAND[] = {1230.3, 560.4, 117.1, 592.8, 310.0, 1247.0,  86.0};
double COST[NSupp][NCust];        // Cost per supplier-customer pair
double IFVAN[NSupp][NCust];       // Non-zero if route uses vans instead 
                                  // of lorries
double VANCAP=40.0;               // Capacity on routes that use vans
XPRBprob p("Delivery");           // Initialize a new problem in BCL
/***********************************************************************/
void modDelivery()
{
 XPRBexpr lobj, lc;
 int s,c,i;
 XPRBvar x[NSupp][NCust];
 int numv, numc, numiis, len, ncol, nrow;
 char *vnames, *cnames;
 int *viis,*ciis;
 char **vindex,**cindex;
 double bnd, rhs;
 char *ctrtype = NULL;
 char *bndtype = NULL;
 double *duals = NULL;
 double *rdcs = NULL;
 char *isolationrows = NULL;
 char *isolationbnds = NULL;
 const char *isotype[] = {"N/A", "No ", "Yes"};
 XPRSprob op;
  
/****VARIABLES****/
 for(s=0;s= DEMAND[c]);
 }
 for(c=4; c= DEMAND[c]);
 }
        
 for(s=0;s<5;s++)                 // Keep within supply at each supplier
 {
  lc=0;
  for(c=0; c<4; c++)  lc+= x[s][c];
  p.newCtr("Supply", lc <= SUPPLY[s]);
 }          
 for(s=5;s0)
   {                              // Print all variables in the IIS
    for(i=0;i0)
   {                              // Print all constraints in the IIS
    for(i=0;i | 
| /********************************************************
  Xpress-BCL C++ Example Problems
  ===============================
  file xbdlvriis2rep.cxx
  ``````````````````````
  Transportation problem (infeasible data).
  Repairing infeasibility.
  - Using Optimizer functions -
  (c) 2008 Fair Isaac Corporation
      author: S.Heipcke, Jan. 2008, rev. Mar. 2011
********************************************************/
#include 
#include 
#include 
#include "xprb_cpp.h"
#include "xprs.h"
using namespace std;
using namespace ::dashoptimization;
#define NSupp 10                  // Number of suppliers
#define NCust 7                   // Number of customers
#define MaxArcs 100               // Max. num. of non-zero cost values
#define VANFILE XPRBDATAPATH "/delivery/ifvan.dat"    // Van data file
#define COSTFILE XPRBDATAPATH "/delivery/cost.dat"    // Cost data file
void printsolution(int scode, XPRBvar x[][NCust]);
void printsolution2(XPRSprob op, int scode, XPRBvar x[][NCust]);
/****DATA****/
// Supplier:      London  Luton  B'ham Bristl  Derby Stckpt   York
double SUPPLY[] = {140.0, 200.0,  50.0,  10.0, 400.0, 200.0,  20.0,
// Supplier:       Derby  Soton Scnthp
                   90.0,  30.0,  12.0};
// Customer:       London Livpol Doncst   York   Hull  Manchr Shffld
double DEMAND[] = {1230.3, 560.4, 117.1, 592.8, 310.0, 1247.0,  86.0};
double COST[NSupp][NCust];        // Cost per supplier-customer pair
double IFVAN[NSupp][NCust];       // Non-zero if route uses vans instead 
                                  // of lorries
double VANCAP=40.0;               // Capacity on routes that use vans
XPRBprob p("Delivery");           // Initialize a new problem in BCL
/***********************************************************************/
void modDelivery()
{
 XPRBexpr lobj, lc;
 XPRBctr ctr, CSupply[NSupp], CDemand[NCust];
 int s,c;
 XPRBvar x[NSupp][NCust];
 int ncol, nrow, scode;
 double *lrp, *grp, *lbp, *ubp;
 XPRSprob op;
  
/****VARIABLES****/
 for(s=0;s= DEMAND[c]);
 }
 for(c=4; c= DEMAND[c]);
 }
        
 for(s=0;s<5;s++)                 // Keep within supply at each supplier
 {
  lc=0;
  for(c=0; c<4; c++)  lc+= x[s][c];
  CSupply[s] = p.newCtr("Supply", lc <= SUPPLY[s]);
 }          
 for(s=5;s= rows)
   ax + aux_var  = b 
   ax + aux_var >= b
lbp:
   x_i + aux_var >= l
ubp:
   x_i - aux_var <= u 
*/
/**** Simplified infeasibility repair:
      specifying preferences per constraint/bound type ****/
  cout << "\n**** Repair infeasibility:" << endl;
  XPRSrepairinfeas(op, &scode, 'c', 'o', ' ', 10, 9, 0, 20, 0.001);
  printsolution2(op, scode, x);         /* Print out the solution values */
/**** Weighted infeasibility repair:
      specifying preferences for every constraint/bound separately ****/
  XPRSgetintattrib(op, XPRS_ORIGINALCOLS, &ncol); 
  XPRSgetintattrib(op, XPRS_ORIGINALROWS, &nrow); 
  lrp = new double[nrow]; 
  grp = new double[nrow]; 
  lbp = new double[ncol]; 
  ubp = new double[ncol]; 
  memset(lrp, 0, nrow*sizeof(double));
  memset(grp, 0, nrow*sizeof(double));
  memset(lbp, 0, ncol*sizeof(double));
  memset(ubp, 0, ncol*sizeof(double));
/* Relax bounds due to van capacity */
/* Repairweightedinfeas for upper bounds of concerned flow variables */
  for(s=0; s0.01)
     cout << x[s][c].getName() << ":" << x[s][c].getSol() << " ";
  cout << endl;    
  cout << "Violations:" << endl;
  for(c=0; cSUPPLY[s])
    cout << " Supplier " << s << ": " << dem-SUPPLY[s] << endl;
  }
  for(s=0; s=0 && sol[x[s][c].getColNum()]>0.01)
     cout << x[s][c].getName() << ":" << sol[x[s][c].getColNum()] << " ";
   cout << endl;    
  cout << "Violations:" << endl;
  for(c=0; c=0) sup+=sol[x[s][c].getColNum()];
   if(sup=0) dem+=sol[x[s][c].getColNum()];
   if(dem>SUPPLY[s])
    cout << "  Supplier " << s << ": " << dem-SUPPLY[s] << endl;
  }
  for(s=0; s=0 &&
       VANCAP |