Changeset 355


Ignore:
Timestamp:
Jun 9, 2006 3:18:19 PM (13 years ago)
Author:
andreasw
Message:

undid last commit (patches incorrectly applied)

Location:
trunk/Cbc/src
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcBranchBase.hpp

    r354 r355  
    423423  virtual void setBestCriterion(double value) {};
    424424  virtual double getBestCriterion() const {return 0.0;};
    425   /// Create C++ lines to get to current state
    426   virtual void generateCpp( FILE * fp) {};
    427425
    428426protected:
  • trunk/Cbc/src/CbcBranchLotsize.cpp

    r354 r355  
    592592{
    593593  OsiSolverInterface * solver = model_->solver();
     594  double value = model_->testSolution()[columnNumber_];
    594595
    595596#ifndef NDEBUG
    596   double value = model_->testSolution()[columnNumber_];
    597597  double nearest = floor(value+0.5);
    598598  double integerTolerance =
  • trunk/Cbc/src/CbcCompareActual.cpp

    r354 r355  
    6161  return x->depth() < y->depth();
    6262}
    63 // Create C++ lines to get to current state
    64 void
    65 CbcCompareDepth::generateCpp( FILE * fp)
    66 {
    67   fprintf(fp,"0#include \"CbcCompareActual.hpp\"\n");
    68   fprintf(fp,"3  CbcCompareDepth compare;\n");
    69   fprintf(fp,"3  cbcModel->setNodeComparison(compare);\n");
    70 }
    7163
    7264/** Default Constructor
     
    113105{
    114106  return x->objectiveValue() > y->objectiveValue();
    115 }
    116 
    117 // Create C++ lines to get to current state
    118 void
    119 CbcCompareObjective::generateCpp( FILE * fp)
    120 {
    121   fprintf(fp,"0#include \"CbcCompareActual.hpp\"\n");
    122   fprintf(fp,"3  CbcCompareObjective compare;\n");
    123   fprintf(fp,"3  cbcModel->setNodeComparison(compare);\n");
    124107}
    125108
     
    290273}
    291274
    292 // Create C++ lines to get to current state
    293 void
    294 CbcCompareDefault::generateCpp( FILE * fp)
    295 {
    296   CbcCompareDefault other;
    297   fprintf(fp,"0#include \"CbcCompareActual.hpp\"\n");
    298   fprintf(fp,"3  CbcCompareDefault compare;\n");
    299   if (weight_!=other.weight_)
    300     fprintf(fp,"3  compare.setWeight(%g);\n",weight_);
    301   fprintf(fp,"3  cbcModel->setNodeComparison(compare);\n");
    302 }
    303 
    304275/** Default Constructor
    305276
     
    347318}
    348319
    349 // Create C++ lines to get to current state
    350 void
    351 CbcCompareEstimate::generateCpp( FILE * fp)
    352 {
    353   fprintf(fp,"0#include \"CbcCompareActual.hpp\"\n");
    354   fprintf(fp,"3  CbcCompareEstimate compare;\n");
    355   fprintf(fp,"3  cbcModel->setNodeComparison(compare);\n");
    356 }
    357 
  • trunk/Cbc/src/CbcCompareActual.hpp

    r354 r355  
    3131  /// Clone
    3232  virtual CbcCompareBase * clone() const;
    33   /// Create C++ lines to get to current state
    34   virtual void generateCpp( FILE * fp);
    3533
    3634  // This returns true if the depth of node y is greater than depth of node x
     
    5149  /// Clone
    5250  virtual CbcCompareBase * clone() const;
    53   /// Create C++ lines to get to current state
    54   virtual void generateCpp( FILE * fp);
    5551
    5652  /* This returns true if objective value of node y is less than
     
    7874  /// Clone
    7975  virtual CbcCompareBase * clone() const;
    80   /// Create C++ lines to get to current state
    81   virtual void generateCpp( FILE * fp);
    8276
    8377  ~CbcCompareDefault() ;
     
    127121  /// Clone
    128122  virtual CbcCompareBase * clone() const;
    129   /// Create C++ lines to get to current state
    130   virtual void generateCpp( FILE * fp);
    131123
    132124  virtual bool test (CbcNode * x, CbcNode * y) ;
  • trunk/Cbc/src/CbcCompareBase.hpp

    r354 r355  
    4545
    4646  virtual ~CbcCompareBase() {};
    47   /// Create C++ lines to get to current state
    48   virtual void generateCpp( FILE * fp) {};
    4947
    5048  // Copy constructor
  • trunk/Cbc/src/CbcHeuristic.cpp

    r354 r355  
    146146// Default Constructor
    147147CbcRounding::CbcRounding()
    148   seed_=1;
    149148  :CbcHeuristic()
    150149{
     
    171170CbcHeuristic *
    172171CbcRounding::clone() const
    173 // Create C++ lines to get to current state
    174 void
    175 CbcRounding::generateCpp( FILE * fp)
    176 {
    177   CbcRounding other;
    178   fprintf(fp,"0#include \"CbcHeuristic.hpp\"\n");
    179   fprintf(fp,"3  CbcRounding rounding(*cbcModel);\n");
    180   if (seed_!=other.seed_)
    181     fprintf(fp,"3  rounding.setSeed(%d);\n",seed_);
    182   else
    183     fprintf(fp,"4  rounding.setSeed(%d);\n",seed_);
    184   fprintf(fp,"3  cbcModel->addHeuristic(&rounding);\n");
    185 }
    186172{
    187173  return new CbcRounding(*this);
     
    898884CbcHeuristic *
    899885CbcSerendipity::clone() const
    900 // Create C++ lines to get to current state
    901 void
    902 CbcSerendipity::generateCpp( FILE * fp)
    903 {
    904   fprintf(fp,"0#include \"CbcHeuristic.hpp\"\n");
    905   fprintf(fp,"3  CbcSerendipity serendipity(*cbcModel);\n");
    906   fprintf(fp,"3  cbcModel->addHeuristic(&serendipity);\n");
    907 }
    908886{
    909887  return new CbcSerendipity(*this);
  • trunk/Cbc/src/CbcHeuristic.hpp

    r354 r355  
    7171                          double * newSolution, double & newSolutionValue,
    7272                          double cutoff , std::string name) const;
    73   /// Create C++ lines to get to current state
    74   virtual void generateCpp( FILE * fp) {};
    7573
    7674protected:
     
    107105  /// Clone
    108106  virtual CbcHeuristic * clone() const;
    109   /// Create C++ lines to get to current state
    110   virtual void generateCpp( FILE * fp) ;
    111107
    112108  /// Resets stuff if model changes
     
    170166  /// Clone
    171167  virtual CbcHeuristic * clone() const;
    172   /// Create C++ lines to get to current state
    173   virtual void generateCpp( FILE * fp) ;
    174168
    175169  /// update model
  • trunk/Cbc/src/CbcHeuristicFPump.cpp

    r354 r355  
    5353{
    5454  return new CbcHeuristicFPump(*this);
    55 }
    56 // Create C++ lines to get to current state
    57 void
    58 CbcHeuristicFPump::generateCpp( FILE * fp)
    59 {
    60   CbcHeuristicFPump other;
    61   fprintf(fp,"0#include \"CbcHeuristicFPump.hpp\"\n");
    62   fprintf(fp,"3  CbcHeuristicFPump heuristicFPump(*cbcModel);\n");
    63   if (maximumPasses_!=other.maximumPasses_)
    64     fprintf(fp,"3  heuristicFPump.setMaximumPasses(%d);\n",maximumPasses_);
    65   else
    66     fprintf(fp,"4  heuristicFPump.setMaximumPasses(%d);\n",maximumPasses_);
    67   if (maximumTime_!=other.maximumTime_)
    68     fprintf(fp,"3  heuristicFPump.setMaximumTime(%g);\n",maximumTime_);
    69   else
    70     fprintf(fp,"4  heuristicFPump.setMaximumTime(%g);\n",maximumTime_);
    71   fprintf(fp,"3  cbcModel->addHeuristic(&heuristicFPump);\n");
    7255}
    7356
     
    128111  for (i=0;i<numberIntegers;i++) {
    129112    int iColumn = integerVariable[i];
     113    const CbcObject * object = model_->object(i);
    130114#ifndef NDEBUG
    131     const CbcObject * object = model_->object(i);
    132115    const CbcSimpleInteger * integerObject =
    133116      dynamic_cast<const  CbcSimpleInteger *> (object);
     
    354337    if(!solver->isBinary(iColumn))
    355338      continue;
     339    const CbcObject * object = model_->object(i);
    356340#ifndef NDEBUG
    357     const CbcObject * object = model_->object(i);
    358341    const CbcSimpleInteger * integerObject =
    359342      dynamic_cast<const  CbcSimpleInteger *> (object);
  • trunk/Cbc/src/CbcHeuristicFPump.hpp

    r354 r355  
    2727  /// Clone
    2828  virtual CbcHeuristic * clone() const;
    29   /// Create C++ lines to get to current state
    30   virtual void generateCpp( FILE * fp) ;
    3129
    3230  /// Resets stuff if model changes
  • trunk/Cbc/src/CbcHeuristicGreedy.cpp

    r354 r355  
    4747{
    4848  return new CbcHeuristicGreedyCover(*this);
    49 }
    50 // Create C++ lines to get to current state
    51 void
    52 CbcHeuristicGreedyCover::generateCpp( FILE * fp)
    53 {
    54   CbcHeuristicGreedyCover other;
    55   fprintf(fp,"0#include \"CbcHeuristicGreedy.hpp\"\n");
    56   fprintf(fp,"3  CbcHeuristicGreedyCover heuristicGreedyCover(*cbcModel);\n");
    57   if (algorithm_!=other.algorithm_)
    58     fprintf(fp,"3  heuristicGreedyCover.setAlgorithm(%d);\n",algorithm_);
    59   else
    60     fprintf(fp,"4  heuristicGreedyCover.setAlgorithm(%d);\n",algorithm_);
    61   if (numberTimes_!=other.numberTimes_)
    62     fprintf(fp,"3  heuristicGreedyCover.setNumberTimes(%d);\n",numberTimes_);
    63   else
    64     fprintf(fp,"4  heuristicGreedyCover.setNumberTimes(%d);\n",numberTimes_);
    65   fprintf(fp,"3  cbcModel->addHeuristic(&heuristicGreedyCover);\n");
    6649}
    6750
     
    454437  return new CbcHeuristicGreedyEquality(*this);
    455438}
    456 // Create C++ lines to get to current state
    457 void
    458 CbcHeuristicGreedyEquality::generateCpp( FILE * fp)
    459 {
    460   CbcHeuristicGreedyEquality other;
    461   fprintf(fp,"0#include \"CbcHeuristicGreedy.hpp\"\n");
    462   fprintf(fp,"3  CbcHeuristicGreedyEquality heuristicGreedyEquality(*cbcModel);\n");
    463   if (algorithm_!=other.algorithm_)
    464     fprintf(fp,"3  heuristicGreedyEquality.setAlgorithm(%d);\n",algorithm_);
    465   else
    466     fprintf(fp,"4  heuristicGreedyEquality.setAlgorithm(%d);\n",algorithm_);
    467   if (fraction_!=other.fraction_)
    468     fprintf(fp,"3  heuristicGreedyEquality.setFraction(%g);\n",fraction_);
    469   else
    470     fprintf(fp,"4  heuristicGreedyEquality.setFraction(%g);\n",fraction_);
    471   if (numberTimes_!=other.numberTimes_)
    472     fprintf(fp,"3  heuristicGreedyEquality.setNumberTimes(%d);\n",numberTimes_);
    473   else
    474     fprintf(fp,"4  heuristicGreedyEquality.setNumberTimes(%d);\n",numberTimes_);
    475   fprintf(fp,"3  cbcModel->addHeuristic(&heuristicGreedyEquality);\n");
    476 }
    477439
    478440// Copy constructor
  • trunk/Cbc/src/CbcHeuristicGreedy.hpp

    r354 r355  
    2727  /// Clone
    2828  virtual CbcHeuristic * clone() const;
    29   /// Create C++ lines to get to current state
    30   virtual void generateCpp( FILE * fp) ;
    3129
    3230  /// update model (This is needed if cliques update matrix etc)
     
    106104  /// Clone
    107105  virtual CbcHeuristic * clone() const;
    108   /// Create C++ lines to get to current state
    109   virtual void generateCpp( FILE * fp) ;
    110106
    111107  /// update model (This is needed if cliques update matrix etc)
  • trunk/Cbc/src/CbcHeuristicLocal.cpp

    r354 r355  
    5252{
    5353  return new CbcHeuristicLocal(*this);
    54 }
    55 // Create C++ lines to get to current state
    56 void
    57 CbcHeuristicLocal::generateCpp( FILE * fp)
    58 {
    59   CbcHeuristicLocal other;
    60   fprintf(fp,"0#include \"CbcHeuristicLocal.hpp\"\n");
    61   fprintf(fp,"3  CbcHeuristicLocal heuristicLocal(*cbcModel);\n");
    62   if (swap_!=other.swap_)
    63     fprintf(fp,"3  heuristicLocal.setSearchType(%d);\n",swap_);
    64   else
    65     fprintf(fp,"4  heuristicLocal.setSearchType(%d);\n",swap_);
    66   fprintf(fp,"3  cbcModel->addHeuristic(&heuristicLocal);\n");
    6754}
    6855
  • trunk/Cbc/src/CbcHeuristicLocal.hpp

    r354 r355  
    2727  /// Clone
    2828  virtual CbcHeuristic * clone() const;
    29 
    30   /// Create C++ lines to get to current state
    31   virtual void generateCpp( FILE * fp) ;
    3229
    3330  /// Resets stuff if model changes
  • trunk/Cbc/src/CbcModel.cpp

    r354 r355  
    710710  continuousSolver_ = solver_->clone() ;
    711711#ifdef COIN_HAS_CLP
    712   if ((specialOptions_&32)==0) {
    713     OsiClpSolverInterface * clpSolver
    714       = dynamic_cast<OsiClpSolverInterface *> (solver_);
    715     if (clpSolver) {
    716       ClpSimplex * clpSimplex = clpSolver->getModelPtr();
    717       // take off names
    718       clpSimplex->dropNames();
    719     }
     712  OsiClpSolverInterface * clpSolver
     713    = dynamic_cast<OsiClpSolverInterface *> (solver_);
     714  if (clpSolver) {
     715    ClpSimplex * clpSimplex = clpSolver->getModelPtr();
     716    // take off names
     717    clpSimplex->dropNames();
    720718  }
    721719#endif
     
    13001298      }
    13011299      if ((specialOptions_&1)!=0&&onOptimalPath) {
    1302         assert (solver_->getRowCutDebugger()) ;
     1300        const OsiRowCutDebugger *debugger = solver_->getRowCutDebugger() ;
     1301        assert (debugger) ;
    13031302      }
    13041303      if (statistics_) {
     
    23432342
    23442343{
    2345   // resize best solution if exists
    2346   if (bestSolution_) {
    2347     int nOld = solver_->getNumCols();
    2348     int nNew = solver->getNumCols();
    2349     if (nNew>nOld) {
    2350       double * temp = new double[nNew];
    2351       memcpy(temp,bestSolution_,nOld*sizeof(double));
    2352       memset(temp+nOld,0,(nNew-nOld)*sizeof(double));
    2353       delete [] bestSolution_;
    2354       bestSolution_=temp;
    2355     }
    2356   }
    23572344  // Keep the current message level for solver (if solver exists)
    23582345  if (solver_)
     
    33663353      addCuts = new const OsiRowCut* [currentNumberCuts];
    33673354      cutsToDrop = new int[currentNumberCuts] ;
    3368       assert (currentNumberCuts+numberRowsAtContinuous_<=lastws->getNumArtificial());
     3355      int nxrow = lastws->getNumArtificial();
    33693356      for (i=0;i<currentNumberCuts;i++) {
     3357        assert (i+numberRowsAtContinuous_<nxrow);
    33703358        CoinWarmStartBasis::Status status =
    33713359          lastws->getArtifStatus(i+numberRowsAtContinuous_);
     
    34783466      { solver_->setColUpper(iColumn,lower[iColumn]) ;
    34793467#ifdef COIN_HAS_CLP
    3480       // may just have been fixed before
    34813468      if (clpSimplex)
    3482         assert(clpSimplex->getColumnStatus(iColumn)==ClpSimplex::atLowerBound||
    3483                clpSimplex->getColumnStatus(iColumn)==ClpSimplex::isFixed);
     3469        assert (clpSimplex->getColumnStatus(iColumn)==ClpSimplex::atLowerBound);
    34843470#endif
    34853471        numberFixed++ ; }
     
    34883474      { solver_->setColLower(iColumn,upper[iColumn]) ;
    34893475#ifdef COIN_HAS_CLP
    3490       // may just have been fixed before
    34913476      if (clpSimplex)
    3492         assert(clpSimplex->getColumnStatus(iColumn)==ClpSimplex::atUpperBound||
    3493                clpSimplex->getColumnStatus(iColumn)==ClpSimplex::isFixed);
     3477        assert (clpSimplex->getColumnStatus(iColumn)==ClpSimplex::atUpperBound);
    34943478#endif
    34953479        numberFixed++ ; } } }
     
    55625546double
    55635547CbcModel::checkSolution (double cutoff, const double *solution,
    5564                          bool fixVariables, double objectiveValue))
     5548                         bool fixVariables)
    55655549
    55665550{
     
    56225606      bool saveTakeHint;
    56235607      OsiHintStrength saveStrength;
    5624 #ifndef NDEBUG
    56255608      bool gotHint = (solver_->getHintParam(OsiDoDualInInitial,saveTakeHint,saveStrength));
    56265609      assert (gotHint);
    5627 #else
    5628       (solver_->getHintParam(OsiDoDualInInitial,saveTakeHint,saveStrength));
    5629 #endif
    56305610      solver_->setHintParam(OsiDoDualInInitial,true,OsiHintTry);
    56315611      solver_->initialSolve();
     
    56475627      //assert(solver_->isProvenOptimal());
    56485628      solver_->setHintParam(OsiDoDualInInitial,saveTakeHint,saveStrength);
    5649       objectiveValue = solver_->getObjValue()*solver_->getObjSense();
    5650     }
     5629    }
     5630    double objectiveValue = solver_->getObjValue()*solver_->getObjSense();
    56515631   
    56525632    /*
     
    58665846      Double check the solution to catch pretenders.
    58675847    */
    5868     objectiveValue = checkSolution(cutoff,solution,fixVariables,objectiveValue);
     5848    objectiveValue = checkSolution(cutoff,solution,fixVariables);
    58695849    if (objectiveValue > cutoff) {
    58705850      if (objectiveValue>1.0e30)
     
    59605940    int numberRowBefore = solver_->getNumRows();
    59615941    int numberColBefore = solver_->getNumCols();
    5962     double *saveColSol=NULL;
     5942    double *saveColSol;
    59635943   
    5964     CoinWarmStart * saveWs=NULL;
     5944    CoinWarmStart * saveWs;
    59655945    // if(how!=CBC_SOLUTION) return;
    59665946    if(how==CBC_ROUNDING)//We don't want to make any change to solver_
     
    59805960    double * candidate = new double[numberColBefore];
    59815961    CoinCopyN(solution, numberColBefore, candidate);
    5982     objectiveValue = checkSolution(cutoff,candidate,fixVariables,objectiveValue);
     5962    objectiveValue = checkSolution(cutoff,candidate,fixVariables);
    59835963   
    59845964    //If it was an heuristic solution we have to clean up the solver
     
    76207600  return CoinCpuTime()-getDblParam(CbcStartSeconds);
    76217601}
    7622 // Create C++ lines to get to current state
    7623 void
    7624 CbcModel::generateCpp( FILE * fp,int options)
    7625 {
    7626   // Do cut generators
    7627   int i;
    7628   for (i=0;i<numberCutGenerators_;i++) {
    7629     CglCutGenerator * generator = generator_[i]->generator();
    7630     std::string name = generator->generateCpp(fp);
    7631     int howOften = generator_[i]->howOften();
    7632     int howOftenInSub = generator_[i]->howOftenInSub();
    7633     int whatDepth = generator_[i]->whatDepth();
    7634     int whatDepthInSub = generator_[i]->whatDepthInSub();
    7635     bool normal = generator_[i]->normal();
    7636     bool atSolution = generator_[i]->atSolution();
    7637     bool whenInfeasible = generator_[i]->whenInfeasible();
    7638     bool timing = generator_[i]->timing();
    7639     fprintf(fp,"3  cbcModel->addCutGenerator(&%s,%d,",
    7640             name.c_str(),howOften);
    7641     // change name
    7642     name[0]=toupper(name[0]);
    7643     fprintf(fp,"\"%s\",%s,%s,%s,%d,%d,%d);\n",
    7644             name.c_str(),normal ? "true" : "false",
    7645             atSolution ? "true" : "false",
    7646             whenInfeasible ? "true" : "false",
    7647             howOftenInSub,whatDepth,whatDepthInSub);
    7648     fprintf(fp,"3  cbcModel->cutGenerator(%d)->setTiming(%s);\n",
    7649             i,timing ? "true" : "false");
    7650     fprintf(fp,"3  \n");
    7651   }
    7652   for (i=0;i<numberHeuristics_;i++) {
    7653     CbcHeuristic * heuristic = heuristic_[i];
    7654     heuristic->generateCpp(fp);
    7655     fprintf(fp,"3  \n");
    7656   }
    7657   if (nodeCompare_)
    7658     nodeCompare_->generateCpp(fp);
    7659   CbcModel defaultModel;
    7660   CbcModel * other = &defaultModel;
    7661   int iValue1, iValue2;
    7662   double dValue1, dValue2;
    7663   iValue1 = this->getMaximumNodes();
    7664   iValue2 = other->getMaximumNodes();
    7665   fprintf(fp,"%d  int save_getMaximumNodes = cbcModel->getMaximumNodes();\n",iValue1==iValue2 ? 2 : 1);
    7666   fprintf(fp,"%d  cbcModel->setMaximumNodes(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7667   fprintf(fp,"%d  cbcModel->setMaximumNodes(save_getMaximumNodes);\n",iValue1==iValue2 ? 7 : 6);
    7668   iValue1 = this->getMaximumSolutions();
    7669   iValue2 = other->getMaximumSolutions();
    7670   fprintf(fp,"%d  int save_getMaximumSolutions = cbcModel->getMaximumSolutions();\n",iValue1==iValue2 ? 2 : 1);
    7671   fprintf(fp,"%d  cbcModel->setMaximumSolutions(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7672   fprintf(fp,"%d  cbcModel->setMaximumSolutions(save_getMaximumSolutions);\n",iValue1==iValue2 ? 7 : 6);
    7673   iValue1 = this->numberStrong();
    7674   iValue2 = other->numberStrong();
    7675   fprintf(fp,"%d  int save_numberStrong = cbcModel->numberStrong();\n",iValue1==iValue2 ? 2 : 1);
    7676   fprintf(fp,"%d  cbcModel->setNumberStrong(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7677   fprintf(fp,"%d  cbcModel->setNumberStrong(save_numberStrong);\n",iValue1==iValue2 ? 7 : 6);
    7678   iValue1 = this->numberBeforeTrust();
    7679   iValue2 = other->numberBeforeTrust();
    7680   fprintf(fp,"%d  int save_numberBeforeTrust = cbcModel->numberBeforeTrust();\n",iValue1==iValue2 ? 2 : 1);
    7681   fprintf(fp,"%d  cbcModel->setNumberBeforeTrust(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7682   fprintf(fp,"%d  cbcModel->setNumberBeforeTrust(save_numberBeforeTrust);\n",iValue1==iValue2 ? 7 : 6);
    7683   iValue1 = this->numberPenalties();
    7684   iValue2 = other->numberPenalties();
    7685   fprintf(fp,"%d  int save_numberPenalties = cbcModel->numberPenalties();\n",iValue1==iValue2 ? 2 : 1);
    7686   fprintf(fp,"%d  cbcModel->setNumberPenalties(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7687   fprintf(fp,"%d  cbcModel->setNumberPenalties(save_numberPenalties);\n",iValue1==iValue2 ? 7 : 6);
    7688   iValue1 = this->howOftenGlobalScan();
    7689   iValue2 = other->howOftenGlobalScan();
    7690   fprintf(fp,"%d  int save_howOftenGlobalScan = cbcModel->howOftenGlobalScan();\n",iValue1==iValue2 ? 2 : 1);
    7691   fprintf(fp,"%d  cbcModel->setHowOftenGlobalScan(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7692   fprintf(fp,"%d  cbcModel->setHowOftenGlobalScan(save_howOftenGlobalScan);\n",iValue1==iValue2 ? 7 : 6);
    7693   iValue1 = this->printFrequency();
    7694   iValue2 = other->printFrequency();
    7695   fprintf(fp,"%d  int save_printFrequency = cbcModel->printFrequency();\n",iValue1==iValue2 ? 2 : 1);
    7696   fprintf(fp,"%d  cbcModel->setPrintFrequency(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7697   fprintf(fp,"%d  cbcModel->setPrintFrequency(save_printFrequency);\n",iValue1==iValue2 ? 7 : 6);
    7698   iValue1 = this->searchStrategy();
    7699   iValue2 = other->searchStrategy();
    7700   fprintf(fp,"%d  int save_searchStrategy = cbcModel->searchStrategy();\n",iValue1==iValue2 ? 2 : 1);
    7701   fprintf(fp,"%d  cbcModel->setSearchStrategy(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7702   fprintf(fp,"%d  cbcModel->setSearchStrategy(save_searchStrategy);\n",iValue1==iValue2 ? 7 : 6);
    7703   iValue1 = this->specialOptions();
    7704   iValue2 = other->specialOptions();
    7705   fprintf(fp,"%d  int save_cbcSpecialOptions = cbcModel->specialOptions();\n",iValue1==iValue2 ? 2 : 1);
    7706   fprintf(fp,"%d  cbcModel->setSpecialOptions(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7707   fprintf(fp,"%d  cbcModel->setSpecialOptions(save_cbcSpecialOptions);\n",iValue1==iValue2 ? 7 : 6);
    7708   iValue1 = this->messageHandler()->logLevel();
    7709   iValue2 = other->messageHandler()->logLevel();
    7710   fprintf(fp,"%d  int save_cbcMessageLevel = cbcModel->messageHandler()->logLevel();\n",iValue1==iValue2 ? 2 : 1);
    7711   fprintf(fp,"%d  cbcModel->messageHandler()->setLogLevel(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7712   fprintf(fp,"%d  cbcModel->messageHandler()->setLogLevel(save_cbcMessageLevel);\n",iValue1==iValue2 ? 7 : 6);
    7713   iValue1 = this->getMaximumCutPassesAtRoot();
    7714   iValue2 = other->getMaximumCutPassesAtRoot();
    7715   fprintf(fp,"%d  int save_getMaximumCutPassesAtRoot = cbcModel->getMaximumCutPassesAtRoot();\n",iValue1==iValue2 ? 2 : 1);
    7716   fprintf(fp,"%d  cbcModel->setMaximumCutPassesAtRoot(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7717   fprintf(fp,"%d  cbcModel->setMaximumCutPassesAtRoot(save_getMaximumCutPassesAtRoot);\n",iValue1==iValue2 ? 7 : 6);
    7718   iValue1 = this->getMaximumCutPasses();
    7719   iValue2 = other->getMaximumCutPasses();
    7720   fprintf(fp,"%d  int save_getMaximumCutPasses = cbcModel->getMaximumCutPasses();\n",iValue1==iValue2 ? 2 : 1);
    7721   fprintf(fp,"%d  cbcModel->setMaximumCutPasses(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    7722   fprintf(fp,"%d  cbcModel->setMaximumCutPasses(save_getMaximumCutPasses);\n",iValue1==iValue2 ? 7 : 6);
    7723   dValue1 = this->getMinimumDrop();
    7724   dValue2 = other->getMinimumDrop();
    7725   fprintf(fp,"%d  double save_getMinimumDrop = cbcModel->getMinimumDrop();\n",dValue1==dValue2 ? 2 : 1);
    7726   fprintf(fp,"%d  cbcModel->setMinimumDrop(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    7727   fprintf(fp,"%d  cbcModel->setMinimumDrop(save_getMinimumDrop);\n",dValue1==dValue2 ? 7 : 6);
    7728   dValue1 = this->getIntegerTolerance();
    7729   dValue2 = other->getIntegerTolerance();
    7730   fprintf(fp,"%d  double save_getIntegerTolerance = cbcModel->getIntegerTolerance();\n",dValue1==dValue2 ? 2 : 1);
    7731   fprintf(fp,"%d  cbcModel->setIntegerTolerance(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    7732   fprintf(fp,"%d  cbcModel->setIntegerTolerance(save_getIntegerTolerance);\n",dValue1==dValue2 ? 7 : 6);
    7733   dValue1 = this->getInfeasibilityWeight();
    7734   dValue2 = other->getInfeasibilityWeight();
    7735   fprintf(fp,"%d  double save_getInfeasibilityWeight = cbcModel->getInfeasibilityWeight();\n",dValue1==dValue2 ? 2 : 1);
    7736   fprintf(fp,"%d  cbcModel->setInfeasibilityWeight(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    7737   fprintf(fp,"%d  cbcModel->setInfeasibilityWeight(save_getInfeasibilityWeight);\n",dValue1==dValue2 ? 7 : 6);
    7738   dValue1 = this->getCutoffIncrement();
    7739   dValue2 = other->getCutoffIncrement();
    7740   fprintf(fp,"%d  double save_getCutoffIncrement = cbcModel->getCutoffIncrement();\n",dValue1==dValue2 ? 2 : 1);
    7741   fprintf(fp,"%d  cbcModel->setCutoffIncrement(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    7742   fprintf(fp,"%d  cbcModel->setCutoffIncrement(save_getCutoffIncrement);\n",dValue1==dValue2 ? 7 : 6);
    7743   dValue1 = this->getAllowableGap();
    7744   dValue2 = other->getAllowableGap();
    7745   fprintf(fp,"%d  double save_getAllowableGap = cbcModel->getAllowableGap();\n",dValue1==dValue2 ? 2 : 1);
    7746   fprintf(fp,"%d  cbcModel->setAllowableGap(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    7747   fprintf(fp,"%d  cbcModel->setAllowableGap(save_getAllowableGap);\n",dValue1==dValue2 ? 7 : 6);
    7748   dValue1 = this->getAllowableFractionGap();
    7749   dValue2 = other->getAllowableFractionGap();
    7750   fprintf(fp,"%d  double save_getAllowableFractionGap = cbcModel->getAllowableFractionGap();\n",dValue1==dValue2 ? 2 : 1);
    7751   fprintf(fp,"%d  cbcModel->setAllowableFractionGap(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    7752   fprintf(fp,"%d  cbcModel->setAllowableFractionGap(save_getAllowableFractionGap);\n",dValue1==dValue2 ? 7 : 6);
    7753   dValue1 = this->getMaximumSeconds();
    7754   dValue2 = other->getMaximumSeconds();
    7755   fprintf(fp,"%d  double save_cbcMaximumSeconds = cbcModel->getMaximumSeconds();\n",dValue1==dValue2 ? 2 : 1);
    7756   fprintf(fp,"%d  cbcModel->setMaximumSeconds(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    7757   fprintf(fp,"%d  cbcModel->setMaximumSeconds(save_cbcMaximumSeconds);\n",dValue1==dValue2 ? 7 : 6);
    7758 }
  • trunk/Cbc/src/CbcModel.hpp

    r354 r355  
    902902      If fixVariables true then bounds of continuous solver updated.
    903903      Returns objective value (worse than cutoff if not feasible)
    904       Previously computed objective value is now passed in (in case user does not do solve)
    905904 */
    906905  double checkSolution(double cutoff, const double * solution,
    907                        bool fixVariables, double originalObjValue);
     906                       bool fixVariables);
    908907  /** Test the current solution for feasiblility.
    909908
     
    12881287      3 bit (8) - fast analyze
    12891288      4 bit (16) - non-linear model and someone too lazy to code "times" correctly - so skip row check
    1290       5 bit (32) - keep names
    12911289  */
    12921290  /// Set special options
     
    14661464  void incrementStrongInfo(int numberTimes, int numberIterations,
    14671465                           int numberFixed, bool ifInfeasible);
    1468   /// Create C++ lines to get to current state
    1469   void generateCpp( FILE * fp,int options);
    14701466  //@}
    14711467
  • trunk/Cbc/src/CbcNode.cpp

    r354 r355  
    632632  for (i=0;i<numberCuts_;i++) {
    633633    addCuts[currentNumberCuts+i]= cuts_[i];
    634     if (cuts_[i]&&model->messageHandler()->logLevel()>4) {
     634    if (cuts_[i]&&model->messageHandler()->logLevel()>2) {
    635635      cuts_[i]->print();
    636636    }
     
    19731973    // for faster hot start
    19741974    saveClpOptions = osiclp->specialOptions();
    1975     osiclp->setSpecialOptions(saveClpOptions|8192);
     1975    osiclp->setSpecialOptions(saveClpOptions|1024);
    19761976  }
    19771977# else
     
    20402040  bool newWay = saveSearchStrategy2>98;
    20412041  int numberNotTrusted=0;
    2042   int numberStrongDone=0;
    2043   int numberUnfinished=0;
    2044   int numberStrongInfeasible=0;
    2045   int numberStrongIterations=0;
     2042  int numberStrongDone;
     2043  int numberUnfinished;
     2044  int numberStrongInfeasible;
     2045  int numberStrongIterations;
    20462046  while(!finished) {
    20472047    finished=true;
     
    21132113        if (infeasibility) {
    21142114          int iColumn = dynamicObject->columnNumber();
    2115           //double gap = saveUpper[iColumn]-saveLower[iColumn];
     2115          double gap = saveUpper[iColumn]-saveLower[iColumn];
    21162116          // Give precedence to ones with gap of 1.0
    2117           //assert(gap>0.0);
    2118           //infeasibility /= CoinMin(gap,100.0);
     2117          assert(gap>0.0);
     2118          infeasibility /= CoinMin(gap,100.0);
    21192119          if (!depth_&&false) {
    21202120            // try closest to 0.5
     
    24972497          doQuickly=false;
    24982498          numberTest=2*numberStrong;
    2499           skipAll=false;
    25002499        }
    25012500      } else if (searchStrategy!=3) {
     
    25122511            numberStrong=CoinMin(6*numberStrong,numberToDo);
    25132512          numberTest=numberStrong;
    2514           skipAll=false;
    25152513        }
    25162514        model->setStateOfSearch(2); // use min min
     
    25792577      }
    25802578      }
    2581 #if 0
    2582       // temp - always switch off
    2583       if (0) {
    2584         int numberIterations = model->getIterationCount();
    2585         int numberStrongIterations = model->numberStrongIterations();
    2586         if (numberStrongIterations>numberIterations+10000&&depth_>=5) {
    2587           skipAll=true;
    2588           newWay=false;
    2589           numberTest=0;
    2590           doQuickly=true;
    2591         }
    2592       }
    2593       // temp - always switch on
    2594       if (0) {
    2595         int numberIterations = model->getIterationCount();
    2596         int numberStrongIterations = model->numberStrongIterations();
    2597         if (2*numberStrongIterations<numberIterations||depth_<=5) {
    2598           skipAll=false;
    2599           newWay=false;
    2600           numberTest=CoinMax(numberTest,numberStrong);
    2601           doQuickly=false;
    2602         }
    2603       }
    2604 #endif
    26052579      px[0]=numberTest;
    26062580      px[1]=numberTest2;
     
    26142588        wantMiniTree=true;
    26152589      numberMini=0;
    2616       //if (skipAll&&numberTest==0&&doQuickly)
    2617       //numberToDo = 1; // trust previous stuff
    2618       bool couldChooseFirst = false ; //(skipAll&&numberTest==0&&doQuickly);
    26192590      for ( iDo=0;iDo<numberToDo;iDo++) {
    26202591        CbcStrongInfo choice;
     
    26662637        numberTest2--;
    26672638        if (!canSkip) {
    2668           //#ifndef RANGING
    2669           if (!doneHotStart) {
    2670             // Mark hot start
    2671             doneHotStart=true;
    2672             assert (auxiliaryInfo->warmStart());
    2673             solver->markHotStart();
    2674             xMark++;
    2675           }
    2676           //#endif
    2677           assert (!couldChooseFirst);
    26782639          numberTest--;
    26792640          if (!newWay)
     
    29202881            choice.upMovement = CoinMax(0.0,choice.upMovement);
    29212882            choice.downMovement = CoinMax(0.0,choice.downMovement);
    2922             if (couldChooseFirst)
    2923               printf("candidate %d up %g down %g sort %g\n",iDo,choice.upMovement,choice.downMovement,sort[iDo]);
    29242883#if ZERO_ONE==2
    29252884            // branch on 0-1 first (temp)
     
    29532912              decision->setBestCriterion(-1.0);
    29542913            double bestCriterion = -1.0;
    2955             //double gap = saveUpper[iColumn]-saveLower[iColumn];
     2914            double gap = saveUpper[iColumn]-saveLower[iColumn];
    29562915            // Give precedence to ones with gap of 1.0
    2957             //assert(gap>0.0);
    2958             double factor = 1.0; //changeFactor/CoinMin(gap,100.0);
     2916            assert(gap>0.0);
     2917            double factor = changeFactor/CoinMin(gap,100.0);
    29592918            int betterWay = decision->betterBranch(choice.possibleBranch,
    29602919                                                   branch_,
     
    29842943              choice.possibleBranch=NULL;
    29852944              branch_->way(betterWay);
    2986               if (couldChooseFirst)
    2987                 printf("choosing %d way %d\n",iDo,betterWay);
    29882945              bestChoice = choice.objectNumber;
    29892946              whichChoice = iDo;
     
    33313288    // for faster hot start
    33323289    saveClpOptions = osiclp->specialOptions();
    3333     osiclp->setSpecialOptions(saveClpOptions|8192);
     3290    osiclp->setSpecialOptions(saveClpOptions|1024);
    33343291  }
    33353292# else
  • trunk/Cbc/src/CbcStrategy.cpp

    r354 r355  
    433433    }
    434434  }
    435 // Create C++ lines to get to current state
    436 void
    437 CbcStrategyDefault::generateCpp( FILE * fp)
    438 {
    439   fprintf(fp,"0#include \"CbcStrategy.hpp\"\n");
    440   fprintf(fp,"3  CbcStrategyDefault strategy(%s,%d,%d,%d);\n",
    441           cutsOnlyAtRoot_ ? "true" : "false",
    442           numberStrong_,
    443           numberBeforeTrust_,
    444           printLevel_);
    445   fprintf(fp,"3  strategy.setupPreProcessing(%d,%d);\n",
    446           desiredPreProcess_,preProcessPasses_);
    447 }
    448435  model.setNumberStrong(numberStrong_);
    449436  model.setNumberBeforeTrust(numberBeforeTrust_);
  • trunk/Cbc/src/CbcStrategy.hpp

    r354 r355  
    5555                                        const double * boundChanges,
    5656                                        const CoinWarmStartDiff *basisDiff) const;
    57   /// Create C++ lines to get to current state
    58   virtual void generateCpp( FILE * fp) {};
    5957  /** After a CbcModel::resolve this can return a status
    6058      -1 no effect
     
    154152  inline int preProcessPasses() const
    155153  { return preProcessPasses_;};
    156   /// Create C++ lines to get to current state
    157   virtual void generateCpp( FILE * fp) ;
    158154
    159155protected:
  • trunk/Cbc/src/Cbc_ampl.cpp

    r354 r355  
    2828#include "unistd.h"
    2929#include <string>
    30 #include <cassert>
    3130/* so decodePhrase and clpCheck can access */
    3231static ampl_info * saveInfo=NULL;
     
    6968  }
    7069  return 0;
    71 }
    72 static void
    73 sos_kludge(int nsos, int *sosbeg, double *sosref)
    74 {
    75   // Adjust sosref if necessary to make monotonic increasing
    76   int i, j, k;
    77   double t, t1;
    78   for(i = j = 0; i++ < nsos; ) {
    79     k = sosbeg[i];
    80     t = sosref[j];
    81     while(++j < k) {
    82       t1 = sosref[j];
    83       t += 1e-10;
    84       if (t1 <= t)
    85         sosref[j] = t1 = t + 1e-10;
    86       t = t1;
    87     }
    88   }
    8970}
    9071static char xxxxxx[20];
     
    11394        { "down", 0, ASL_Sufkind_var | ASL_Sufkind_outonly },
    11495        { "priority", 0, ASL_Sufkind_var },
    115 #endif
    116         { "direction", 0, ASL_Sufkind_var },
    117         { "downPseudocost", 0, ASL_Sufkind_var | ASL_Sufkind_real },
    118         { "priority", 0, ASL_Sufkind_var },
    11996        { "ref", 0, ASL_Sufkind_var | ASL_Sufkind_real },
    12097        { "sos", 0, ASL_Sufkind_var },
     
    12299        { "sosno", 0, ASL_Sufkind_var | ASL_Sufkind_real },
    123100        { "sosref", 0, ASL_Sufkind_var | ASL_Sufkind_real },
     101#endif
     102        { "direction", 0, ASL_Sufkind_var },
     103        { "downPseudocost", 0, ASL_Sufkind_var | ASL_Sufkind_real },
     104        { "priority", 0, ASL_Sufkind_var },
    124105        { strdup("sstatus"), 0, ASL_Sufkind_var, 0 },
    125106        { strdup("sstatus"), 0, ASL_Sufkind_con, 0 },
     
    278259    usage_ASL(&Oinfo, 1);
    279260  nl = jac0dim(stub, 0);
     261  /*void * specialOrderedInfo = sos_add(nl,0);*/
    280262  suf_declare(suftab, sizeof(suftab)/sizeof(SufDecl));
    281263 
     
    295277  /* read linear model*/
    296278  f_read(nl,0);
    297   // see if any sos
    298   if (true) {
    299     char *sostype;
    300     int nsosnz, *sosbeg, *sosind, * sospri;
    301     double *sosref;
    302     int nsos;
    303     int i = ASL_suf_sos_explict_free;
    304     int copri[2], **p_sospri;
    305     copri[0] = 0;
    306     copri[1] = 0;
    307     p_sospri = &sospri;
    308     nsos = suf_sos(i, &nsosnz, &sostype, p_sospri, copri,
    309                    &sosbeg, &sosind, &sosref);
    310     if (nsos) {
    311       info->numberSos=nsos;
    312       info->sosType = (char *) malloc(nsos);
    313       info->sosPriority = (int *) malloc(nsos*sizeof(int));
    314       info->sosStart = (int *) malloc((nsos+1)*sizeof(int));
    315       info->sosIndices = (int *) malloc(nsosnz*sizeof(int));
    316       info->sosReference = (double *) malloc(nsosnz*sizeof(double));
    317       sos_kludge(nsos, sosbeg, sosref);
    318       for (int i=0;i<nsos;i++) {
    319         int ichar = sostype[i];
    320         assert (ichar=='1'||ichar=='2');
    321         info->sosType[i]=ichar-'0';
    322       }
    323       memcpy(info->sosPriority,sospri,nsos*sizeof(int));
    324       memcpy(info->sosStart,sosbeg,(nsos+1)*sizeof(int));
    325       memcpy(info->sosIndices,sosind,nsosnz*sizeof(int));
    326       memcpy(info->sosReference,sosref,nsosnz*sizeof(double));
    327     }
    328   }
    329279
    330280  /*sos_finish(&specialOrderedInfo, 0, &j, 0, 0, 0, 0, 0);*/
     
    412362    int foundLog=0;
    413363    int foundSleep=0;
    414     const char * something[]={"solve","branch","duals","primals","user"};
     364    const char * something[]={"solve","branch","duals","primals"};
    415365    for (i=0;i<info->numberArguments;i++) {
    416366      unsigned int j;
     
    502452  free(info->pseudoUp);
    503453  info->pseudoUp=NULL;
    504   free(info->sosType);
    505   info->sosType=NULL;
    506   free(info->sosPriority);
    507   info->sosPriority=NULL;
    508   free(info->sosStart);
    509   info->sosStart=NULL;
    510   free(info->sosIndices);
    511   info->sosIndices=NULL;
    512   free(info->sosReference);
    513   info->sosReference=NULL;
    514454  ASL_free(&asl);
    515455}
  • trunk/Cbc/src/Cbc_ampl.h

    r354 r355  
    99  int numberBinary;
    1010  int numberIntegers; /* non binary */
    11   int numberSos;
    1211  int numberElements;
    1312  int numberArguments;
     
    3231  double * pseudoDown;
    3332  double * pseudoUp;
    34   char * sosType;
    35   int * sosPriority;
    36   int * sosStart;
    37   int * sosIndices;
    38   double * sosReference;
    3933  char ** arguments;
    4034  char buffer[300];
  • trunk/Cbc/src/CoinSolve.cpp

    r354 r355  
    6464#include "CglMixedIntegerRounding2.hpp"
    6565#include "CglTwomir.hpp"
    66 #include "CglDuplicateRow.hpp"
    6766
    6867#include "CbcModel.hpp"
     
    8584static double totalTime=0.0;
    8685static void statistics(ClpSimplex * originalModel, ClpSimplex * model);
    87 static bool maskMatches(const int * starts, char ** masks,
    88                         std::string & check);
    89 static void generateCode(const char * fileName,int type,int preProcess);
     86static bool maskMatches(std::string & mask, std::string & check);
    9087//#############################################################################
    9188
     
    405402  }
    406403}
    407 static int outDupRow(OsiSolverInterface * solver)
    408 {
    409   CglDuplicateRow dupCuts(solver);
    410   CglTreeInfo info;
    411   info.level = 0;
    412   info.pass = 0;
    413   int numberRows = solver->getNumRows();
    414   info.formulation_rows = numberRows;
    415   info.inTree = false;
    416   info.strengthenRow= NULL;
    417   info.pass = 0;
    418   OsiCuts cs;
    419   dupCuts.generateCuts(*solver,cs,info);
    420   const int * duplicate = dupCuts.duplicate();
    421   // Get rid of duplicate rows
    422   int * which = new int[numberRows];
    423   int numberDrop=0;
    424   for (int iRow=0;iRow<numberRows;iRow++) {
    425     if (duplicate[iRow]==-2||duplicate[iRow]>=0)
    426       which[numberDrop++]=iRow;
    427   }
    428   if (numberDrop) {
    429     solver->deleteRows(numberDrop,which);
    430   }
    431   delete [] which;
    432   // see if we have any column cuts
    433   int numberColumnCuts = cs.sizeColCuts() ;
    434   const double * columnLower = solver->getColLower();
    435   const double * columnUpper = solver->getColUpper();
    436   for (int k = 0;k<numberColumnCuts;k++) {
    437     OsiColCut * thisCut = cs.colCutPtr(k) ;
    438     const CoinPackedVector & lbs = thisCut->lbs() ;
    439     const CoinPackedVector & ubs = thisCut->ubs() ;
    440     int j ;
    441     int n ;
    442     const int * which ;
    443     const double * values ;
    444     n = lbs.getNumElements() ;
    445     which = lbs.getIndices() ;
    446     values = lbs.getElements() ;
    447     for (j = 0;j<n;j++) {
    448       int iColumn = which[j] ;
    449       if (values[j]>columnLower[iColumn])
    450         solver->setColLower(iColumn,values[j]) ;
    451     }
    452     n = ubs.getNumElements() ;
    453     which = ubs.getIndices() ;
    454     values = ubs.getElements() ;
    455     for (j = 0;j<n;j++) {
    456       int iColumn = which[j] ;
    457       if (values[j]<columnUpper[iColumn])
    458         solver->setColUpper(iColumn,values[j]) ;
    459     }
    460   }
    461   return numberDrop;
    462 }
    463404int main (int argc, const char *argv[])
    464405{
     
    489430    double * pseudoDown=NULL;
    490431    double * pseudoUp=NULL;
    491     double * solutionIn = NULL;
    492     int * prioritiesIn = NULL;
    493432#ifdef CBC_AMPL
    494433    ampl_info info;
     
    556495    int outputFormat=2;
    557496    int slpValue=-1;
    558     int cppValue=-1;
    559497    int printOptions=0;
    560498    int printMode=0;
     
    568506    int preSolve=5;
    569507    int preProcess=4;
    570     bool useStrategy=false;
    571508    bool preSolveFile=false;
    572509   
     
    644581    parameters[whichParam(CUTSSTRATEGY,numberParameters,parameters)].setCurrentOption("on");
    645582    parameters[whichParam(HEURISTICSTRATEGY,numberParameters,parameters)].setCurrentOption("on");
    646     int doSOS=1;
    647583    int verbose=0;
    648584    CglGomory gomoryGen;
     
    719655    bool useLocalTree=false;
    720656    parameters[whichParam(COSTSTRATEGY,numberParameters,parameters)].setCurrentOption("off");
    721     int useCosts=0;
    722     // don't use input solution
    723     int useSolution=0;
     657    bool useCosts=false;
    724658   
    725659    // total number of commands read
     
    812746        }
    813747        if (type==GENERALQUERY) {
    814           bool evenHidden=false;
    815           if ((verbose&8)!=0) {
    816             // even hidden
    817             evenHidden = true;
    818             verbose &= ~8;
    819           }
    820748#ifdef CBC_AMPL
    821749          if (verbose<4&&usingAmpl)
     
    859787            for ( iParam=0; iParam<numberParameters; iParam++ ) {
    860788              int type = parameters[iParam].type();
    861               if ((parameters[iParam].displayThis()||evenHidden)&&
    862                   type>=limits[iType]
     789              if (parameters[iParam].displayThis()&&type>=limits[iType]
    863790                  &&type<limits[iType+1]) {
    864791                // but skip if not useful for ampl (and in ampl mode)
     
    976903              else if (parameters[iParam].type()==SLPVALUE)
    977904                slpValue = value;
    978               else if (parameters[iParam].type()==CPP)
    979                 cppValue = value;
    980905              else if (parameters[iParam].type()==PRESOLVEOPTIONS)
    981906                presolveOptions = value;
     
    11361061              crossover=action;
    11371062              break;
    1138             case SOS:
    1139               doSOS=action;
    1140               break;
    11411063            case GOMORYCUTS:
    11421064              defaultSettings=false; // user knows what she is doing
     
    12241146              break;
    12251147            case COSTSTRATEGY:
    1226               useCosts=action;
     1148              if (action!=1&&action!=0) {
     1149                printf("Pseudo costs not implemented yet\n");
     1150              } else {
     1151                useCosts=action;
     1152              }
    12271153              break;
    12281154            case PREPROCESS:
    12291155              preProcess = action;
    1230               break;
    1231             case USESOLUTION:
    1232               useSolution = action;
    12331156              break;
    12341157            default:
     
    15281451            }
    15291452            break;
    1530           case OUTDUPROWS:
    1531             if (goodModel) {
    1532               int nOut = outDupRow(clpSolver);
    1533               if (nOut&&!noPrinting)
    1534                 printf("%d rows eliminated\n",nOut);
    1535             } else {
    1536               std::cout<<"** Current model not valid"<<std::endl;
    1537             }
    1538             break;
    15391453          case NETWORK:
    15401454            if (goodModel) {
     
    15831497                si->setSpecialOptions(0x40000000);
    15841498              }
    1585               if (!miplib) {
     1499              if (!miplib)
    15861500                model.initialSolve();
    1587                 OsiSolverInterface * solver = model.solver();
    1588                 OsiClpSolverInterface * si =
    1589                   dynamic_cast<OsiClpSolverInterface *>(solver) ;
    1590                 if (si->getModelPtr()->tightenPrimalBounds()!=0) {
    1591                   std::cout<<"Problem is infeasible - tightenPrimalBounds!"<<std::endl;
    1592                   exit(1);
    1593                 }
    1594                 si->getModelPtr()->dual();  // clean up
    1595               }
    15961501              // If user made settings then use them
    15971502              if (!defaultSettings) {
     
    16791584              time1 = time2;
    16801585              double timeLeft = babModel->getMaximumSeconds();
    1681               int numberOriginalColumns = babModel->solver()->getNumCols();
    1682 #ifdef CBC_AMPL
    1683               if (usingAmpl&&info.numberSos&&doSOS) {
    1684                 // SOS
    1685                 assert (!preProcess); // do later
    1686                 int numberSOS = info.numberSos;
    1687                 int numberIntegers = babModel->numberIntegers();
    1688                 int numberColumns = babModel->getNumCols();
    1689                 /* model may not have created objects
    1690                    If none then create
    1691                 */
    1692                 if (!numberIntegers||!babModel->numberObjects()) {
    1693                   int type = (pseudoUp) ? 1 : 0;
    1694                   babModel->findIntegers(true,type);
    1695                   numberIntegers = babModel->numberIntegers();
    1696                 }
    1697                 // Do sets and priorities
    1698                 CbcObject ** objects = new CbcObject * [numberSOS];
    1699                 const int * starts = info.sosStart;
    1700                 const int * which = info.sosIndices;
    1701                 const char * type = info.sosType;
    1702                 const double * weight = info.sosReference;
    1703                 // see if any priorities
    1704                 int i;
    1705                 bool gotPriorities=false;
    1706                 int * priorities=info.priorities;
    1707                 if (priorities) {
    1708                   for (i=0;i<numberColumns;i++) {
    1709                     if (priorities[i]) {
    1710                       gotPriorities=true;
    1711                       break;
    1712                     }
    1713                   }
    1714                 }
    1715                 priorities=info.sosPriority;
    1716                 if (priorities) {
    1717                   for (i=0;i<numberSOS;i++) {
    1718                     if (priorities[i]) {
    1719                       gotPriorities=true;
    1720                       break;
    1721                     }
    1722                   }
    1723                 }
    1724                 int iSOS;
    1725                 for (iSOS =0;iSOS<numberSOS;iSOS++) {
    1726                   int iStart = starts[iSOS];
    1727                   int n=starts[iSOS+1]-iStart;
    1728                   objects[iSOS] = new CbcSOS(babModel,n,which+iStart,weight+iStart,
    1729                                              iSOS,type[iSOS]);
    1730                   // higher for set
    1731                   objects[iSOS]->setPriority(10);
    1732                   if (gotPriorities&&info.sosPriority&&info.sosPriority[iSOS])
    1733                     objects[iSOS]->setPriority(info.sosPriority[iSOS]);
    1734                 }
    1735                 babModel->addObjects(numberSOS,objects);
    1736                 for (iSOS=0;iSOS<numberSOS;iSOS++)
    1737                   delete objects[iSOS];
    1738                 delete [] objects;
    1739               }
    1740 #endif
    1741               if (preProcess==6) {
    1742                 // use strategy instead
    1743                 preProcess=0;
    1744                 useStrategy=true;
    1745               }
    17461586              if (preProcess&&type==BAB) {
    17471587                saveSolver=babModel->solver()->clone();
     
    18391679                  if (babModel->isInteger(iColumn)) {
    18401680                    sort[n]=n;
    1841                     if (useCosts==1)
    1842                       dsort[n++]=-objective[iColumn];
    1843                     else
    1844                       dsort[n++]=iColumn;
     1681                    dsort[n++]=-objective[iColumn];
    18451682                  }
    18461683                }
     
    20421879                  pseudoDown=info.pseudoDown;
    20431880                  pseudoUp=info.pseudoUp;
    2044                   solutionIn=info.primalSolution;
    2045                   prioritiesIn = info.priorities;
    20461881                }
    20471882#endif               
    2048                 const int * originalColumns = preProcess ? process.originalColumns() : NULL;
    2049                 if (solutionIn&&useSolution) {
    2050                   if (preProcess) {
    2051                     int numberColumns = babModel->getNumCols();
    2052                     // extend arrays in case SOS
    2053                     int n = originalColumns[numberColumns-1]+1;
    2054                     int nSmaller = CoinMin(n,numberOriginalColumns);
    2055                     double * solutionIn2 = new double [n];
    2056                     int * prioritiesIn2 = new int[n];
    2057                     int i;
    2058                     for (i=0;i<nSmaller;i++) {
    2059                       solutionIn2[i]=solutionIn[i];
    2060                       prioritiesIn2[i]=prioritiesIn[i];
    2061                     }
    2062                     for (;i<n;i++) {
    2063                       solutionIn2[i]=0.0;
    2064                       prioritiesIn2[i]=1000000;
    2065                     }
    2066                     int iLast=-1;
    2067                     for (i=0;i<numberColumns;i++) {
    2068                       int iColumn = originalColumns[i];
    2069                       assert (iColumn>iLast);
    2070                       iLast=iColumn;
    2071                       solutionIn2[i]=solutionIn2[iColumn];
    2072                       if (prioritiesIn)
    2073                         prioritiesIn2[i]=prioritiesIn2[iColumn];
    2074                     }
    2075                     babModel->setHotstartSolution(solutionIn2,prioritiesIn2);
    2076                     delete [] solutionIn2;
    2077                     delete [] prioritiesIn2;
    2078                   } else {
    2079                     babModel->setHotstartSolution(solutionIn,prioritiesIn);
    2080                   }
    2081                 }
     1883                const int * originalColumns = NULL;
     1884                if (preProcess)
     1885                  originalColumns = process.originalColumns();
    20821886                if (preProcess&&process.numberSOS()) {
    20831887                  int numberSOS = process.numberSOS();
     
    21011905                    int iColumn = oldObjects[iObj]->columnNumber();
    21021906                    assert (iColumn>=0);
    2103                     if (iColumn>=numberOriginalColumns)
    2104                       continue;
    21051907                    if (originalColumns)
    21061908                      iColumn = originalColumns[iColumn];
     
    21111913                        dynamic_cast <CbcSimpleIntegerPseudoCost *>(oldObjects[iObj]) ;
    21121914                      assert (obj1a);
    2113                       if (pseudoDown[iColumn]>0.0)
    2114                         obj1a->setDownPseudoCost(pseudoDown[iColumn]);
    2115                       if (pseudoUp[iColumn]>0.0)
    2116                         obj1a->setUpPseudoCost(pseudoUp[iColumn]);
     1915                      obj1a->setDownPseudoCost(pseudoDown[iColumn]);
     1916                      obj1a->setUpPseudoCost(pseudoUp[iColumn]);
    21171917                    }
    21181918                  }
     
    21471947                  int numberObjects = babModel->numberObjects();
    21481948                  for (int iObj = 0;iObj<numberObjects;iObj++) {
    2149                     // skip sos
    2150                     CbcSOS * objSOS =
    2151                       dynamic_cast <CbcSOS *>(objects[iObj]) ;
    2152                     if (objSOS)
    2153                       continue;
    21541949                    int iColumn = objects[iObj]->columnNumber();
    21551950                    assert (iColumn>=0);
     
    21671962                        dynamic_cast <CbcSimpleIntegerPseudoCost *>(objects[iObj]) ;
    21681963                      assert (obj1a);
    2169                       if (pseudoDown[iColumn]>0.0)
    2170                         obj1a->setDownPseudoCost(pseudoDown[iColumn]);
    2171                       if (pseudoUp[iColumn]>0.0)
    2172                         obj1a->setUpPseudoCost(pseudoUp[iColumn]);
     1964                      obj1a->setDownPseudoCost(pseudoDown[iColumn]);
     1965                      obj1a->setUpPseudoCost(pseudoUp[iColumn]);
    21731966                    }
    21741967                  }
    21751968                }
    2176                 int statistics = (printOptions>0) ? printOptions: 0;
    21771969#ifdef CBC_AMPL
    21781970                if (!usingAmpl) {
     
    21861978                  free(pseudoUp);
    21871979                  pseudoUp=NULL;
    2188                   free(solutionIn);
    2189                   solutionIn=NULL;
    2190                   free(prioritiesIn);
    2191                   prioritiesIn=NULL;
    21921980#ifdef CBC_AMPL
    21931981                }
    21941982#endif               
    2195                 if (cppValue>=0) {
    2196                   int prepro = useStrategy ? -1 : preProcess;
    2197                   // generate code
    2198                   FILE * fp = fopen("user_driver.cpp","w");
    2199                   if (fp) {
    2200                     // generate enough to do BAB
    2201                     babModel->generateCpp(fp,1);
    2202                     OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (babModel->solver());
    2203                     // Make general so do factorization
    2204                     int factor = osiclp->getModelPtr()->factorizationFrequency();
    2205                     osiclp->getModelPtr()->setFactorizationFrequency(200);
    2206                     osiclp->generateCpp(fp);
    2207                     osiclp->getModelPtr()->setFactorizationFrequency(factor);
    2208                     //solveOptions.generateCpp(fp);
    2209                     fclose(fp);
    2210                     // now call generate code
    2211                     generateCode("user_driver.cpp",cppValue,prepro);
    2212                   } else {
    2213                     std::cout<<"Unable to open file user_driver.cpp"<<std::endl;
    2214                   }
    2215                 }
    2216                 if (useStrategy) {
    2217                   CbcStrategyDefault strategy(true,5,5);
    2218                   strategy.setupPreProcessing(1);
    2219                   babModel->setStrategy(strategy);
    2220                 }
     1983                int statistics = (printOptions>0) ? printOptions: 0;
    22211984                babModel->branchAndBound(statistics);
    22221985              } else if (type==MIPLIB) {
     
    23842147                free(pseudoUp);
    23852148                pseudoUp=NULL;
    2386                 free(solutionIn);
    2387                 solutionIn=NULL;
    2388                 free(prioritiesIn);
    2389                 prioritiesIn=NULL;
    23902149#ifdef CBC_AMPL
    23912150              }
     
    27222481              if (fp) {
    27232482                // can open - lets go for it
    2724                 std::string headings[]={"name","number","direction","priority","up","down",
    2725                                         "solution","priin"};
    2726                 int got[]={-1,-1,-1,-1,-1,-1,-1,-1};
    2727                 int order[8];
    2728                 assert(sizeof(got)==sizeof(order));
     2483                std::string headings[]={"name","number","direction","priority","up","down"};
     2484                int order[]={-1,-1,-1,-1,-1,-1};
    27292485                int nAcross=0;
    27302486                char line[1000];
     
    27402496                      put++;
    27412497                    }
    2742                     pos++;
    27432498                  }
    27442499                  *put='\0';
     
    27502505                    if (comma)
    27512506                      *comma='\0';
    2752                     for (i=0;i<(int) (sizeof(got)/sizeof(int));i++) {
     2507                    for (i=0;i<(int) (sizeof(order)/sizeof(int));i++) {
    27532508                      if (headings[i]==pos) {
    2754                         if (got[i]<0) {
    2755                           order[nAcross]=i;
    2756                           got[i]=nAcross++;
     2509                        if (order[i]<0) {
     2510                          order[i]=nAcross++;
    27572511                        } else {
    27582512                          // duplicate
     
    27622516                      }
    27632517                    }
    2764                     if (i==(int) (sizeof(got)/sizeof(int)))
     2518                    if (i==(int) (sizeof(order)/sizeof(int)))
    27652519                      good=false;
    27662520                    if (comma) {
     
    27712525                    }
    27722526                  }
    2773                   if (got[0]<0&&got[1]<0)
     2527                  if (order[0]<0&&order[1]<0)
    27742528                    good=false;
    2775                   if (got[0]>=0&&got[1]>=0)
     2529                  if (order[0]>=0&&order[1]>=0)
    27762530                    good=false;
    2777                   if (got[0]>=0&&!lpSolver->lengthNames())
     2531                  if (order[0]>=0&&!lpSolver->lengthNames())
    27782532                    good=false;
    27792533                  if (good) {
     
    27832537                    branchDirection = (int *) malloc(numberColumns*sizeof(int));
    27842538                    priorities= (int *) malloc(numberColumns*sizeof(int));
    2785                     free(solutionIn);
    2786                     solutionIn=NULL;
    2787                     free(prioritiesIn);
    2788                     prioritiesIn=NULL;
    27892539                    int iColumn;
    2790                     if (got[6]>=0) {
    2791                       solutionIn = (double *) malloc(numberColumns*sizeof(double));
    2792                       CoinZeroN(solutionIn,numberColumns);
    2793                     }
    2794                     if (got[7]>=0) {
    2795                       prioritiesIn = (int *) malloc(numberColumns*sizeof(int));
    2796                       for (iColumn=0;iColumn<numberColumns;iColumn++)
    2797                         prioritiesIn[iColumn]=10000;
    2798                     }
    27992540                    for (iColumn=0;iColumn<numberColumns;iColumn++) {
    28002541                      columnNames[iColumn] =
     
    28182559                      int pri=0;
    28192560                      int dir=0;
    2820                       double solValue=COIN_DBL_MAX;
    2821                       int priValue=1000000;
    28222561                      char * pos = line;
    28232562                      char * put = line;
     
    28272566                          put++;
    28282567                        }
    2829                         pos++;
    28302568                      }
    28312569                      *put='\0';
     
    28842622                          down = atof(pos);
    28852623                          break;
    2886                           // sol value
    2887                         case 6:
    2888                           solValue = atof(pos);
    2889                           break;
    2890                           // priority in value
    2891                         case 7:
    2892                           priValue = atoi(pos);
    2893                           break;
    28942624                        }
    28952625                        if (comma) {
     
    29232653                        branchDirection[iColumn]=dir;
    29242654                        priorities[iColumn]=pri;
    2925                         if (solValue!=COIN_DBL_MAX) {
    2926                           assert (solutionIn);
    2927                           solutionIn[iColumn]=solValue;
    2928                         }
    2929                         if (priValue!=1000000) {
    2930                           assert (prioritiesIn);
    2931                           prioritiesIn[iColumn]=priValue;
    2932                         }
    29332655                      } else {
    29342656                        nBadName++;
     
    33573079            }
    33583080            break;
    3359           case USERCLP:
    3360             // Replace the sample code by whatever you want
    3361             if (goodModel) {
    3362               printf("Dummy user clp code - model has %d rows and %d columns\n",
    3363                      lpSolver->numberRows(),lpSolver->numberColumns());
    3364             }
    3365             break;
    3366           case USERCBC:
    3367             // Replace the sample code by whatever you want
    3368             if (goodModel) {
    3369               printf("Dummy user cbc code - model has %d rows and %d columns\n",
    3370                      model.getNumRows(),model.getNumCols());
    3371   // Reduce printout
    3372   //solver1.setHintParam(OsiDoReducePrint,true,OsiHintTry);
    3373   OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (model.solver());
    3374   // go faster stripes
    3375   if (osiclp&&0) {
    3376     // Turn this off if you get problems
    3377     // Used to be automatically set
    3378     osiclp->setSpecialOptions(128);
    3379     if(osiclp->getNumRows()<300&&osiclp->getNumCols()<500) {
    3380       //osiclp->setupForRepeatedUse(2,0);
    3381       osiclp->setupForRepeatedUse(0,0);
    3382     }
    3383   }
    3384   // Allow rounding heuristic
    3385 
    3386   CbcRounding heuristic1(model);
    3387   model.addHeuristic(&heuristic1);
    3388 
    3389   // Do initial solve to continuous
    3390   ClpPrimalColumnSteepest steepest(5);
    3391   osiclp->getModelPtr()->setPrimalColumnPivotAlgorithm(steepest);
    3392   osiclp->getModelPtr()->setPerturbation(50);
    3393   osiclp->getModelPtr()->setInfeasibilityCost(1.0e9);
    3394   osiclp->setHintParam(OsiDoPresolveInInitial,false,OsiHintTry);
    3395   osiclp->setHintParam(OsiDoDualInInitial,false,OsiHintTry);
    3396   //osiclp->setHintParam(OsiDoDualInResolve,false,OsiHintTry);
    3397   model.setSpecialOptions(model.specialOptions()|4);
    3398   osiclp->getModelPtr()->defaultFactorizationFrequency();
    3399   {
    3400     ClpSimplex * clp = osiclp->getModelPtr();
    3401     // fix integers to 1
    3402     int numberColumns = clp->numberColumns();
    3403     double * lower = clp->columnLower();
    3404     int i;
    3405     for (i=0;i<numberColumns;i++) {
    3406       if (osiclp->isInteger(i))
    3407         lower[i]=1.0;
    3408     }
    3409     clp->primal();
    3410     double objValue = clp->objectiveValue();
    3411     osiclp->setDblParam(OsiDualObjectiveLimit,objValue+1.0e-4);
    3412     // unfix integers
    3413     for (i=0;i<numberColumns;i++) {
    3414       if (osiclp->isInteger(i))
    3415         lower[i]=0.0;
    3416     }
    3417     clp->primal();
    3418     //clp->dual();
    3419     int nArt=0;
    3420     int nFixed0=0,nFixed1=0;
    3421     double gap=objValue-clp->objectiveValue();
    3422     // for those at one fix anyway
    3423     double gap2=1.0;
    3424     const double * solution = clp->primalColumnSolution();
    3425     const double * dj = clp->dualColumnSolution();
    3426     const double * objective = clp->objective();
    3427     double * upper = clp->columnUpper();
    3428     for (i=0;i<numberColumns;i++) {
    3429       if (objective[i]>1.0e5&&solution[i]>1.0e-8)
    3430         nArt++;
    3431       if (osiclp->isInteger(i)) {
    3432         if(dj[i]>gap+1.0e-4) {
    3433           nFixed0++;
    3434           upper[i]=0.0;
    3435         }
    3436         if(-dj[i]>gap2+1.0e-4) {
    3437           nFixed1++;
    3438         lower[i]=1.0;
    3439         }
    3440       }
    3441     }
    3442     printf("%d artificials, %d fixed to 0, %d fixed to 1\n",nArt,nFixed0,nFixed1);
    3443     //osiclp->getModelPtr()->setPerturbation(100);
    3444     osiclp->setWarmStart(NULL); // set basis in osiclp
    3445   }
    3446   osiclp->initialSolve();
    3447 
    3448   // Switch off strong branching if wanted
    3449   // model.setNumberStrong(0);
    3450   // Do more strong branching if small
    3451   model.setNumberStrong(0);
    3452   model.setNumberBeforeTrust(0);
    3453 
    3454   // TEMP - set gap - better to see if no improvement in last few nodes
    3455   model.setAllowableGap(600.0);
    3456   // message levels
    3457   model.messageHandler()->setLogLevel(2);
    3458   model.solver()->messageHandler()->setLogLevel(2);
    3459   // Do complete search
    3460  
    3461   model.branchAndBound();
    3462             }
    3463             break;
    34643081          case HELP:
    34653082            std::cout<<"Coin Solver version "<<CBCVERSION
     
    35293146                sprintf(format,"%%-%ds",CoinMax(lengthName,8));
    35303147                bool doMask = (printMask!=""&&lengthName);
    3531                 int * maskStarts=NULL;
    3532                 int maxMasks=0;
    3533                 char ** masks =NULL;
    3534                 if (doMask) {
    3535                   int nAst =0;
    3536                   const char * pMask2 = printMask.c_str();
    3537                   char pMask[100];
    3538                   int iChar;
    3539                   int lengthMask = strlen(pMask2);
    3540                   assert (lengthMask<100);
    3541                   if (*pMask2=='"') {
    3542                     if (pMask2[lengthMask-1]!='"') {
    3543                       printf("mismatched \" in mask %s\n",pMask2);
    3544                       break;
    3545                     } else {
    3546                       strcpy(pMask,pMask2+1);
    3547                       *strchr(pMask,'"')='\0';
    3548                     }
    3549                   } else if (*pMask2=='\'') {
    3550                     if (pMask2[lengthMask-1]!='\'') {
    3551                       printf("mismatched ' in mask %s\n",pMask2);
    3552                       break;
    3553                     } else {
    3554                       strcpy(pMask,pMask2+1);
    3555                       *strchr(pMask,'\'')='\0';
    3556                     }
    3557                   } else {
    3558                     strcpy(pMask,pMask2);
    3559                   }
    3560                   if (lengthMask>lengthName) {
    3561                     printf("mask %s too long - skipping\n",pMask);
    3562                     break;
    3563                   }
    3564                   maxMasks = 1;
    3565                   for (iChar=0;iChar<lengthMask;iChar++) {
    3566                     if (pMask[iChar]=='*') {
    3567                       nAst++;
    3568                       maxMasks *= (lengthName+1);
    3569                     }
    3570                   }
    3571                   int nEntries = 1;
    3572                   maskStarts = new int[lengthName+2];
    3573                   masks = new char * [maxMasks];
    3574                   char ** newMasks = new char * [maxMasks];
    3575                   int i;
    3576                   for (i=0;i<maxMasks;i++) {
    3577                     masks[i] = new char[lengthName+1];
    3578                     newMasks[i] = new char[lengthName+1];
    3579                   }
    3580                   strcpy(masks[0],pMask);
    3581                   for (int iAst=0;iAst<nAst;iAst++) {
    3582                     int nOldEntries = nEntries;
    3583                     nEntries=0;
    3584                     for (int iEntry = 0;iEntry<nOldEntries;iEntry++) {
    3585                       char * oldMask = masks[iEntry];
    3586                       char * ast = strchr(oldMask,'*');
    3587                       assert (ast);
    3588                       int length = strlen(oldMask)-1;
    3589                       int nBefore = ast-oldMask;
    3590                       int nAfter = length-nBefore;
    3591                       // and add null
    3592                       nAfter++;
    3593                       for (int i=0;i<=lengthName-length;i++) {
    3594                         char * maskOut = newMasks[nEntries];
    3595                         memcpy(maskOut,oldMask,nBefore);
    3596                         for (int k=0;k<i;k++)
    3597                           maskOut[k+nBefore]='?';
    3598                         memcpy(maskOut+nBefore+i,ast+1,nAfter);
    3599                         nEntries++;
    3600                         assert (nEntries<=maxMasks);
    3601                       }
    3602                     }
    3603                     char ** temp = masks;
    3604                     masks = newMasks;
    3605                     newMasks = temp;
    3606                   }
    3607                   // Now extend and sort
    3608                   int * sort = new int[nEntries];
    3609                   for (i=0;i<nEntries;i++) {
    3610                     char * maskThis = masks[i];
    3611                     int length = strlen(maskThis);
    3612                     while (maskThis[length-1]==' ')
    3613                       length--;
    3614                     maskThis[length]='\0';
    3615                     sort[i]=length;
    3616                   }
    3617                   CoinSort_2(sort,sort+nEntries,masks);
    3618                   int lastLength=-1;
    3619                   for (i=0;i<nEntries;i++) {
    3620                     int length = sort[i];
    3621                     while (length>lastLength)
    3622                       maskStarts[++lastLength] = i;
    3623                   }
    3624                   maskStarts[++lastLength]=nEntries;
    3625                   delete [] sort;
    3626                   for (i=0;i<maxMasks;i++)
    3627                     delete [] newMasks[i];
    3628                   delete [] newMasks;
    3629                 }
    36303148                if (printMode>2) {
    36313149                  for (iRow=0;iRow<numberRows;iRow++) {
     
    36403158                      type=3;
    36413159                    }
    3642                     if (doMask&&!maskMatches(maskStarts,masks,rowNames[iRow]))
     3160                    if (doMask&&!maskMatches(printMask,rowNames[iRow]))
    36433161                      type =0;
    36443162                    if (type) {
     
    36753193                         &&printMode==1)
    36763194                      type=0;
    3677                     if (doMask&&!maskMatches(maskStarts,masks,
    3678                                              columnNames[iColumn]))
     3195                    if (doMask&&!maskMatches(printMask,columnNames[iColumn]))
    36793196                      type =0;
    36803197                    if (type) {
     
    37353252                if (fp!=stdout)
    37363253                  fclose(fp);
    3737                 if (masks) {
    3738                   delete [] maskStarts;
    3739                   for (int i=0;i<maxMasks;i++)
    3740                     delete [] masks[i];
    3741                   delete [] masks;
    3742                 }
    37433254              } else {
    37443255                std::cout<<"Unable to open file "<<fileName<<std::endl;
     
    41273638  breakdown("Objective",numberColumns,objective);
    41283639}
    4129 static bool maskMatches(const int * starts, char ** masks,
    4130                         std::string & check)
     3640static bool maskMatches(std::string & mask, std::string & check)
    41313641{
    41323642  // back to char as I am old fashioned
     3643  const char * maskC = mask.c_str();
    41333644  const char * checkC = check.c_str();
    4134   int length = strlen(checkC);
    4135   while (checkC[length-1]==' ')
    4136     length--;
    4137   for (int i=starts[length];i<starts[length+1];i++) {
    4138     char * thisMask = masks[i];
    4139     int k;
    4140     for ( k=0;k<length;k++) {
    4141       if (thisMask[k]!='?'&&thisMask[k]!=checkC[k])
    4142         break;
    4143     }
    4144     if (k==length)
    4145       return true;
     3645  int length = strlen(maskC);
     3646  int lengthCheck;
     3647  for (lengthCheck=length-1;lengthCheck>=0;lengthCheck--) {
     3648    if (maskC[lengthCheck]!='*')
     3649      break;
    41463650  }
    4147   return false;
    4148 }
    4149 static void clean(char * temp)
    4150 {
    4151   char * put = temp;
    4152   while (*put>=' ')
    4153     put++;
    4154   *put='\0';
    4155 }
    4156 static void generateCode(const char * fileName,int type,int preProcess)
    4157 {
    4158   // options on code generation
    4159   bool sizecode = (type&4)!=0;
    4160   type &= 3;
    4161   FILE * fp = fopen(fileName,"r");
    4162   assert (fp);
    4163   int numberLines=0;
    4164 #define MAXLINES 5000
    4165 #define MAXONELINE 200
    4166   char line[MAXLINES][MAXONELINE];
    4167   strcpy(line[numberLines++],"0#if defined(_MSC_VER)");
    4168   strcpy(line[numberLines++],"0// Turn off compiler warning about long names");
    4169   strcpy(line[numberLines++],"0#  pragma warning(disable:4786)");
    4170   strcpy(line[numberLines++],"0#endif\n");
    4171   strcpy(line[numberLines++],"0#include <cassert>");
    4172   strcpy(line[numberLines++],"0#include <iomanip>");
    4173   strcpy(line[numberLines++],"0#include \"OsiClpSolverInterface.hpp\"");
    4174   strcpy(line[numberLines++],"0#include \"CbcModel.hpp\"");
    4175   strcpy(line[numberLines++],"0#include \"CbcCutGenerator.hpp\"");
    4176   strcpy(line[numberLines++],"0#include \"CbcStrategy.hpp\"");
    4177   strcpy(line[numberLines++],"0#include \"CglPreProcess.hpp\"");
    4178   strcpy(line[numberLines++],"0#include \"CoinTime.hpp\"");
    4179   while (fgets(line[numberLines],MAXONELINE,fp)) {
    4180     assert (numberLines<MAXLINES);
    4181     clean(line[numberLines]);
    4182     numberLines++;
    4183   }
    4184   fclose(fp);
    4185   strcpy(line[numberLines++],"0\nint main (int argc, const char *argv[])\n{");
    4186   strcpy(line[numberLines++],"0  OsiClpSolverInterface solver1;");
    4187   strcpy(line[numberLines++],"0  int status=1;");
    4188   strcpy(line[numberLines++],"0  if (argc<2)");
    4189   strcpy(line[numberLines++],"0    std::cout<<\"Please give file name\"<<std::endl;");
    4190   strcpy(line[numberLines++],"0  else");
    4191   strcpy(line[numberLines++],"0    status=solver1.readMps(argv[1],\"\");");
    4192   strcpy(line[numberLines++],"0  if (status) {");
    4193   strcpy(line[numberLines++],"0    std::cout<<\"Bad readMps \"<<argv[1]<<std::endl;");
    4194   strcpy(line[numberLines++],"0    exit(1);");
    4195   strcpy(line[numberLines++],"0  }\n");
    4196   strcpy(line[numberLines++],"0  double time1 = CoinCpuTime();");
    4197   strcpy(line[numberLines++],"0  CbcModel model(solver1);");
    4198   strcpy(line[numberLines++],"0  // Now do requested saves and modifications");
    4199   strcpy(line[numberLines++],"0  CbcModel * cbcModel = & model;");
    4200   strcpy(line[numberLines++],"0  OsiSolverInterface * osiModel = model.solver();");
    4201   strcpy(line[numberLines++],"0  OsiClpSolverInterface * osiclpModel = dynamic_cast< OsiClpSolverInterface*> (osiModel);");
    4202   strcpy(line[numberLines++],"0  ClpSimplex * clpModel = osiclpModel->getModelPtr();");
    4203   // add in comments about messages
    4204   strcpy(line[numberLines++],"3  // You can save some time by switching off message building");
    4205   strcpy(line[numberLines++],"3  // clpModel->messagesPointer()->setDetailMessages(100,10000,(int *) NULL);");
    4206   strcpy(line[numberLines++],"5  cbcModel->initialSolve();");
    4207   strcpy(line[numberLines++],"5  if (clpModel->tightenPrimalBounds()!=0) {");
    4208   strcpy(line[numberLines++],"5    std::cout<<\"Problem is infeasible - tightenPrimalBounds!\"<<std::endl;");
    4209   strcpy(line[numberLines++],"5    exit(1);");
    4210   strcpy(line[numberLines++],"5  }");
    4211   strcpy(line[numberLines++],"5  clpModel->dual();  // clean up");
    4212   if (sizecode) {
    4213     // override some settings
    4214     strcpy(line[numberLines++],"5  // compute some things using problem size");
    4215     strcpy(line[numberLines++],"5  cbcModel->setMinimumDrop(min(5.0e-2,");
    4216     strcpy(line[numberLines++],"5       fabs(cbcModel->getMinimizationObjValue())*1.0e-3+1.0e-4));");
    4217     strcpy(line[numberLines++],"5  if (cbcModel->getNumCols()<500)");
    4218     strcpy(line[numberLines++],"5    cbcModel->setMaximumCutPassesAtRoot(-100); // always do 100 if possible");
    4219     strcpy(line[numberLines++],"5  else if (cbcModel->getNumCols()<5000)");
    4220     strcpy(line[numberLines++],"5    cbcModel->setMaximumCutPassesAtRoot(100); // use minimum drop");
    4221     strcpy(line[numberLines++],"5  else");
    4222     strcpy(line[numberLines++],"5    cbcModel->setMaximumCutPassesAtRoot(20);");
    4223     strcpy(line[numberLines++],"5  cbcModel->setMaximumCutPasses(1);");
    4224   }
    4225   if (preProcess<=0) {
    4226     // no preprocessing or strategy
    4227     if (preProcess) {
    4228       strcpy(line[numberLines++],"5  // Preprocessing using CbcStrategy");
    4229       strcpy(line[numberLines++],"5  CbcStrategyDefault strategy(true,5,5);");
    4230       strcpy(line[numberLines++],"5  strategy.setupPreProcessing(1);");
    4231       strcpy(line[numberLines++],"5  cbcModel->setStrategy(strategy);");
    4232     }
    4233   } else {
    4234     int translate[]={9999,0,0,-1,2,3};
    4235     strcpy(line[numberLines++],"5  // Hand coded preprocessing");
    4236     strcpy(line[numberLines++],"5  CglPreProcess process;");
    4237     strcpy(line[numberLines++],"5  OsiSolverInterface * saveSolver=cbcModel->solver()->clone();");
    4238     strcpy(line[numberLines++],"5  // Tell solver we are in Branch and Cut");
    4239     strcpy(line[numberLines++],"5  saveSolver->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo) ;");
    4240     strcpy(line[numberLines++],"5  // Default set of cut generators");
    4241     strcpy(line[numberLines++],"5  CglProbing generator1;");
    4242     strcpy(line[numberLines++],"5  generator1.setUsingObjective(true);");
    4243     strcpy(line[numberLines++],"5  generator1.setMaxPass(3);");
    4244     strcpy(line[numberLines++],"5  generator1.setMaxProbeRoot(saveSolver->getNumCols());");
    4245     strcpy(line[numberLines++],"5  generator1.setMaxElements(100);");
    4246     strcpy(line[numberLines++],"5  generator1.setMaxLookRoot(50);");
    4247     strcpy(line[numberLines++],"5  generator1.setRowCuts(3);");
    4248     strcpy(line[numberLines++],"5  // Add in generators");
    4249     strcpy(line[numberLines++],"5  process.addCutGenerator(&generator1);");
    4250     strcpy(line[numberLines++],"5  process.messageHandler()->setLogLevel(cbcModel->logLevel());");
    4251     strcpy(line[numberLines++],"5  OsiSolverInterface * solver2 = ");
    4252     sprintf(line[numberLines++],"5    process.preProcessNonDefault(*saveSolver,%d,10);",translate[preProcess]);
    4253     strcpy(line[numberLines++],"5  // Tell solver we are not in Branch and Cut");
    4254     strcpy(line[numberLines++],"5  saveSolver->setHintParam(OsiDoInBranchAndCut,false,OsiHintDo) ;");
    4255     strcpy(line[numberLines++],"5  if (solver2)");
    4256     strcpy(line[numberLines++],"5    solver2->setHintParam(OsiDoInBranchAndCut,false,OsiHintDo) ;");
    4257     strcpy(line[numberLines++],"5  if (!solver2) {");
    4258     strcpy(line[numberLines++],"5    std::cout<<\"Pre-processing says infeasible!\"<<std::endl;");
    4259     strcpy(line[numberLines++],"5    exit(1);");
    4260     strcpy(line[numberLines++],"5  } else {");
    4261     strcpy(line[numberLines++],"5    std::cout<<\"processed model has \"<<solver2->getNumRows()");
    4262     strcpy(line[numberLines++],"5            <<\" rows, \"<<solver2->getNumCols()");
    4263     strcpy(line[numberLines++],"5            <<\" and \"<<solver2->getNumElements()<<std::endl;");
    4264     strcpy(line[numberLines++],"5  }");
    4265     strcpy(line[numberLines++],"5  // we have to keep solver2 so pass clone");
    4266     strcpy(line[numberLines++],"5  solver2 = solver2->clone();");
    4267     strcpy(line[numberLines++],"5  cbcModel->assignSolver(solver2);");
    4268     strcpy(line[numberLines++],"5  cbcModel->initialSolve();");
    4269   }
    4270   // add in actual solve
    4271   strcpy(line[numberLines++],"5  cbcModel->branchAndBound();");
    4272   strcpy(line[numberLines++],"8  std::cout<<argv[1]<<\" took \"<<CoinCpuTime()-time1<<\" seconds, \"");
    4273   strcpy(line[numberLines++],"8    <<cbcModel->getNodeCount()<<\" nodes with objective \"");
    4274   strcpy(line[numberLines++],"8    <<cbcModel->getObjValue()");
    4275   strcpy(line[numberLines++],"8    <<(!cbcModel->status() ? \" Finished\" : \" Not finished\")");
    4276   strcpy(line[numberLines++],"8    <<std::endl;");
    4277   strcpy(line[numberLines++],"5  // For best solution");
    4278   strcpy(line[numberLines++],"5  int numberColumns = solver1.getNumCols();");
    4279   strcpy(line[numberLines++],"5  if (cbcModel->getMinimizationObjValue()<1.0e50) {");
    4280   if (preProcess>0) {
    4281     strcpy(line[numberLines++],"5    // post process");
    4282     strcpy(line[numberLines++],"5    process.postProcess(*cbcModel->solver());");
    4283     strcpy(line[numberLines++],"5    // Solution now back in saveSolver");
    4284     strcpy(line[numberLines++],"5    cbcModel->assignSolver(saveSolver);");
    4285     strcpy(line[numberLines++],"5    memcpy(cbcModel->bestSolution(),cbcModel->solver()->getColSolution(),");
    4286     strcpy(line[numberLines++],"5          numberColumns*sizeof(double));");
    4287   }
    4288   strcpy(line[numberLines++],"5    // put back in original solver");
    4289   strcpy(line[numberLines++],"5    solver1.setColSolution(cbcModel->bestSolution());");
    4290   strcpy(line[numberLines++],"5    const double * solution = solver1.getColSolution();");
    4291   strcpy(line[numberLines++],"8  \n  // Now you would use solution etc etc\n");
    4292   strcpy(line[numberLines++],"5");
    4293   strcpy(line[numberLines++],"5    // Get names from solver1 (as OsiSolverInterface may lose)");
    4294   strcpy(line[numberLines++],"5    std::vector<std::string> columnNames = *solver1.getModelPtr()->columnNames();");
    4295   strcpy(line[numberLines++],"5    ");
    4296   strcpy(line[numberLines++],"5    int iColumn;");
    4297   strcpy(line[numberLines++],"5    std::cout<<std::setiosflags(std::ios::fixed|std::ios::showpoint)<<std::setw(14);");
    4298   strcpy(line[numberLines++],"5    ");
    4299   strcpy(line[numberLines++],"5    std::cout<<\"--------------------------------------\"<<std::endl;");
    4300   strcpy(line[numberLines++],"5    for (iColumn=0;iColumn<numberColumns;iColumn++) {");
    4301   strcpy(line[numberLines++],"5      double value=solution[iColumn];");
    4302   strcpy(line[numberLines++],"5      if (fabs(value)>1.0e-7&&solver1.isInteger(iColumn)) ");
    4303   strcpy(line[numberLines++],"5 std::cout<<std::setw(6)<<iColumn<<\" \"");
    4304   strcpy(line[numberLines++],"5                 <<columnNames[iColumn]<<\" \"");
    4305   strcpy(line[numberLines++],"5                 <<value<<std::endl;");
    4306   strcpy(line[numberLines++],"5    }");
    4307   strcpy(line[numberLines++],"5    std::cout<<\"--------------------------------------\"<<std::endl;");
    4308   strcpy(line[numberLines++],"5  ");
    4309   strcpy(line[numberLines++],"5    std::cout<<std::resetiosflags(std::ios::fixed|std::ios::showpoint|std::ios::scientific);");
    4310   strcpy(line[numberLines++],"5  }");
    4311   strcpy(line[numberLines++],"8  return 0;\n}");
    4312   fp = fopen(fileName,"w");
    4313   assert (fp);
    4314 
    4315   int wanted[9];
    4316   memset(wanted,0,sizeof(wanted));
    4317   wanted[0]=wanted[3]=wanted[5]=wanted[8]=1;
    4318   if (type>0)
    4319     wanted[1]=wanted[6]=1;
    4320   if (type>1)
    4321     wanted[2]=wanted[4]=wanted[7]=1;
    4322   std::string header[9]=
    4323   { "","Save values","Redundant save of default values","Set changed values",
    4324     "Redundant set default values","Solve","Restore values","Redundant restore values","Add to model"};
    4325   for (int iType=0;iType<9;iType++) {
    4326     if (!wanted[iType])
    4327       continue;
    4328     int n=0;
    4329     int iLine;
    4330     for (iLine=0;iLine<numberLines;iLine++) {
    4331       if (line[iLine][0]=='0'+iType) {
    4332         if (!n&&header[iType]!="")
    4333           fprintf(fp,"\n  // %s\n\n",header[iType].c_str());
    4334         n++;
    4335         // skip save and clp as cloned
    4336         if (!strstr(line[iLine],"save")||(!strstr(line[iLine],"clpMo")&&
    4337                                           !strstr(line[iLine],"_Osi")))
    4338           fprintf(fp,"%s\n",line[iLine]+1);
    4339       }
     3651  lengthCheck++;
     3652  int lengthC = strlen(checkC);
     3653  if (lengthC>length)
     3654    return false; // can't be true
     3655  if (lengthC<lengthCheck) {
     3656    // last lot must be blank for match
     3657    for (int i=lengthC;i<lengthCheck;i++) {
     3658      if (maskC[i]!=' ')
     3659        return false;
    43403660    }
    43413661  }
    4342   fclose(fp);
    4343   printf("C++ file written to %s\n",fileName);
     3662  // need only check this much
     3663  lengthC = CoinMin(lengthC,lengthCheck);
     3664  for (int i=0;i<lengthC;i++) {
     3665    if (maskC[i]!='*'&&maskC[i]!=checkC[i])
     3666      return false;
     3667  }
     3668  return true; // matches
    43443669}
    43453670/*
  • trunk/Cbc/src/unitTestClp.cpp

    r354 r355  
    860860    assert (fabs(valueDecrease[8]-2.95113)<1.0e-4);
    861861#if 0
    862 #if 0
    863862    // out until I find optimization bug
    864863    // Test parametrics
     
    868867    model2->scaling(0);
    869868    model2->setLogLevel(63);
    870 #endif
    871869    model2->parametrics(0.0,endingTheta,0.1,
    872870                        NULL,NULL,rhs,rhs,NULL);
     
    17781776  }
    17791777#endif
    1780   if (!doTest) {
    1781     printf("Not doing miplib run as can't find mps files - ? .gz without libz\n");
     1778  if (!doTest)
    17821779    return;
    1783   }
    17841780  /*
    17851781    Vectors to hold test problem names and characteristics. The objective value
     
    19391935
    19401936    double startTime = CoinCpuTime();
    1941     model->setMaximumNodes(100000);
     1937    model->setMaximumNodes(50000);
    19421938    OsiClpSolverInterface * si =
    19431939      dynamic_cast<OsiClpSolverInterface *>(model->solver()) ;
Note: See TracChangeset for help on using the changeset viewer.