Changeset 1286 for trunk/Clp


Ignore:
Timestamp:
Oct 1, 2008 11:45:12 AM (11 years ago)
Author:
forrest
Message:

changes for factorization and aux region

Location:
trunk/Clp/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/CbcOrClpParam.cpp

    r1284 r1286  
    14851485#endif
    14861486#ifdef COIN_HAS_CLP
    1487 #if CLP_MULTIPLE_FACTORIZATIONS == 1
     1487#if CLP_MULTIPLE_FACTORIZATIONS >0
    14881488  parameters[numberParameters++]=
    14891489    CbcOrClpParam("dense!Threshold","Whether to use dense factorization",
     
    26852685sequential Lps to get a good approximate solution."
    26862686     );
    2687 #if CLP_MULTIPLE_FACTORIZATIONS == 2
     2687#if CLP_MULTIPLE_FACTORIZATIONS > 0
    26882688  parameters[numberParameters++]=
    26892689    CbcOrClpParam("small!Factorization","Whether to use small factorization",
    2690                   -1,10000,DENSE,false);
     2690                  -1,10000,SMALLFACT,false);
    26912691  parameters[numberParameters-1].setLonghelp
    26922692    (
  • trunk/Clp/src/ClpFactorization.cpp

    r1285 r1286  
    11131113  coinFactorizationA_ = new CoinFactorization() ;
    11141114  coinFactorizationB_ = NULL;
    1115   //coinFactorizationB_ = new CoinOtherFactorization();
     1115  //coinFactorizationB_ = new CoinSmallFactorization();
    11161116  goDenseThreshold_ = -1;
     1117  goSmallThreshold_ = -1;
    11171118}
    11181119
     
    11201121// Copy constructor
    11211122//-------------------------------------------------------------------
    1122 ClpFactorization::ClpFactorization (const ClpFactorization & rhs)
     1123ClpFactorization::ClpFactorization (const ClpFactorization & rhs,
     1124                                    int denseIfSmaller)
    11231125{
    11241126#ifdef CLP_FACTORIZATION_INSTRUMENT
     
    11311133    networkBasis_=NULL;
    11321134#endif
    1133   if (rhs.coinFactorizationA_)
     1135  goDenseThreshold_ = rhs.goDenseThreshold_;
     1136  goSmallThreshold_ = rhs.goSmallThreshold_;
     1137  int goDense = 0;
     1138  if (denseIfSmaller>0&&!rhs.coinFactorizationB_) {
     1139    if (denseIfSmaller<=goDenseThreshold_)
     1140      goDense=1;
     1141    else if (denseIfSmaller<=goSmallThreshold_)
     1142      goDense=2;
     1143  }
     1144  if (rhs.coinFactorizationA_&&!goDense)
    11341145    coinFactorizationA_ = new CoinFactorization(*(rhs.coinFactorizationA_));
    11351146  else
    11361147    coinFactorizationA_=NULL;
    11371148  if (rhs.coinFactorizationB_)
    1138     coinFactorizationB_ = new CoinOtherFactorization(*(rhs.coinFactorizationB_));
     1149    coinFactorizationB_ = rhs.coinFactorizationB_->clone();
     1150  //coinFactorizationB_ = new CoinSmallFactorization(*(rhs.coinFactorizationB_));
    11391151  else
    11401152    coinFactorizationB_=NULL;
    1141   goDenseThreshold_ = rhs.goDenseThreshold_;
     1153  if (goDense) {
     1154    delete coinFactorizationB_;
     1155    if (goDense==1)
     1156      coinFactorizationB_ = new CoinDenseFactorization();
     1157    else
     1158      coinFactorizationB_ = new CoinSimpFactorization();
     1159    assert(rhs.coinFactorizationA_);
     1160    coinFactorizationB_->maximumPivots(rhs.coinFactorizationA_->maximumPivots());
     1161    coinFactorizationB_->pivotTolerance(rhs.coinFactorizationA_->pivotTolerance());
     1162    coinFactorizationB_->zeroTolerance(rhs.coinFactorizationA_->zeroTolerance());
     1163  }
     1164  assert (!coinFactorizationA_||!coinFactorizationB_);
    11421165#ifdef CLP_FACTORIZATION_INSTRUMENT
    11431166  factorization_instrument(1);
     
    11571180#ifdef CLP_FACTORIZATION_INSTRUMENT
    11581181  factorization_instrument(1);
     1182#endif
    11591183  goDenseThreshold_ = -1;
    1160 #endif
     1184  goSmallThreshold_ = -1;
     1185  assert (!coinFactorizationA_||!coinFactorizationB_);
    11611186}
    11621187
    1163 ClpFactorization::ClpFactorization (const CoinOtherFactorization & rhs)
     1188ClpFactorization::ClpFactorization (const CoinSmallFactorization & rhs)
    11641189{
    11651190#ifdef CLP_FACTORIZATION_INSTRUMENT
     
    11701195#endif
    11711196  coinFactorizationA_ = NULL;
    1172   coinFactorizationB_ = new CoinOtherFactorization(rhs);
     1197  coinFactorizationB_ = rhs.clone();
     1198  //coinFactorizationB_ = new CoinSmallFactorization(rhs);
    11731199  goDenseThreshold_ = -1;
     1200  goSmallThreshold_ = -1;
    11741201#ifdef CLP_FACTORIZATION_INSTRUMENT
    11751202  factorization_instrument(1);
    11761203#endif
     1204  assert (!coinFactorizationA_||!coinFactorizationB_);
    11771205}
    11781206
     
    12071235#endif
    12081236    delete coinFactorizationA_;
     1237    goDenseThreshold_ = rhs.goDenseThreshold_;
     1238    goSmallThreshold_ = rhs.goSmallThreshold_;
    12091239    if (rhs.coinFactorizationA_)
    12101240      coinFactorizationA_ = new CoinFactorization(*(rhs.coinFactorizationA_));
     
    12121242      coinFactorizationA_=NULL;
    12131243    delete coinFactorizationB_;
    1214     if (rhs.coinFactorizationB_)
    1215       coinFactorizationB_ = new CoinOtherFactorization(*(rhs.coinFactorizationB_));
    1216     else
     1244    if (rhs.coinFactorizationB_) {
     1245      coinFactorizationB_ = rhs.coinFactorizationB_->clone();
     1246      //coinFactorizationB_ = new CoinSmallFactorization(*(rhs.coinFactorizationB_));
     1247    } else {
    12171248      coinFactorizationB_=NULL;
     1249    }
    12181250  }
    12191251#ifdef CLP_FACTORIZATION_INSTRUMENT
    12201252  factorization_instrument(1);
    12211253#endif
     1254  assert (!coinFactorizationA_||!coinFactorizationB_);
    12221255  return *this;
    12231256}
    12241257// Go over to dense code
    12251258void
    1226 ClpFactorization::goDense()
    1227 {
    1228   delete coinFactorizationA_;
    1229   delete coinFactorizationB_;
    1230   coinFactorizationA_ = NULL;
    1231   coinFactorizationB_ = new CoinOtherFactorization();
    1232   //printf("going dense\n");
     1259ClpFactorization::goDenseOrSmall(int numberRows)
     1260{
     1261  if (numberRows<=goDenseThreshold_) {
     1262    delete coinFactorizationA_;
     1263    delete coinFactorizationB_;
     1264    coinFactorizationA_ = NULL;
     1265    coinFactorizationB_ = new CoinDenseFactorization();
     1266    //printf("going dense\n");
     1267  } else if (numberRows<=goSmallThreshold_) {
     1268    delete coinFactorizationA_;
     1269    delete coinFactorizationB_;
     1270    coinFactorizationA_ = NULL;
     1271    coinFactorizationB_ = new CoinSimpFactorization();
     1272    //printf("going small\n");
     1273  }
     1274  assert (!coinFactorizationA_||!coinFactorizationB_);
    12331275}
    12341276int
     
    12451287#endif
    12461288  if (coinFactorizationB_) {
    1247     setStatus(-99);
     1289    coinFactorizationB_->setStatus(-99);
    12481290    int * pivotVariable = model->pivotVariable();
    12491291    //returns 0 -okay, -1 singular, -2 too many in basis */
     1292    // allow dense
     1293    coinFactorizationB_->setSolveMode(-1);
    12501294    while (status()<-98) {
    12511295     
     
    13831427      coinFactorizationB_->preProcess ( );
    13841428      coinFactorizationB_->factor (  );
     1429      if (coinFactorizationB_->status() == -1 &&
     1430          coinFactorizationB_->solveMode()!=0) {
     1431        coinFactorizationB_->setSolveMode(0);
     1432        coinFactorizationB_->setStatus(-99);
     1433        continue;
     1434      }
    13851435      // If we get here status is 0 or -1
    1386       if (status() == 0&&numberBasic==numberRows) {
     1436      if (coinFactorizationB_->status() == 0&&numberBasic==numberRows) {
    13871437        coinFactorizationB_->postProcess(pivotTemp,pivotVariable);
    13881438      } else {
  • trunk/Clp/src/ClpFactorization.hpp

    r1284 r1286  
    1212class ClpNetworkBasis;
    1313#ifndef CLP_MULTIPLE_FACTORIZATIONS
    14 #define CLP_MULTIPLE_FACTORIZATIONS 1
     14#define CLP_MULTIPLE_FACTORIZATIONS 3
    1515#endif   
    1616#if CLP_MULTIPLE_FACTORIZATIONS == 1
    1717#include "CoinDenseFactorization.hpp"
    18 typedef CoinDenseFactorization CoinOtherFactorization;
     18typedef CoinDenseFactorization CoinSmallFactorization;
    1919#elif CLP_MULTIPLE_FACTORIZATIONS == 2
    2020#include "CoinSimpFactorization.hpp"
    21 typedef CoinSimpFactorization CoinOtherFactorization;
     21typedef CoinSimpFactorization CoinSmallFactorization;
     22#elif CLP_MULTIPLE_FACTORIZATIONS == 3
     23#include "CoinDenseFactorization.hpp"
     24#include "CoinSimpFactorization.hpp"
    2225#endif
    2326
     
    6063   /**@name Copy method */
    6164   //@{
    62    /** The copy constructor. */
    63    ClpFactorization(const ClpFactorization&);
    6465   /** The copy constructor from an CoinFactorization. */
    6566   ClpFactorization(const CoinFactorization&);
    6667#ifdef CLP_MULTIPLE_FACTORIZATIONS   
    67    /** The copy constructor from an CoinOtherFactorization. */
    68    ClpFactorization(const CoinOtherFactorization&);
     68   /** The copy constructor. */
     69  ClpFactorization(const ClpFactorization&,int denseIfSmaller=-1);
     70   /** The copy constructor from an CoinSmallFactorization. */
     71   ClpFactorization(const CoinSmallFactorization&);
     72#else
     73   /** The copy constructor. */
     74   ClpFactorization(const ClpFactorization&);
    6975#endif
    7076   ClpFactorization& operator=(const ClpFactorization&);
     
    275281  inline void setGoDenseThreshold(int value)
    276282  { goDenseThreshold_ = value;}
    277   /// Go over to dense code
    278   void goDense() ;
     283  /// Get switch to small if number rows <= this
     284  inline int goSmallThreshold() const
     285  { return goSmallThreshold_;}
     286  /// Set switch to small if number rows <= this
     287  inline void setGoSmallThreshold(int value)
     288  { goSmallThreshold_ = value;}
     289  /// Go over to dense or small code if small enough
     290  void goDenseOrSmall(int numberRows) ;
    279291  /// Return 1 if dense code
    280   inline int isDense() const
     292  inline int isDenseOrSmall() const
    281293  { return coinFactorizationB_ ? 1 : 0;}
    282294#else
     
    333345  /// Pointer to CoinFactorization
    334346  CoinFactorization * coinFactorizationA_;
    335   /// Pointer to CoinOtherFactorization
    336   CoinOtherFactorization * coinFactorizationB_;
     347  /// Pointer to CoinSmallFactorization
     348  CoinSmallFactorization * coinFactorizationB_;
     349  /// Switch to small if number rows <= this
     350  int goSmallThreshold_;
    337351  /// Switch to dense if number rows <= this
    338352  int goDenseThreshold_;
  • trunk/Clp/src/ClpMain.cpp

    r1245 r1286  
    734734#ifdef CLP_MULTIPLE_FACTORIZATIONS   
    735735              int denseCode = parameters[whichParam(DENSE,numberParameters,parameters)].intValue();
    736               if (denseCode>=model2->numberRows()) {
    737                 model2->factorization()->goDense();
    738               }
     736              model2->factorization()->setGoDenseThreshold(denseCode);
     737              model2->factorization()->goDenseOrSmall(model2->numberRows());
    739738#endif
    740739              try {
  • trunk/Clp/src/ClpNode.cpp

    r1276 r1286  
    3131  sequence_(1),
    3232  numberInfeasibilities_(0),
     33  depth_(0),
    3334  numberFixed_(0),
    3435  flags_(0),
     
    6061  sequence_(1),
    6162  numberInfeasibilities_(0),
     63  depth_(0),
    6264  numberFixed_(0),
    6365  flags_(0),
     
    8385  int numberTotal = numberRows+numberColumns;
    8486  int maximumTotal = maximumRows_+maximumColumns_;
     87  depth_ = depth;
    8588  // save stuff
    8689  objectiveValue_ = model->objectiveValue()*model->optimizationDirection();
     
    163166      }
    164167      pivotVariables_ = new int [maximumRows_];
    165       if (model->pivotVariable())
     168      if (model->pivotVariable()&&model->numberRows()==numberRows)
    166169        CoinMemcpyN(model->pivotVariable(),numberRows,pivotVariables_);
     170      else
     171        CoinFillN(pivotVariables_,numberRows,-1);
    167172    }
    168173  }
     
    183188  int nFix=0;
    184189  double gap = CoinMax(model->dualObjectiveLimit()-objectiveValue_,1.0e-4);
    185 #define PSEUDO 2
    186 #if PSEUDO==1
     190#define PSEUDO 3
     191#if PSEUDO==1||PSEUDO==2
    187192  // Column copy of matrix
    188193  ClpPackedMatrix * matrix = model->clpScaledMatrix();
     
    196201  double direction = model->optimizationDirection();
    197202  const double * dual = dualSolution_+numberColumns;
    198 #elif PSEUDO==2
     203#if PSEUDO==2
     204  double * activeWeight = new double [numberRows];
     205  const double * rowLower = model->rowLower();
     206  const double * rowUpper = model->rowUpper();
     207  const double * rowActivity = model->primalRowSolution();
     208  double tolerance = 1.0e-6;
     209  for (int iRow = 0;iRow<numberRows;iRow++) {
     210    // could use pi to see if active or activity
     211    if (rowActivity[iRow]>rowUpper[iRow]-tolerance
     212        ||rowActivity[iRow]<rowLower[iRow]+tolerance) {
     213      activeWeight[iRow]=0.0;
     214    } else {
     215      activeWeight[iRow]=-1.0;
     216    }
     217  }
     218  for (int iColumn=0;iColumn<numberColumns;iColumn++) {
     219    if (integerType[iColumn]) {
     220      double value = solution[iColumn];
     221      if (fabs(value-floor(value+0.5))>1.0e-6) {
     222        CoinBigIndex start = columnStart[iColumn];
     223        CoinBigIndex end = start + columnLength[iColumn];
     224        for (CoinBigIndex j=start;j<end;j++) {
     225          int iRow = row[j];
     226          if (activeWeight[iRow]>=0.0)
     227            activeWeight[iRow] += 1.0;
     228        }
     229      }
     230    }
     231  }
     232  for (int iRow = 0;iRow<numberRows;iRow++) {
     233    if (activeWeight[iRow]>0.0) {
     234      // could use pi
     235      activeWeight[iRow] = 1.0/activeWeight[iRow];
     236    } else {
     237      activeWeight[iRow]=0.0;
     238    }
     239  }
     240#endif
     241#elif PSEUDO==3
    199242  const double * downPseudo = stuff->downPseudo_;
    200243  const int * numberDown = stuff->numberDown_;
     
    214257        numberInfeasibilities_++;
    215258        sumInfeasibilities_ += fabs(value-nearest);
    216 #if PSEUDO==1
     259#if PSEUDO==1 || PSEUDO ==2
    217260        double upValue = 0.0;
    218261        double downValue = 0.0;
    219         double value2 = direction*objective[iColumn];
     262        double value2 = objective ? direction*objective[iColumn] : 0.0;
    220263        if (value2) {
    221264          if (value2>0.0)
    222             upValue += value2;
     265            upValue += 1.5*value2;
    223266          else
    224             downValue -= value2;
     267            downValue -= 1.5*value2;
    225268        }
    226269        CoinBigIndex start = columnStart[iColumn];
     
    231274          if (value2) {
    232275            value2 *= element[j];
     276#if PSEUDO==2
     277            assert (activeWeight[iRow]>0.0||fabs(dual[iRow])<1.0e-6);
     278            value2 *= activeWeight[iRow];
     279#endif
    233280            if (value2>0.0)
    234281              upValue += value2;
     
    237284          }
    238285        }
     286        upValue = CoinMax(upValue,1.0e-8);
     287        downValue = CoinMax(downValue,1.0e-8);
    239288        upValue *= ceil(value)-value;
    240289        downValue *= value-floor(value);
     
    245294          infeasibility = 0.1*CoinMax(upValue,downValue)+
    246295            0.9*CoinMin(upValue,downValue) + integerTolerance;
    247 #elif PSEUDO==2
     296#elif PSEUDO==3
    248297        double upValue = (ceil(value)-value)*(upPseudo[iInteger]/(1.0+numberUp[iInteger]+numberUpInfeasible[iInteger]));
    249298        double downValue = (value-floor(value))*(downPseudo[iInteger]/(1.0+numberDown[iInteger]+numberDownInfeasible[iInteger]));
     
    309358    }
    310359  }
     360#if PSEUDO == 2
     361  delete [] activeWeight;
     362#endif
    311363  if (lower_) {
    312364    // save bounds
     
    497549  }
    498550}
     551// Choose a new variable
     552void
     553ClpNode::chooseVariable(ClpSimplex * model, ClpNodeStuff * info)
     554{
     555#if 0
     556  int way=branchState_.firstBranch;
     557  if (branchState_.branch>0)
     558    way=1-way;
     559  assert (!branchState_.branch);
     560  // We need to use pseudo costs to choose a variable
     561  int numberColumns = model->numberColumns();
     562#endif
     563}
    499564// Fix on reduced costs
    500565int
    501566ClpNode::fixOnReducedCosts(ClpSimplex * model)
    502567{
     568 
    503569  return 0;
    504570}
     
    609675    saveOptions_ = rhs.saveOptions_;
    610676    solverOptions_ = rhs.solverOptions_;
    611     if (nDepth_>=0) {
    612       int n = (1<<nDepth_)+1+nDepth_;
     677    int n = maximumNodes();
     678    if (n) {
    613679      for (int i=0;i<n;i++)
    614680        delete nodeInfo_[i];
     
    663729  delete [] numberDownInfeasible_;
    664730  delete [] numberUpInfeasible_;
    665   if (nDepth_>=0) {
    666     int n = (1<<nDepth_)+1+nDepth_;
     731  int n = maximumNodes();
     732  if (n) {
    667733    for (int i=0;i<n;i++)
    668734      delete nodeInfo_[i];
    669735    delete [] nodeInfo_;
    670736  }
     737}
     738// Return maximum number of nodes
     739int
     740ClpNodeStuff::maximumNodes() const
     741{
     742  int n;
     743  if ((solverOptions_&32)==0)
     744    n = (1<<nDepth_)+1+nDepth_;
     745  else if (nDepth_)
     746    n = 1+1+nDepth_;
     747  else
     748    n = 0;
     749  return n;
    671750}
    672751/* Fill with pseudocosts */
  • trunk/Clp/src/ClpNode.hpp

    r1202 r1286  
    2525  */
    2626  void applyNode(ClpSimplex * model, int doBoundsEtc );
     27  /// Choose a new variable
     28  void chooseVariable(ClpSimplex * model, ClpNodeStuff * info);
    2729  /// Fix on reduced costs
    2830  int fixOnReducedCosts(ClpSimplex * model);
     
    5658  inline int numberInfeasibilities() const
    5759  { return numberInfeasibilities_;}
     60  /// Relative depth
     61  inline int depth() const
     62  { return depth_;}
    5863  /// Estimated solution value
    5964  inline double estimatedSolution() const
     
    138143  /// Number of infeasibilities
    139144  int numberInfeasibilities_;
     145  /// Relative depth
     146  int depth_;
    140147  /// Number fixed by reduced cost
    141148  int numberFixed_;
     
    183190  /// Update pseudo costs
    184191  void update(int way,int sequence,double change,bool feasible);
     192  /// Return maximum number of nodes
     193  int maximumNodes() const;
    185194  //@}
    186195 
     
    223232      4 - create external row activity (columns always done)
    224233      Above only done if feasible
     234      32 - just create up to nDepth_+1 nodes
    225235      65536 - set if activated
    226236  */
  • trunk/Clp/src/ClpSimplex.cpp

    r1284 r1286  
    11// Copyright (C) 2002, International Business Machines
    22// Corporation and others.  All Rights Reserved.
    3 
    43
    54//#undef NDEBUG
     
    3029#include "CoinLpIO.hpp"
    3130#include <cfloat>
     31#ifndef CLP_AUXILIARY_MODEL
     32#define auxiliaryModel_ false
     33#endif
    3234
    3335#include <string>
     
    9395  rowActivityWork_(NULL),
    9496  columnActivityWork_(NULL),
     97#ifdef CLP_AUXILIARY_MODEL
    9598  auxiliaryModel_(NULL),
     99#endif
    96100  numberDualInfeasibilities_(0),
    97101  numberDualInfeasibilitiesWithoutFree_(0),
     
    205209  rowActivityWork_(NULL),
    206210  columnActivityWork_(NULL),
     211#ifdef CLP_AUXILIARY_MODEL
    207212  auxiliaryModel_(NULL),
     213#endif
    208214  numberDualInfeasibilities_(0),
    209215  numberDualInfeasibilitiesWithoutFree_(0),
     
    354360  rowActivityWork_(NULL),
    355361  columnActivityWork_(NULL),
     362#ifdef CLP_AUXILIARY_MODEL
    356363  auxiliaryModel_(NULL),
     364#endif
    357365  numberDualInfeasibilities_(0),
    358366  numberDualInfeasibilitiesWithoutFree_(0),
     
    393401  }
    394402  saveStatus_=NULL;
     403#ifdef CLP_MULTIPLE_FACTORIZATIONS   
     404  factorization_ = new ClpFactorization(*rhs->factorization_,numberRows_);
     405#else
    395406  factorization_ = new ClpFactorization(*rhs->factorization_);
    396 #ifdef CLP_MULTIPLE_FACTORIZATIONS   
    397   if (numberRows_<=factorization_->goDenseThreshold()) //&&!factorization_->isDense())
    398     factorization_->goDense();
    399407#endif
    400408  ClpDualRowDantzig * pivot =
     
    480488  }
    481489  CoinZeroN(rowActivity_,numberRows_);
     490#if 0
     491  if (!problemStatus_) {
     492    ClpDisjointCopyN(smallModel.objective(),smallModel.numberColumns_,smallModel.reducedCost_);
     493    smallModel.matrix_->transposeTimes(-1.0,smallModel.dual_,smallModel.reducedCost_);
     494    for (int i=0;i<smallModel.numberColumns_;i++) {
     495      if (smallModel.getColumnStatus(i)==basic)
     496        assert (fabs(smallModel.reducedCost_[i])<1.0e-5);
     497    }
     498    ClpDisjointCopyN(objective(),numberColumns_,reducedCost_);
     499    matrix_->transposeTimes(-1.0,dual_,reducedCost_);
     500    for (int i=0;i<numberColumns_;i++) {
     501      if (getColumnStatus(i)==basic)
     502        assert (fabs(reducedCost_[i])<1.0e-5);
     503    }
     504  }
     505#endif
    482506  matrix()->times(columnActivity_,rowActivity_) ;
    483507}
     
    19141938  rowActivityWork_(NULL),
    19151939  columnActivityWork_(NULL),
     1940#ifdef CLP_AUXILIARY_MODEL
    19161941  auxiliaryModel_(NULL),
     1942#endif
    19171943  numberDualInfeasibilities_(0),
    19181944  numberDualInfeasibilitiesWithoutFree_(0),
     
    20192045  rowActivityWork_(NULL),
    20202046  columnActivityWork_(NULL),
     2047#ifdef CLP_AUXILIARY_MODEL
    20212048  auxiliaryModel_(NULL),
     2049#endif
    20222050  numberDualInfeasibilities_(0),
    20232051  numberDualInfeasibilitiesWithoutFree_(0),
     
    20892117  dontFactorizePivots_ = rhs.dontFactorizePivots_;
    20902118  int numberRows2 = numberRows_+numberExtraRows_;
     2119#ifdef CLP_AUXILIARY_MODEL
    20912120  auxiliaryModel_ = NULL;
     2121#endif
    20922122  moreSpecialOptions_ = rhs.moreSpecialOptions_;
    20932123  if ((whatsChanged_&1)!=0) {
     
    22922322  if (!type) {
    22932323    // delete everything
     2324#ifdef CLP_AUXILIARY_MODEL
    22942325    delete auxiliaryModel_;
    22952326    auxiliaryModel_ = NULL;
     2327#endif
    22962328    setEmptyFactorization();
    22972329    delete [] pivotVariable_;
     
    27442776{
    27452777  bool goodMatrix=true;
     2778  int saveLevel=handler_->logLevel();
    27462779  spareIntArray_[0]=0;
    27472780  if (!matrix_->canGetRowCopy())
    27482781    makeRowCopy=false; // switch off row copy if can't produce
    2749   int saveLevel=handler_->logLevel();
    27502782  // Arrays will be there and correct size unless what is 63
    27512783  bool newArrays = (what==63);
     
    27572789  }
    27582790  bool oldMatrix = ((startFinishOptions&4)!=0&&(whatsChanged_&1)!=0);
     2791#ifdef CLP_AUXILIARY_MODEL
    27592792  if (auxiliaryModel_) {
    27602793    if (auxiliaryModel_->numberRows_==numberRows_&&
     
    27672800    }
    27682801  }
     2802#endif
    27692803  if (what==63) {
    27702804    pivotRow_=-1;
     
    31123146      delete [] solution_;
    31133147      solution_ = new double[numberTotal];
     3148#ifdef CLP_AUXILIARY_MODEL
    31143149    } else if (auxiliaryModel_) {
    31153150      assert (!cost_);
     
    31253160      assert (!rowScale_);
    31263161      assert (!columnScale_);
     3162#endif
    31273163    }
    31283164    reducedCostWork_ = dj_;
     
    31383174  }
    31393175  if ((what&4)!=0) {
    3140     if (!auxiliaryModel_||(what==63&&(auxiliaryModel_->specialOptions_&4)==0)) {
     3176#ifdef CLP_AUXILIARY_MODEL
     3177    if (!auxiliaryModel_||(what==63&&(auxiliaryModel_->specialOptions_&4)==0))
     3178#endif
     3179      {
    31413180      double direction = optimizationDirection_*objectiveScale_;
    31423181      const double * obj = objective();
     3182#ifdef CLP_AUXILIARY_MODEL
    31433183      const double * rowScale = auxiliaryModel_ ? auxiliaryModel_->rowScale_ : rowScale_;
    31443184      const double * columnScale = auxiliaryModel_ ? auxiliaryModel_->columnScale_ : columnScale_;
     3185#else
     3186      const double * rowScale = rowScale_;
     3187      const double * columnScale = columnScale_;
     3188#endif
    31453189      // and also scale by scale factors
    31463190      if (rowScale) {
     
    31703214        }
    31713215      }
     3216#ifdef CLP_AUXILIARY_MODEL
    31723217      if (auxiliaryModel_) {
    31733218        // save costs
     
    31773222      // just copy
    31783223      CoinMemcpyN(auxiliaryModel_->cost_+numberTotal,numberTotal,cost_);
     3224#endif
    31793225    }
    31803226  }
    31813227  if ((what&1)!=0) {
     3228#ifdef CLP_AUXILIARY_MODEL
    31823229    const double * rowScale = auxiliaryModel_ ? auxiliaryModel_->rowScale_ : rowScale_;
    31833230    const double * columnScale = auxiliaryModel_ ? auxiliaryModel_->columnScale_ : columnScale_;
     3231#else
     3232    const double * rowScale = rowScale_;
     3233    const double * columnScale = columnScale_;
     3234#endif
    31843235    // clean up any mismatches on infinity
    31853236    // and fix any variables with tiny gaps
    31863237    double primalTolerance=dblParam_[ClpPrimalTolerance];
     3238#ifdef CLP_AUXILIARY_MODEL
    31873239    if (!auxiliaryModel_) {
     3240#endif
    31883241      if(rowScale) {
    31893242        // If scaled then do all columns later in one loop
     
    34043457        }
    34053458      }
     3459#ifdef CLP_AUXILIARY_MODEL
    34063460    } else {
    34073461      // auxiliary model
     
    35143568      }
    35153569    }
     3570#endif
    35163571  }
    35173572  if (what==63) {
     
    35213576    if (direction)
    35223577      direction = 1.0/direction;
    3523     if (direction!=1.0&&(!auxiliaryModel_||(auxiliaryModel_->specialOptions_&8)==0)) {
     3578#ifdef CLP_AUXILIARY_MODEL
     3579    if (direction!=1.0&&(!auxiliaryModel_||(auxiliaryModel_->specialOptions_&8)==0))
     3580#else
     3581    if (direction!=1.0)
     3582#endif
     3583 {
    35243584      // reverse all dual signs
    35253585      for (i=0;i<numberColumns_;i++)
     
    35313591      setFakeBound(i,noFake);
    35323592    }
     3593#ifdef CLP_AUXILIARY_MODEL
    35333594    if (!auxiliaryModel_) {
     3595#endif
    35343596      if (rowScale_) {
    35353597        const double * obj = objective();
     
    37513813        }
    37523814      }
    3753     }
     3815#ifdef CLP_AUXILIARY_MODEL
     3816    }
     3817#endif
    37543818  }
    37553819 
     
    38623926    } else {
    38633927      int iRow,iColumn;
     3928#ifdef CLP_AUXILIARY_MODEL
    38643929      if (auxiliaryModel_) {
    38653930        for (iRow=0;iRow<4;iRow++) {
     
    38813946        auxiliaryModel_->matrix_=temp;
    38823947      }
     3948#endif
    38833949      for (iRow=0;iRow<4;iRow++) {
    38843950        rowArray_[iRow]->clear();
     
    39514017  int numberTotal = numberRows2+numberColumns_;
    39524018  //assert (!auxiliaryModel_);
     4019#ifdef CLP_AUXILIARY_MODEL
    39534020  if (!auxiliaryModel_) {
     4021#endif
    39544022    if ((specialOptions_&65536)!=0&&true) {
    39554023      assert (!initial);
     
    41824250      }
    41834251    }
     4252#ifdef CLP_AUXILIARY_MODEL
    41844253  } else {
    41854254    // auxiliary model
     
    42964365    }
    42974366  }
     4367#endif
    42984368#ifndef NDEBUG
    42994369  if ((specialOptions_&65536)!=0&&false) {
     
    43154385  int numberTotal = numberRows2+numberColumns_;
    43164386  //assert (!auxiliaryModel_);
     4387#ifdef CLP_AUXILIARY_MODEL
    43174388  if (!auxiliaryModel_||(initial&&(auxiliaryModel_->specialOptions_&4)==0)) {
     4389#endif
    43184390    if ((specialOptions_&65536)!=0&&true) {
    43194391      assert (!initial);
     
    43244396    double direction = optimizationDirection_*objectiveScale_;
    43254397    const double * obj = objective();
     4398#ifdef CLP_AUXILIARY_MODEL
    43264399    const double * rowScale = auxiliaryModel_ ? auxiliaryModel_->rowScale_ : rowScale_;
    43274400    const double * columnScale = auxiliaryModel_ ? auxiliaryModel_->columnScale_ : columnScale_;
     4401#else
     4402    const double * rowScale = rowScale_;
     4403    const double * columnScale = columnScale_;
     4404#endif
    43284405    // and also scale by scale factors
    43294406    if (rowScale) {
     
    43534430      }
    43544431    }
     4432#ifdef CLP_AUXILIARY_MODEL
    43554433    if (auxiliaryModel_) {
    43564434      // save costs
     
    43614439    CoinMemcpyN(auxiliaryModel_->cost_+numberTotal,numberTotal,cost_);
    43624440  }
     4441#endif
    43634442}
    43644443// Does rows and columns and objective
     
    43804459      numberColumns=0;
    43814460  }
     4461#ifdef CLP_AUXILIARY_MODEL
    43824462  if (!auxiliaryModel_) {
     4463#endif
    43834464    int i;
    43844465    if (problemStatus_!=1&&problemStatus_!=2) {
     
    46764757        dual_[i] *= optimizationDirection_;
    46774758    }
     4759#ifdef CLP_AUXILIARY_MODEL
    46784760  } else {
    46794761    // auxiliary model
     
    47784860    }
    47794861  }
     4862#endif
    47804863  // scaling may have been turned off
    47814864  scalingFlag_ = abs(scalingFlag_);
     
    95489631    problemStatus_=-1;
    95499632}
     9633#ifdef CLP_AUXILIARY_MODEL
    95509634/*
    95519635  If you are re-using the same matrix again and again then the setup time
     
    96509734  }
    96519735}
     9736#endif
    96529737/*
    96539738  When scaling is on it is possible that the scaled problem
     
    97379822}
    97389823#endif
     9824#ifdef CLP_AUXILIARY_MODEL
    97399825// Switch off e.g. if people using presolve
    97409826void
     
    97449830  auxiliaryModel_=NULL;
    97459831}
     9832#endif
    97469833// Compute objective value from solution
    97479834void
     
    1055010637  assert (stuff);
    1055110638  ClpNodeStuff * info = (ClpNodeStuff *) stuff;
    10552   int nNodes = (1<<info->nDepth_)+1+info->nDepth_;
     10639  int nNodes = info->maximumNodes();
    1055310640  int goodNodes=0;
    1055410641  info->nNodes_=0;
     
    1079510882  int useDepth=nNodes-1;
    1079610883  bool lastFeasible=true;
     10884  bool justDive = (info->solverOptions_&32)!=0;
    1079710885  while (depth>=0) {
     10886    bool stopAtOnce=false;
    1079810887    // If backtrack get to correct depth
    1079910888    if (backtrack) {
     
    1082410913      }
    1082510914      nodeInfo[useDepth]->applyNode(this,1);
     10915      if (justDive)
     10916        stopAtOnce=true;
    1082610917      int iColumn = nodeInfo[useDepth]->sequence();
    10827         if (printing)
    10828           printf("after backtracking - applying node at depth %d - variable %d (%g,%g)\n",
    10829                 depth,iColumn,
    10830                 columnLower_[iColumn],columnUpper_[iColumn]);
     10918      if (printing)
     10919        printf("after backtracking - applying node at depth %d - variable %d (%g,%g)\n",
     10920              depth,iColumn,
     10921              columnLower_[iColumn],columnUpper_[iColumn]);
    1083110922      depth++;
    1083210923      useDepth--;
     
    1083410925      // just bounds
    1083510926      if (depth>0) {
     10927        // Choose variable here!!
     10928        nodeInfo[useDepth+1]->chooseVariable(this,info);
    1083610929        nodeInfo[useDepth+1]->applyNode(this,0);
    1083710930        int iColumn = nodeInfo[useDepth+1]->sequence();
     
    1084610939    numberNodes++;
    1084710940    numberIterations += numberIterations_;
    10848     if ((numberNodes%1000)==0)
     10941    if ((numberNodes%1000)==0&&printing)
    1084910942      printf("After %d nodes (%d iterations) - best solution %g - current depth %d\n",
    1085010943             numberNodes,numberIterations,bestObjective,depth);
     
    1087810971        if (onOptimal) {
    1087910972          printf("INF on optimal (pre) fathom at depth %d\n",depth);
     10973          writeMps("fathom_pre.mps");
    1088010974          abort();
    1088110975        }
     
    1097211066      }
    1097311067#endif
    10974       if (depth<info->nDepth_) {
     11068      if (depth<info->nDepth_&&!stopAtOnce) {
    1097511069        node = nodeInfo[useDepth];
    1097611070        if (node) {
     
    1099511089        lastFeasible=false;
    1099611090        double objectiveValue=doubleCheck();
    10997         printf("Solution of %g after %d nodes at depth %d\n",
    10998                objectiveValue,numberNodes,depth);
     11091        if (printing)
     11092          printf("Solution of %g after %d nodes at depth %d\n",
     11093                 objectiveValue,numberNodes,depth);
    1099911094        if (objectiveValue<bestObjective&&!problemStatus_) {
    1100011095          // make sure node exists
     
    1103611131      } else {
    1103711132        lastFeasible=true;
    11038         if (printing)
    11039           printf("depth %d variable %d\n",depth,node->sequence());
    11040         if (depth==info->nDepth_) {
     11133        //if (printing)
     11134        //printf("depth %d variable %d\n",depth,node->sequence());
     11135        if (depth==info->nDepth_||stopAtOnce) {
    1104111136          if (info->large_) {
    1104211137            //check this does everything
     
    1134511440      // reduced costs
    1134611441      if (!columnScale_) {
    11347         CoinMemcpyN(reducedCost_,numberColumns_,dj_);
     11442        CoinMemcpyN(dj_,numberColumns_,reducedCost_);
    1134811443      } else {
    1134911444        for (j=0;j<numberColumns_;j++)
     
    1135411449      // dual
    1135511450      if (!rowScale_) {
    11356         CoinMemcpyN(dual_,numberRows_,dj_+numberColumns_);
     11451        //CoinMemcpyN(dual_,numberRows_,dj_+numberColumns_);
    1135711452      } else {
    1135811453        for (j=0;j<numberRows_;j++)
     
    1136311458      // row activity
    1136411459      if (!rowScale_) {
    11365         CoinMemcpyN(rowActivity_,numberRows_,solution_+numberColumns_);
     11460        CoinMemcpyN(solution_+numberColumns_,numberRows_,rowActivity_);
    1136611461      } else {
    1136711462        for (j=0;j<numberRows_;j++)
  • trunk/Clp/src/ClpSimplex.hpp

    r1282 r1286  
    121121  */
    122122  void setPersistenceFlag(int value);
     123#ifdef CLP_AUXILIARY_MODEL
    123124  /**
    124125     If you are re-using the same matrix again and again then the setup time
     
    140141  inline bool usingAuxiliaryModel() const
    141142  { return auxiliaryModel_!=NULL;}
     143#endif
    142144  /// Save a copy of model with certain state - normally without cuts
    143145  void makeBaseModel();
     
    12621264  /// Column activities - working copy
    12631265  double * columnActivityWork_;
     1266#ifdef CLP_AUXILIARY_MODEL
    12641267  /// Auxiliary model
    12651268  ClpSimplex * auxiliaryModel_;
     1269#endif
    12661270  /// Number of dual infeasibilities
    12671271  int numberDualInfeasibilities_;
  • trunk/Clp/src/ClpSimplexDual.cpp

    r1277 r1286  
    125125extern int * toVub;
    126126extern int * nextDescendent;
     127#endif
     128#ifndef CLP_AUXILIARY_MODEL
     129#define auxiliaryModel_ false
    127130#endif
    128131// dual
     
    499502    nPivots=factorization_->pivots();
    500503#endif
     504    if (!problemStatus_&&factorization_->pivots())
     505      computeDuals(NULL); // need to compute duals
    501506    if (returnCode==-2)
    502507      factorType=3;
    503508  }
    504509#ifdef CLP_INVESTIGATE
     510  // NOTE - can fail if parallel
    505511  if (z_thinks!=-1) {
    506512    assert (z_thinks<4);
     
    39463952  }
    39473953  progressFlag_ = 0; //reset progress flag
     3954  /*if (!numberIterations_&&sumDualInfeasibilities_)
     3955    printf("OBJ %g sumPinf %g sumDinf %g\n",
     3956           objectiveValue(),sumPrimalInfeasibilities_,
     3957           sumDualInfeasibilities_);*/
    39483958  if (handler_->detail(CLP_SIMPLEX_STATUS,messages_)<100) {
    39493959    handler_->message(CLP_SIMPLEX_STATUS,messages_)
     
    41584168        delete [] saveColumnSolution;
    41594169        delete [] saveRowSolution;
    4160       } 
     4170      }
    41614171      if (problemStatus_==-4||problemStatus_==-5) {
    41624172        // may be infeasible - or may be bounds are wrong
     
    41724182          createRim4(false);
    41734183        }
    4174         if (numberChangedBounds<=0||dualBound_>1.0e20||
    4175             (largestPrimalError_>1.0&&dualBound_>1.0e17)) {
     4184        if ((numberChangedBounds<=0||dualBound_>1.0e20||
     4185            (largestPrimalError_>1.0&&dualBound_>1.0e17))&&
     4186            (numberPivots<4||sumPrimalInfeasibilities_>1.0e-6)) {
    41764187          problemStatus_=1; // infeasible
    41774188          if (perturbation_==101) {
     
    46114622    numberFake_--;;
    46124623    setFakeBound(iSequence,noFake);
     4624#ifdef CLP_AUXILIARY_MODEL
    46134625    if (auxiliaryModel_) {
    46144626      // just copy back
     
    46174629      return;
    46184630    }
     4631#endif
    46194632    if (iSequence>=numberColumns_) {
    46204633      // rows
  • trunk/Clp/src/ClpSimplexOther.cpp

    r1197 r1286  
    159159    }
    160160    double scaleFactor;
     161#ifdef CLP_AUXILIARY_MODEL
    161162    if (!auxiliaryModel_) {
     163#endif
    162164      if (rowScale_) {
    163165        if (iSequence<numberColumns_)
     
    168170        scaleFactor = 1.0/objectiveScale_;
    169171      }
     172#ifdef CLP_AUXILIARY_MODEL
    170173    } else {
    171174      if (auxiliaryModel_->rowScale()) {
     
    178181      }
    179182    }
     183#endif
    180184    if (costIncrease<1.0e30)
    181185      costIncrease *= scaleFactor;
  • trunk/Clp/src/unitTest.cpp

    r1185 r1286  
    11471147      CoinRelFltEq eq(1.0e-8);
    11481148      assert(eq(objValue,-4.6475314286e+02));
     1149#ifdef CLP_AUXILIARY_MODEL
    11491150      // Test auxiliary model
    11501151      //solution.scaling(0);
     
    11561157      assert(eq(solution.objectiveValue(),-4.6475314286e+02));
    11571158      solution.auxiliaryModel(-1);
     1159#endif
    11581160      solution.dual();
    11591161      assert(eq(solution.objectiveValue(),-4.6475314286e+02));
Note: See TracChangeset for help on using the changeset viewer.