Ignore:
Timestamp:
Jan 6, 2019 6:17:46 PM (9 months ago)
Author:
unxusr
Message:

formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/examples/allCuts.cpp

    r1898 r2469  
    66#include <cassert>
    77#include <iomanip>
    8 
    98
    109#include "CoinPragma.hpp"
     
    4544/** Stored Cut Generator Class */
    4645class CglStoredUser : public CglStored {
    47  
     46
    4847public:
    49    
    50  
    5148  /**@name Generate Cuts */
    5249  //@{
     
    5956      and inserts any that are violated by enough
    6057  */
    61   virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
    62                              const CglTreeInfo info = CglTreeInfo()) const;
     58  virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs,
     59    const CglTreeInfo info = CglTreeInfo()) const;
    6360  //@}
    6461
    6562  /**@name Cut stuff */
    6663  //@{
    67   OsiRowCut * mutableRowCutPointer(int index)
    68   { return cuts_.rowCutPtr(index);}
     64  OsiRowCut *mutableRowCutPointer(int index)
     65  {
     66    return cuts_.rowCutPtr(index);
     67  }
    6968  //@}
    7069
    7170  /**@name Constructors and destructors */
    7271  //@{
    73   /// Default constructor 
    74   CglStoredUser ();
    75  
    76   /// Copy constructor 
    77   CglStoredUser (const CglStoredUser & rhs);
     72  /// Default constructor
     73  CglStoredUser();
     74
     75  /// Copy constructor
     76  CglStoredUser(const CglStoredUser &rhs);
    7877
    7978  /// Clone
    80   virtual CglCutGenerator * clone() const;
    81 
    82   /// Assignment operator 
     79  virtual CglCutGenerator *clone() const;
     80
     81  /// Assignment operator
    8382  CglStoredUser &
    84     operator=(const CglStoredUser& rhs);
    85  
    86   /// Destructor
    87   virtual
    88     ~CglStoredUser ();
     83  operator=(const CglStoredUser &rhs);
     84
     85  /// Destructor
     86  virtual ~CglStoredUser();
    8987  //@}
    90      
     88
    9189protected:
    92  
    93  // Protected member methods
     90  // Protected member methods
    9491
    9592  // Protected member data
     
    105102//-------------------------------------------------------------------
    106103// Generate Stored cuts
    107 //-------------------------------------------------------------------
    108 void
    109 CglStoredUser::generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
    110                              const CglTreeInfo info) const
     104//-------------------------------------------------------------------
     105void CglStoredUser::generateCuts(const OsiSolverInterface &si, OsiCuts &cs,
     106  const CglTreeInfo info) const
    111107{
    112108  // Get basic problem information
    113   const double * solution = si.getColSolution();
    114   if (info.inTree&&info.pass>numberPasses_) {
     109  const double *solution = si.getColSolution();
     110  if (info.inTree && info.pass > numberPasses_) {
    115111    // only continue if integer feasible
    116     int numberColumns=si.getNumCols();
     112    int numberColumns = si.getNumCols();
    117113    int i;
    118     const double * colUpper = si.getColUpper();
    119     const double * colLower = si.getColLower();
    120     int numberAway=0;
    121     for (i=0;i<numberColumns;i++) {
     114    const double *colUpper = si.getColUpper();
     115    const double *colLower = si.getColLower();
     116    int numberAway = 0;
     117    for (i = 0; i < numberColumns; i++) {
    122118      double value = solution[i];
    123119      // In case slightly away from bounds
    124       value = CoinMax(colLower[i],value);
    125       value = CoinMin(colUpper[i],value);
    126       if (si.isInteger(i)&&fabs(value-fabs(value+0.5))>1.0e-5)
    127         numberAway++;
     120      value = CoinMax(colLower[i], value);
     121      value = CoinMin(colUpper[i], value);
     122      if (si.isInteger(i) && fabs(value - fabs(value + 0.5)) > 1.0e-5)
     123        numberAway++;
    128124    }
    129125    if (numberAway)
     
    131127  }
    132128  int numberRowCuts = cuts_.sizeRowCuts();
    133   for (int i=0;i<numberRowCuts;i++) {
    134     const OsiRowCut * rowCutPointer = cuts_.rowCutPtr(i);
     129  for (int i = 0; i < numberRowCuts; i++) {
     130    const OsiRowCut *rowCutPointer = cuts_.rowCutPtr(i);
    135131    double violation = rowCutPointer->violated(solution);
    136     if (violation>=requiredViolation_)
     132    if (violation >= requiredViolation_)
    137133      cs.insert(*rowCutPointer);
    138134  }
     
    140136
    141137//-------------------------------------------------------------------
    142 // Default Constructor
    143 //-------------------------------------------------------------------
    144 CglStoredUser::CglStoredUser ()
    145 :
    146   CglStored(),
    147   numberPasses_(5)
    148 {
    149 }
    150 
    151 //-------------------------------------------------------------------
    152 // Copy constructor
    153 //-------------------------------------------------------------------
    154 CglStoredUser::CglStoredUser (const CglStoredUser & source) :
    155   CglStored(source),
    156   numberPasses_(source.numberPasses_)
    157 
     138// Default Constructor
     139//-------------------------------------------------------------------
     140CglStoredUser::CglStoredUser()
     141  : CglStored()
     142  , numberPasses_(5)
     143{
     144}
     145
     146//-------------------------------------------------------------------
     147// Copy constructor
     148//-------------------------------------------------------------------
     149CglStoredUser::CglStoredUser(const CglStoredUser &source)
     150  : CglStored(source)
     151  , numberPasses_(source.numberPasses_)
     152{
    158153}
    159154
     
    168163
    169164//-------------------------------------------------------------------
    170 // Destructor 
    171 //-------------------------------------------------------------------
    172 CglStoredUser::~CglStoredUser ()
     165// Destructor
     166//-------------------------------------------------------------------
     167CglStoredUser::~CglStoredUser()
    173168{
    174169}
    175170
    176171//----------------------------------------------------------------
    177 // Assignment operator 
     172// Assignment operator
    178173//-------------------------------------------------------------------
    179174CglStoredUser &
    180 CglStoredUser::operator=(const CglStoredUser& rhs)
     175CglStoredUser::operator=(const CglStoredUser &rhs)
    181176{
    182177  if (this != &rhs) {
    183178    CglStored::operator=(rhs);
    184     numberPasses_=rhs.numberPasses_;
     179    numberPasses_ = rhs.numberPasses_;
    185180  }
    186181  return *this;
     
    188183// Class to disallow strong branching solutions
    189184#include "CbcFeasibilityBase.hpp"
    190 class CbcFeasibilityNoStrong : public CbcFeasibilityBase{
     185class CbcFeasibilityNoStrong : public CbcFeasibilityBase {
    191186public:
    192   // Default Constructor 
    193   CbcFeasibilityNoStrong () {};
     187  // Default Constructor
     188  CbcFeasibilityNoStrong() {};
    194189
    195190  virtual ~CbcFeasibilityNoStrong() {};
    196   // Copy constructor
    197   CbcFeasibilityNoStrong ( const CbcFeasibilityNoStrong &rhs) {};
    198    
    199   // Assignment operator
    200   CbcFeasibilityNoStrong & operator=( const CbcFeasibilityNoStrong& rhs)
    201   { return * this;};
     191  // Copy constructor
     192  CbcFeasibilityNoStrong(const CbcFeasibilityNoStrong &rhs) {};
     193
     194  // Assignment operator
     195  CbcFeasibilityNoStrong &operator=(const CbcFeasibilityNoStrong &rhs)
     196  {
     197    return *this;
     198  };
    202199
    203200  /// Clone
    204   virtual CbcFeasibilityBase * clone() const
    205   { return new CbcFeasibilityNoStrong();};
     201  virtual CbcFeasibilityBase *clone() const
     202  {
     203    return new CbcFeasibilityNoStrong();
     204  };
    206205
    207206  /**
     
    214213     1 pretend integer solution
    215214  */
    216   virtual int feasible(CbcModel * model, int mode)
    217   {return mode;};
     215  virtual int feasible(CbcModel *model, int mode)
     216  {
     217    return mode;
     218  };
    218219};
    219220
    220 
    221221//#############################################################################
    222222
    223 
    224223/************************************************************************
    225224
     
    230229************************************************************************/
    231230
    232 int main (int argc, const char *argv[])
     231int main(int argc, const char *argv[])
    233232{
    234233
    235234  // Define your favorite OsiSolver
    236  
     235
    237236  OsiClpSolverInterface solver1;
    238237
     
    248247  }
    249248#endif
    250   if (argc>=2) mpsFileName = argv[1];
    251   int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),"");
    252   if( numMpsReadErrors != 0 )
    253   {
    254      printf("%d errors reading MPS file\n", numMpsReadErrors);
    255      return numMpsReadErrors;
     249  if (argc >= 2)
     250    mpsFileName = argv[1];
     251  int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(), "");
     252  if (numMpsReadErrors != 0) {
     253    printf("%d errors reading MPS file\n", numMpsReadErrors);
     254    return numMpsReadErrors;
    256255  }
    257256  double time1 = CoinCpuTime();
     
    263262     if 2 parameters and numeric taken as time
    264263  */
    265   bool preProcess=false;
    266   double minutes=-1.0;
    267   int nGoodParam=0;
    268   for (int iParam=2; iParam<argc;iParam++) {
    269     if (!strcmp(argv[iParam],"preprocess")) {
    270       preProcess=true;
     264  bool preProcess = false;
     265  double minutes = -1.0;
     266  int nGoodParam = 0;
     267  for (int iParam = 2; iParam < argc; iParam++) {
     268    if (!strcmp(argv[iParam], "preprocess")) {
     269      preProcess = true;
    271270      nGoodParam++;
    272     } else if (!strcmp(argv[iParam],"time")) {
    273       if (iParam+1<argc&&isdigit(argv[iParam+1][0])) {
    274         minutes=atof(argv[iParam+1]);
    275         if (minutes>=0.0) {
    276           nGoodParam+=2;
     271    } else if (!strcmp(argv[iParam], "time")) {
     272      if (iParam + 1 < argc && isdigit(argv[iParam + 1][0])) {
     273        minutes = atof(argv[iParam + 1]);
     274        if (minutes >= 0.0) {
     275          nGoodParam += 2;
    277276          iParam++; // skip time
    278277        }
     
    280279    }
    281280  }
    282   if (nGoodParam==0&&argc==3&&isdigit(argv[2][0])) {
     281  if (nGoodParam == 0 && argc == 3 && isdigit(argv[2][0])) {
    283282    // If time is given then stop after that number of minutes
    284283    minutes = atof(argv[2]);
    285     if (minutes>=0.0)
    286       nGoodParam=1;
    287   }
    288   if (nGoodParam!=argc-2&&argc>=2) {
     284    if (minutes >= 0.0)
     285      nGoodParam = 1;
     286  }
     287  if (nGoodParam != argc - 2 && argc >= 2) {
    289288    printf("Usage <file> [preprocess] [time <minutes>] or <file> <minutes>\n");
    290289    exit(1);
    291290  }
    292291  // Reduce printout
    293   solver1.setHintParam(OsiDoReducePrint,true,OsiHintTry);
     292  solver1.setHintParam(OsiDoReducePrint, true, OsiHintTry);
    294293  // See if we want preprocessing
    295   OsiSolverInterface * solver2=&solver1;
     294  OsiSolverInterface *solver2 = &solver1;
    296295  CglPreProcess process;
    297296  // Never do preprocessing until dual tests out as can fix incorrectly
    298   preProcess=false;
     297  preProcess = false;
    299298  if (preProcess) {
    300299    /* Do not try and produce equality cliques and
    301300       do up to 5 passes */
    302     solver2 = process.preProcess(solver1,false,5);
     301    solver2 = process.preProcess(solver1, false, 5);
    303302    if (!solver2) {
    304303      printf("Pre-processing says infeasible\n");
     
    309308  // Turn L rows into cuts
    310309  CglStoredUser stored;
    311  {
    312   int numberRows = solver2->getNumRows();
    313 
    314   int * whichRow = new int[numberRows];
    315   // get row copy
    316   const CoinPackedMatrix * rowCopy = solver2->getMatrixByRow();
    317   const int * column = rowCopy->getIndices();
    318   const int * rowLength = rowCopy->getVectorLengths();
    319   const CoinBigIndex * rowStart = rowCopy->getVectorStarts();
    320   const double * rowLower = solver2->getRowLower();
    321   const double * rowUpper = solver2->getRowUpper();
    322   const double * element = rowCopy->getElements();
    323   int iRow,nDelete=0;
    324   for (iRow=0;iRow<numberRows;iRow++) {
    325     if (rowLower[iRow]<-1.0e20||rowUpper[iRow]>1.0e20) {
    326       // take out
    327       whichRow[nDelete++]=iRow;
    328     }
    329   }
    330   // leave some rows to avoid empty problem (Gomory does not like)
    331   nDelete = CoinMax(CoinMin(nDelete,numberRows-5),0);
    332   for (int jRow=0;jRow<nDelete;jRow++) {
    333     iRow=whichRow[jRow];
    334     int start = rowStart[iRow];
    335     stored.addCut(rowLower[iRow],rowUpper[iRow],rowLength[iRow],
    336                   column+start,element+start);
    337   }
    338   /* The following is problem specific.
     310  {
     311    int numberRows = solver2->getNumRows();
     312
     313    int *whichRow = new int[numberRows];
     314    // get row copy
     315    const CoinPackedMatrix *rowCopy = solver2->getMatrixByRow();
     316    const int *column = rowCopy->getIndices();
     317    const int *rowLength = rowCopy->getVectorLengths();
     318    const CoinBigIndex *rowStart = rowCopy->getVectorStarts();
     319    const double *rowLower = solver2->getRowLower();
     320    const double *rowUpper = solver2->getRowUpper();
     321    const double *element = rowCopy->getElements();
     322    int iRow, nDelete = 0;
     323    for (iRow = 0; iRow < numberRows; iRow++) {
     324      if (rowLower[iRow] < -1.0e20 || rowUpper[iRow] > 1.0e20) {
     325        // take out
     326        whichRow[nDelete++] = iRow;
     327      }
     328    }
     329    // leave some rows to avoid empty problem (Gomory does not like)
     330    nDelete = CoinMax(CoinMin(nDelete, numberRows - 5), 0);
     331    for (int jRow = 0; jRow < nDelete; jRow++) {
     332      iRow = whichRow[jRow];
     333      int start = rowStart[iRow];
     334      stored.addCut(rowLower[iRow], rowUpper[iRow], rowLength[iRow],
     335        column + start, element + start);
     336    }
     337    /* The following is problem specific.
    339338     Normally cuts are deleted if slack on cut basic.
    340339     On some problems you may wish to leave cuts in as long
    341340     as slack value zero
    342341  */
    343   int numberCuts=stored.sizeRowCuts();
    344   for (int iCut=0;iCut<numberCuts;iCut++) {
    345     //stored.mutableRowCutPointer(iCut)->setEffectiveness(1.0e50);
    346   }
    347   solver2->deleteRows(nDelete,whichRow);
    348   delete [] whichRow;
    349  }
     342    int numberCuts = stored.sizeRowCuts();
     343    for (int iCut = 0; iCut < numberCuts; iCut++) {
     344      //stored.mutableRowCutPointer(iCut)->setEffectiveness(1.0e50);
     345    }
     346    solver2->deleteRows(nDelete, whichRow);
     347    delete[] whichRow;
     348  }
    350349  CbcModel model(*solver2);
    351   model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
     350  model.solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry);
    352351  // Set up some cut generators and defaults
    353352  // Probing first as gets tight bounds on continuous
     
    383382  CglMixedIntegerRounding2 mixedGen;
    384383  CglFlowCover flowGen;
    385  
     384
    386385  // Add in generators
    387386  // Experiment with -1 and -99 etc
    388387  // This is just for one particular model
    389   model.addCutGenerator(&generator1,-1,"Probing");
     388  model.addCutGenerator(&generator1, -1, "Probing");
    390389  //model.addCutGenerator(&generator2,-1,"Gomory");
    391   model.addCutGenerator(&generator2,1,"Gomory");
    392   model.addCutGenerator(&generator3,-1,"Knapsack");
     390  model.addCutGenerator(&generator2, 1, "Gomory");
     391  model.addCutGenerator(&generator3, -1, "Knapsack");
    393392  // model.addCutGenerator(&generator4,-1,"RedSplit");
    394393  //model.addCutGenerator(&generator5,-1,"Clique");
    395   model.addCutGenerator(&generator5,1,"Clique");
    396   model.addCutGenerator(&flowGen,-1,"FlowCover");
    397   model.addCutGenerator(&mixedGen,-1,"MixedIntegerRounding");
     394  model.addCutGenerator(&generator5, 1, "Clique");
     395  model.addCutGenerator(&flowGen, -1, "FlowCover");
     396  model.addCutGenerator(&mixedGen, -1, "MixedIntegerRounding");
    398397  // Add stored cuts (making sure at all depths)
    399   model.addCutGenerator(&stored,1,"Stored",true,false,false,-100,1,-1);
    400  
     398  model.addCutGenerator(&stored, 1, "Stored", true, false, false, -100, 1, -1);
     399
    401400  int numberGenerators = model.numberCutGenerators();
    402401  int iGenerator;
    403402  // Say we want timings
    404   for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
    405     CbcCutGenerator * generator = model.cutGenerator(iGenerator);
     403  for (iGenerator = 0; iGenerator < numberGenerators; iGenerator++) {
     404    CbcCutGenerator *generator = model.cutGenerator(iGenerator);
    406405    generator->setTiming(true);
    407406  }
    408   OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (model.solver());
     407  OsiClpSolverInterface *osiclp = dynamic_cast< OsiClpSolverInterface * >(model.solver());
    409408  // go faster stripes
    410   if (osiclp) { 
    411     if(osiclp->getNumRows()<300&&osiclp->getNumCols()<500) {
     409  if (osiclp) {
     410    if (osiclp->getNumRows() < 300 && osiclp->getNumCols() < 500) {
    412411      //osiclp->setupForRepeatedUse(2,0);
    413       osiclp->setupForRepeatedUse(0,0);
     412      osiclp->setupForRepeatedUse(0, 0);
    414413    }
    415414    // Don't allow dual stuff
    416     osiclp->setSpecialOptions(osiclp->specialOptions()|262144);
    417   } 
     415    osiclp->setSpecialOptions(osiclp->specialOptions() | 262144);
     416  }
    418417  // Uncommenting this should switch off all CBC messages
    419418  // model.messagesPointer()->setDetailMessages(10,10000,NULL);
     
    429428  */
    430429  // Make sure cut generator called correctly (a)
    431   iGenerator=numberGenerators-1;
     430  iGenerator = numberGenerators - 1;
    432431  model.cutGenerator(iGenerator)->setMustCallAgain(true);
    433432  // Say cuts needed at continuous (b)
     
    443442
    444443  // Could tune more
    445   double objValue = model.solver()->getObjSense()*model.solver()->getObjValue();
    446   double minimumDropA=CoinMin(1.0,fabs(objValue)*1.0e-3+1.0e-4);
    447   double minimumDrop= fabs(objValue)*1.0e-4+1.0e-4;
    448   printf("min drop %g (A %g)\n",minimumDrop,minimumDropA);
     444  double objValue = model.solver()->getObjSense() * model.solver()->getObjValue();
     445  double minimumDropA = CoinMin(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4);
     446  double minimumDrop = fabs(objValue) * 1.0e-4 + 1.0e-4;
     447  printf("min drop %g (A %g)\n", minimumDrop, minimumDropA);
    449448  model.setMinimumDrop(minimumDrop);
    450449
    451   if (model.getNumCols()<500)
     450  if (model.getNumCols() < 500)
    452451    model.setMaximumCutPassesAtRoot(-100); // always do 100 if possible
    453   else if (model.getNumCols()<5000)
     452  else if (model.getNumCols() < 5000)
    454453    model.setMaximumCutPassesAtRoot(100); // use minimum drop
    455454  else
     
    461460  // model.setNumberStrong(0);
    462461  // Do more strong branching if small
    463   if (model.getNumCols()<5000)
     462  if (model.getNumCols() < 5000)
    464463    model.setNumberStrong(10);
    465464  model.setNumberStrong(20);
     
    467466  model.setNumberBeforeTrust(5);
    468467
    469   model.solver()->setIntParam(OsiMaxNumIterationHotStart,100);
     468  model.solver()->setIntParam(OsiMaxNumIterationHotStart, 100);
    470469
    471470  // If time is given then stop after that number of minutes
    472   if (minutes>=0.0) {
    473     std::cout<<"Stopping after "<<minutes<<" minutes"<<std::endl;
    474     model.setDblParam(CbcModel::CbcMaximumSeconds,60.0*minutes);
     471  if (minutes >= 0.0) {
     472    std::cout << "Stopping after " << minutes << " minutes" << std::endl;
     473    model.setDblParam(CbcModel::CbcMaximumSeconds, 60.0 * minutes);
    475474  }
    476475  // Switch off most output
    477   if (model.getNumCols()<30000) {
     476  if (model.getNumCols() < 30000) {
    478477    model.messageHandler()->setLogLevel(1);
    479478    //model.solver()->messageHandler()->setLogLevel(0);
     
    489488  // Set up debugger by name (only if no preprocesing)
    490489  if (!preProcess) {
    491     std::string problemName ;
    492     model.solver()->getStrParam(OsiProbName,problemName) ;
    493     model.solver()->activateRowCutDebugger(problemName.c_str()) ;
     490    std::string problemName;
     491    model.solver()->getStrParam(OsiProbName, problemName);
     492    model.solver()->activateRowCutDebugger(problemName.c_str());
    494493  }
    495494#endif
    496495  // Do complete search
    497  
     496
    498497  model.branchAndBound();
    499498
    500   std::cout<<mpsFileName<<" took "<<CoinCpuTime()-time1<<" seconds, "
    501            <<model.getNodeCount()<<" nodes with objective "
    502            <<model.getObjValue()
    503            <<(!model.status() ? " Finished" : " Not finished")
    504            <<std::endl;
     499  std::cout << mpsFileName << " took " << CoinCpuTime() - time1 << " seconds, "
     500            << model.getNodeCount() << " nodes with objective "
     501            << model.getObjValue()
     502            << (!model.status() ? " Finished" : " Not finished")
     503            << std::endl;
    505504
    506505  // Print more statistics
    507   std::cout<<"Cuts at root node changed objective from "<<model.getContinuousObjective()
    508            <<" to "<<model.rootObjectiveAfterCuts()<<std::endl;
    509 
    510   for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
    511     CbcCutGenerator * generator = model.cutGenerator(iGenerator);
    512     std::cout<<generator->cutGeneratorName()<<" was tried "
    513              <<generator->numberTimesEntered()<<" times and created "
    514              <<generator->numberCutsInTotal()<<" cuts of which "
    515              <<generator->numberCutsActive()<<" were active after adding rounds of cuts";
     506  std::cout << "Cuts at root node changed objective from " << model.getContinuousObjective()
     507            << " to " << model.rootObjectiveAfterCuts() << std::endl;
     508
     509  for (iGenerator = 0; iGenerator < numberGenerators; iGenerator++) {
     510    CbcCutGenerator *generator = model.cutGenerator(iGenerator);
     511    std::cout << generator->cutGeneratorName() << " was tried "
     512              << generator->numberTimesEntered() << " times and created "
     513              << generator->numberCutsInTotal() << " cuts of which "
     514              << generator->numberCutsActive() << " were active after adding rounds of cuts";
    516515    if (generator->timing())
    517       std::cout<<" ( "<<generator->timeInCutGenerator()<<" seconds)"<<std::endl;
     516      std::cout << " ( " << generator->timeInCutGenerator() << " seconds)" << std::endl;
    518517    else
    519       std::cout<<std::endl;
     518      std::cout << std::endl;
    520519  }
    521520  // Print solution if finished - we can't get names from Osi! - so get from OsiClp
    522521
    523   if (model.getMinimizationObjValue()<1.0e50) {
     522  if (model.getMinimizationObjValue() < 1.0e50) {
    524523    // post process
    525     OsiSolverInterface * solver;
     524    OsiSolverInterface *solver;
    526525    if (preProcess) {
    527526      process.postProcess(*model.solver());
    528527      // Solution now back in solver1
    529       solver = & solver1;
     528      solver = &solver1;
    530529    } else {
    531530      solver = model.solver();
    532531    }
    533532    int numberColumns = solver->getNumCols();
    534    
    535     const double * solution = solver->getColSolution();
     533
     534    const double *solution = solver->getColSolution();
    536535
    537536    // Get names from solver1 (as OsiSolverInterface may lose)
    538     std::vector<std::string> columnNames = *solver1.getModelPtr()->columnNames();
    539    
     537    std::vector< std::string > columnNames = *solver1.getModelPtr()->columnNames();
     538
    540539    int iColumn;
    541     std::cout<<std::setiosflags(std::ios::fixed|std::ios::showpoint)<<std::setw(14);
    542    
    543     std::cout<<"--------------------------------------"<<std::endl;
    544     for (iColumn=0;iColumn<numberColumns;iColumn++) {
    545       double value=solution[iColumn];
    546       if (fabs(value)>1.0e-7&&solver->isInteger(iColumn)) {
    547         std::cout<<std::setw(6)<<iColumn<<" "
    548                  <<columnNames[iColumn]<<" "
    549                  <<value<<std::endl;
    550         solverSave.setColLower(iColumn,value);
    551         solverSave.setColUpper(iColumn,value);
     540    std::cout << std::setiosflags(std::ios::fixed | std::ios::showpoint) << std::setw(14);
     541
     542    std::cout << "--------------------------------------" << std::endl;
     543    for (iColumn = 0; iColumn < numberColumns; iColumn++) {
     544      double value = solution[iColumn];
     545      if (fabs(value) > 1.0e-7 && solver->isInteger(iColumn)) {
     546        std::cout << std::setw(6) << iColumn << " "
     547                  << columnNames[iColumn] << " "
     548                  << value << std::endl;
     549        solverSave.setColLower(iColumn, value);
     550        solverSave.setColUpper(iColumn, value);
    552551      }
    553552    }
    554     std::cout<<"--------------------------------------"<<std::endl;
    555  
    556     std::cout<<std::resetiosflags(std::ios::fixed|std::ios::showpoint|std::ios::scientific);
     553    std::cout << "--------------------------------------" << std::endl;
     554
     555    std::cout << std::resetiosflags(std::ios::fixed | std::ios::showpoint | std::ios::scientific);
    557556    solverSave.initialSolve();
    558557  }
    559558  return 0;
    560 }   
     559}
Note: See TracChangeset for help on using the changeset viewer.