Changeset 799


Ignore:
Timestamp:
Jun 9, 2006 3:26:50 PM (14 years ago)
Author:
andreasw
Message:

undid last commit (patches incorrectly applied)

Location:
trunk/Clp
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/examples/makeDual.cpp

    r798 r799  
    5656  int numberExtraRows=0;
    5757  for (iRow=0;iRow<numberRows;iRow++) {
    58     if (rowLower[iRow]<=-1.0e20) {
    59     } else if (rowUpper[iRow]>=1.0e20) {
     58    if (rowLower[iRow]<-1.0e20) {
     59    } else if (rowUpper[iRow]>1.0e20) {
    6060    } else {
    6161      if (rowUpper[iRow]!=rowLower[iRow])
     
    7070  for (iColumn=0;iColumn<numberColumns;iColumn++) {
    7171    double offset=0.0;
    72     if (columnUpper[iColumn]>=1.0e20) {
     72    if (columnUpper[iColumn]>1.0e20) {
    7373      if (columnLower[iColumn]>-1.0e20)
    7474        offset=columnLower[iColumn];
    75     } else if (columnLower[iColumn]<=-1.0e20) {
     75    } else if (columnLower[iColumn]<-1.0e20) {
    7676      offset=columnUpper[iColumn];
    7777    } else {
     
    101101  for (iColumn=0;iColumn<numberColumns;iColumn++) {
    102102    // Offset is already in
    103     if (columnUpper[iColumn]>=1.0e20) {
     103    if (columnUpper[iColumn]>1.0e20) {
    104104      if (columnLower[iColumn]>-1.0e20) {
    105105        fromColumnsLower[iColumn]=-COIN_DBL_MAX;
     
    110110        fromColumnsUpper[iColumn]=objective[iColumn];
    111111      }
    112     } else if (columnLower[iColumn]<=-1.0e20) {
     112    } else if (columnLower[iColumn]<-1.0e20) {
    113113      fromColumnsLower[iColumn]=objective[iColumn];
    114114      fromColumnsUpper[iColumn]=COIN_DBL_MAX;
     
    119119  int kRow=0;
    120120  for (iRow=0;iRow<numberRows;iRow++) {
    121     if (rowLower[iRow]<=-1.0e20) {
     121    if (rowLower[iRow]<-1.0e20) {
    122122      assert (rowUpper[iRow]<1.0e20);
    123123      newObjective[kRow]=-rowUpper[iRow];
     
    126126      which[kRow]=iRow;
    127127      kRow++;
    128     } else if (rowUpper[iRow]>=1.0e20) {
     128    } else if (rowUpper[iRow]>1.0e20) {
    129129      newObjective[kRow]=-rowLower[iRow];
    130130      fromRowsLower[kRow]=0.0;
  • trunk/Clp/src/CbcOrClpParam.cpp

    r798 r799  
    352352  if (name_=="directory")
    353353    std::cout<<"Current working directory is "<<stringValue_<<std::endl;
    354   else if (name_.substr(0,6)=="printM")
     354  else if (name_=="printM!ask")
    355355    std::cout<<"Current value of printMask is "<<stringValue_<<std::endl;
    356356  else
     
    10941094    (
    10951095     "If the gap between best solution and best possible solution is less than this \
    1096 then the search will be terminated.  Also see ratioGap."
     1096then the search will be terminated.  Also see gapRatio."
    10971097     );
    10981098#endif
     
    12361236                  "off",COSTSTRATEGY);
    12371237  parameters[numberParameters-1].append("pri!orities");
    1238   parameters[numberParameters-1].append("column!Order?");
     1238  parameters[numberParameters-1].append("pseudo!costs(not implemented yet)");
    12391239  parameters[numberParameters-1].setLonghelp
    12401240    (
    12411241     "This orders the variables in order of their absolute costs - with largest cost ones being branched on \
    1242 first.  This primitive strategy can be surprsingly effective.  The column order\
    1243  option is obviously not on costs but easy to code here."
    1244      );
    1245 #if 0
    1246   parameters[numberParameters++]=
    1247     CbcOrClpParam("cpp!Generate","Generates C++ code",
    1248                   -1,50000,CPP);
    1249   parameters[numberParameters-1].setLonghelp
    1250     (
    1251      "Once you like what the stand-alone solver does then this allows \
    1252 you to generate user_driver.cpp which approximates the code.  \
    1253 0 gives simplest driver, 1 generates saves and restores, 2 \
    1254 generates saves and restores even for variables at default value. \
    1255 4 bit in cbc generates size dependent code rather than computed values."
    1256      );
    1257 #endif
     1242first.  This primitive strategy can be surprsingly effective."
     1243     );
    12581244#endif
    12591245#ifdef COIN_HAS_CLP
     
    14941480     "This switches on flow cover cuts (either at root or in entire tree) \
    14951481See branchAndCut for information on options."
    1496     parameters[numberParameters++]=
    1497       CbcOrClpParam("force!Solution","Whether to use given solution as crash for BAB",
    1498                     "off",USESOLUTION);
    1499     parameters[numberParameters-1].append("on");
    1500   parameters[numberParameters-1].setLonghelp
    1501     (
    1502      "If on then tries to branch to solution given by AMPL or priorities file."
    1503      );
    15041482     );
    15051483#endif
     
    15161494#ifdef COIN_HAS_CBC
    15171495  parameters[numberParameters++]=
     1496    CbcOrClpParam("gap!Ratio","Stop when gap between best possible and \
     1497best less than this fraction of larger of two",
     1498                  0.0,1.0e20,GAPRATIO);
     1499  parameters[numberParameters-1].setDoubleValue(0.0);
     1500  parameters[numberParameters-1].setLonghelp
     1501    (
     1502     "If the gap between best solution and best possible solution is less than this fraction \
     1503of the objective value at the root node then the search will terminate.  See 'allowableGap' for a \
     1504way of using absolute value rather than fraction."
     1505     );
     1506  parameters[numberParameters++]=
    15181507    CbcOrClpParam("gomory!Cuts","Whether to use Gomory cuts",
    15191508                  "off",GOMORYCUTS);
     
    18421831     );
    18431832  parameters[numberParameters-1].setDoubleValue(1.0);
    1844 #endif
    1845 #ifdef COIN_USE_CBC
    1846   parameters[numberParameters++]=
    1847     CbcOrClpParam("outDup!licates","takes duplicate rows etc out of integer model",
    1848                   OUTDUPROWS,7,false);
    18491833#endif
    18501834  parameters[numberParameters++]=
     
    19541938  parameters[numberParameters-1].append("sos");
    19551939  parameters[numberParameters-1].append("trysos");
    1956   parameters[numberParameters-1].append("strategy");
    19571940  parameters[numberParameters-1].setLonghelp
    19581941    (
     
    19611944 Save option saves on file presolved.mps.  equal will turn <= cliques into \
    19621945==.  sos will create sos sets if all 0-1 in sets (well one extra is allowed) \
    1963 and no overlaps.  trysos is same but allows any number extra.  strategy is as \
    1964 on but uses CbcStrategy."
     1946and no overlaps.  trysos is same but allows any number extra."
    19651947     );
    19661948#endif
     
    20512033    (
    20522034     "If set then only those names which match mask are printed in a solution. \
    2053 '?' matches any character and '*' matches any set of characters. \
    2054  The default is '' i.e. unset so all variables are printed. \
     2035'*' matches any character.  The default is '' i.e. unset so all variables are printed. \
    20552036This is only active if model has names."
    20562037     );
     
    20642045 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
    20652046 is initialized to '', i.e. it must be set.  This can not read from compressed files. \
    2066 File is in csv format with allowed headings - name, number, priority, direction, up, down, solution.  Exactly one of\
     2047File is in csv format with allowed headings - name, number, priority, direction.  Exactly one of\
    20672048 name and number must be given."
    20682049     );
     
    20852066    (
    20862067     "This stops the execution of Clp, end, exit, quit and stop are synonyms"
    2087 #ifdef COIN_USE_CBC
    2088   parameters[numberParameters++]=
    2089     CbcOrClpParam("ratio!Gap","Stop when gap between best possible and \
    2090 best less than this fraction of larger of two",
    2091                   0.0,1.0e20,GAPRATIO);
    2092   parameters[numberParameters-1].setDoubleValue(0.0);
    2093   parameters[numberParameters-1].setLonghelp
    2094     (
    2095      "If the gap between best solution and best possible solution is less than this fraction \
    2096 of the objective value at the root node then the search will terminate.  See 'allowableGap' for a \
    2097 way of using absolute value rather than fraction."
    2098      );
    2099 #endif
    21002068     );
    21012069#ifdef COIN_HAS_CLP
     
    22532221this does branch and cut."
    22542222     );
    2255     CbcOrClpParam("sos!Options","Whether to use SOS from AMPL",
    2256                   "off",SOS);
    2257   parameters[numberParameters-1].append("on");
    2258   parameters[numberParameters-1].setCurrentOption("on");
    2259   parameters[numberParameters-1].setLonghelp
    2260     (
    2261      "Normally if AMPL says there are SOS variables they should be used, but sometime sthey should\
    2262  be turned off - this does so."
    2263      );
    2264   parameters[numberParameters++]=
    22652223  parameters[numberParameters++]=
    22662224    CbcOrClpParam("slog!Level","Level of detail in Solver output",
     
    23492307  parameters[numberParameters++]=
    23502308    CbcOrClpParam("thread!s","Number of threads to try and use",
    2351                   -2,64,THREADS,false);
     2309                  -2,64,THREADS);
    23522310#endif
    23532311#ifdef COIN_HAS_CBC
     
    23972355     );
    23982356  parameters[numberParameters++]=
    2399     CbcOrClpParam("userClp","Hand coded Clp stuff",
    2400                   USERCLP);
    2401   parameters[numberParameters-1].setLonghelp
    2402     (
    2403      "There are times e.g. when using AMPL interface when you may wish to do something unusual.  \
    2404 Look for USERCLP in main driver and modify sample code."
    2405      );
    2406 #ifdef COIN_USE_CBC
    2407   parameters[numberParameters++]=
    2408     CbcOrClpParam("userCbc","Hand coded Cbc stuff",
    2409                   USERCBC);
    2410   parameters[numberParameters-1].setLonghelp
    2411     (
    2412      "There are times e.g. when using AMPL interface when you may wish to do something unusual.  \
    2413 Look for USERCBC in main driver and modify sample code."
    2414      );
    2415 #endif
    2416   parameters[numberParameters++]=
    24172357    CbcOrClpParam("verbose","Switches on longer help on single ?",
    2418                   0,15,VERBOSE,false);
     2358                  0,7,VERBOSE,false);
    24192359  parameters[numberParameters-1].setLonghelp
    24202360    (
  • trunk/Clp/src/CbcOrClpParam.hpp

    r798 r799  
    6060    MAXFACTOR,PERTVALUE,MAXITERATION,PRESOLVEPASS,IDIOT,SPRINT,
    6161    OUTPUTFORMAT,SLPVALUE,PRESOLVEOPTIONS,PRINTOPTIONS,SPECIALOPTIONS,
    62     SUBSTITUTION,DUALIZE,VERBOSE,THREADS,CPP,
     62    SUBSTITUTION,DUALIZE,VERBOSE,THREADS,
    6363
    6464    STRONGBRANCHING=151,CUTDEPTH, MAXNODES,NUMBERBEFORE,NUMBERANALYZE,
     
    7575    GOMORYCUTS,PROBINGCUTS,KNAPSACKCUTS,REDSPLITCUTS,
    7676    ROUNDING,SOLVER,CLIQUECUTS,COSTSTRATEGY,FLOWCUTS,MIXEDCUTS,
    77     TWOMIRCUTS,PREPROCESS,FPUMP,GREEDY,COMBINE,LOCALTREE,USESOLUTION,SOS,
     77    TWOMIRCUTS,PREPROCESS,FPUMP,GREEDY,COMBINE,LOCALTREE,
    7878   
    7979    DIRECTORY=301,IMPORT,EXPORT,RESTORE,SAVE,DUALSIMPLEX,PRIMALSIMPLEX,EITHERSIMPLEX,
     
    8181    TIGHTEN,FAKEBOUND,HELP,PLUSMINUS,NETWORK,ALLSLACK,REVERSE,BARRIER,NETLIB_BARRIER,NETLIB_TUNE,
    8282    REALLY_SCALE,BASISIN,BASISOUT,SOLVECONTINUOUS,CLEARCUTS,VERSION,STATISTICS,DEBUG,DUMMY,PRINTMASK,
    83     OUTDUPROWS,USERCLP,
    84 
    85     BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,USERCBC,
     83
     84    BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,
    8685
    8786    OSLSTUFF = 401,CBCSTUFF,
  • trunk/Clp/src/ClpCholeskyBase.cpp

    r798 r799  
    249249    CoinMemcpyN(region1,numberTotal,array);
    250250    CoinMemcpyN(region2,numberRowsModel,array+numberTotal);
    251     assert (numberRows_>=numberRowsModel+numberTotal);
    252251    solve(array);
    253252    int iRow;
     
    14111410    //std::sort(choleskyRow_+indexStart_[iRow]
    14121411    //      ,choleskyRow_+indexStart_[iRow]+nz);
    1413     //#define CLP_DEBUG
     1412#define CLP_DEBUG
    14141413#ifdef CLP_DEBUG
    14151414    int last=-1;
  • trunk/Clp/src/ClpCholeskyDense.cpp

    r798 r799  
    7474#define BLOCKSHIFT 4
    7575
    76 #define BLOCKSQ ( BLOCK*BLOCK )
    77 #define BLOCKSQSHIFT ( BLOCKSHIFT+BLOCKSHIFT )
     76#define BLOCKSQ BLOCK*BLOCK
     77#define BLOCKSQSHIFT BLOCKSHIFT+BLOCKSHIFT
    7878#define number_blocks(x) (((x)+BLOCK-1)>>BLOCKSHIFT)
    7979#define number_rows(x) ((x)<<BLOCKSHIFT)
  • trunk/Clp/src/ClpCholeskyUfl.cpp

    r798 r799  
    4343ClpCholeskyUfl::~ClpCholeskyUfl ()
    4444{
    45 #ifdef CLP_USE_CHOLMOD
    4645  cholmod_free_factor (&L_, &c_) ;
    4746  cholmod_finish (&c_) ;               
    48 #endif
    4947}
    5048
     
    108106{
    109107  numberRows_ = model->numberRows();
    110   if (doKKT_) {
    111     numberRows_ += numberRows_ + model->numberColumns();
    112     printf("finish coding UFL KKT!\n");
    113     abort();
    114   }
    115108  rowsDropped_ = new char [numberRows_];
    116109  memset(rowsDropped_,0,numberRows_);
  • trunk/Clp/src/ClpDualRowSteepest.cpp

    r798 r799  
    163163  // we can't really trust infeasibilities if there is primal error
    164164  // this coding has to mimic coding in checkPrimalSolution
    165   double error = CoinMin(1.0e-2,model_->largestPrimalError());
     165  double error = CoinMin(1.0e-3,model_->largestPrimalError());
    166166  // allow tolerance at least slightly bigger than standard
    167167  tolerance = tolerance +  error;
     
    915915  // we can't really trust infeasibilities if there is primal error
    916916  // this coding has to mimic coding in checkPrimalSolution
    917   double error = CoinMin(1.0e-2,model_->largestPrimalError());
     917  double error = CoinMin(1.0e-3,model_->largestPrimalError());
    918918  // allow tolerance at least slightly bigger than standard
    919919  tolerance = tolerance +  error;
  • trunk/Clp/src/ClpDynamicMatrix.cpp

    r798 r799  
    931931      double relaxedTolerance=dualTolerance;
    932932      // we can't really trust infeasibilities if there is dual error
    933       double error = CoinMin(1.0e-2,model->largestDualError());
     933      double error = CoinMin(1.0e-3,model->largestDualError());
    934934      // allow tolerance at least slightly bigger than standard
    935935      relaxedTolerance = relaxedTolerance +  error;
  • trunk/Clp/src/ClpGubDynamicMatrix.cpp

    r798 r799  
    338338    }
    339339#endif
    340 #ifdef CLP_DEBUG
    341  {
    342    for (int i=firstDynamic_;i<firstAvailable_;i++) {
    343      assert (getDynamicStatus(id_[i-firstDynamic_])==inSmall);
    344    }
    345  }
    346 #endif
    347340    int minSet = minimumObjectsScan_<0 ? 5 : minimumObjectsScan_;
    348341    int minNeg = minimumGoodReducedCosts_<0 ? 5 : minimumGoodReducedCosts_;
     
    608601          firstAvailable_++;
    609602        } else {
    610           int jColumn = id_[iColumn-firstDynamic_];
    611           setDynamicStatus(jColumn,atLowerBound);
    612603          if (lowerColumn_||upperColumn_) {
     604            int jColumn = id_[iColumn-firstDynamic_];
    613605            if (model->getStatus(iColumn)==ClpSimplex::atUpperBound)
    614606              setDynamicStatus(jColumn,atUpperBound);
     607            else
     608              setDynamicStatus(jColumn,atLowerBound);
    615609            // treat solution as if exactly at a bound
    616610            double value = solution[iColumn];
     
    642636          lowerColumn[firstAvailable_]=lowerColumn[iColumn];
    643637          upperColumn[firstAvailable_]=upperColumn[iColumn];
    644           double originalLower = lowerColumn_ ? lowerColumn_[jColumn] : 0.0;
    645           double originalUpper = upperColumn_ ? upperColumn_[jColumn] : COIN_DBL_MAX;
    646           if (originalUpper>1.0e30)
    647             originalUpper = COIN_DBL_MAX;
    648           model->nonLinearCost()->setOne(firstAvailable_,solution[iColumn],
    649                                          originalLower,originalUpper,
    650                                          cost_[jColumn]);
     638          model->nonLinearCost()->setOne(firstAvailable_,solution[iColumn],0.0,COIN_DBL_MAX,
     639                                         cost_[jColumn]);
    651640          CoinBigIndex base = startColumn_[jColumn];
    652641          for (int j=0;j<numberThis;j++) {
     
    785774      // id will be sitting at firstAvailable
    786775      int sequence = id_[firstAvailable_-firstDynamic_];
    787       assert (!flagged(sequence));
    788776      setFlagged(sequence);
    789777      model->clearFlagged(firstAvailable_);
     
    829817                                         upperColumn[i],cost_[jColumn]);
    830818      }
    831       if (!model->numberIterations()&&rhsOffset_) {
    832         lastRefresh_ = - refreshFrequency_; // force refresh
    833       }
    834819    }
    835820    break;
     
    848833      double relaxedTolerance=dualTolerance;
    849834      // we can't really trust infeasibilities if there is dual error
    850       double error = CoinMin(1.0e-2,model->largestDualError());
     835      double error = CoinMin(1.0e-3,model->largestDualError());
    851836      // allow tolerance at least slightly bigger than standard
    852837      relaxedTolerance = relaxedTolerance +  error;
     
    932917    {
    933918      returnNumber = (lowerColumn_!=NULL||upperColumn_!=NULL) ? 1 : 0;
    934 #if 0
    935       if (!returnNumber) {
    936         // may be gub slacks
    937         for (int i=0;i<numberSets_;i++) {
    938           if (upper_[i]>lower_[i]) {
    939             returnNumber=1;
    940             break;
    941           }
    942         }
    943       }
    944 #endif
    945919    }
    946920    break;
     
    13881362            // already set startColumn[firstAvailable_]=numberElements;
    13891363            id_[firstAvailable_-firstDynamic_]=iBasic;
    1390             setDynamicStatus(iBasic,inSmall);
    13911364            backward_[firstAvailable_]=iSet;
    13921365            iBasic=firstAvailable_;
     
    17311704        // and now compute value to use for key
    17321705        ClpSimplex::Status iStatus;
    1733         int iSet;
     1706  int iSet;
    17341707        for ( iSet=0;iSet<numberSets_;iSet++) {
    17351708          iColumn = keyVariable_[iSet];
     
    18751848      int bigSequence = id_[sequenceOut-firstDynamic_];
    18761849      trueOut=bigSequence+firstDynamic_;
    1877       if (getDynamicStatus(bigSequence)!=inSmall) {
    1878         if (model->getStatus(sequenceOut)==ClpSimplex::atUpperBound)
    1879           setDynamicStatus(bigSequence,atUpperBound);
    1880         else
    1881           setDynamicStatus(bigSequence,atLowerBound);
    1882       }
     1850      if (model->getStatus(sequenceOut)==ClpSimplex::atUpperBound)
     1851        setDynamicStatus(bigSequence,atUpperBound);
     1852      else
     1853        setDynamicStatus(bigSequence,atLowerBound);
    18831854      if (doPrinting)
    18841855        printf(" ,outgoing set %d big seq %d,",iSet,bigSequence);
     
    21072078  return numberInfeasible;
    21082079}
    2109 // Cleans data after setWarmStart
    2110 void
    2111 ClpGubDynamicMatrix::cleanData(ClpSimplex * model)
    2112 {
    2113   // and redo chains
    2114   int numberColumns = model->numberColumns();
    2115   int iColumn;
    2116   // do backward
    2117   int * mark = new int [numberGubColumns_];
    2118   for (iColumn=0;iColumn<numberGubColumns_;iColumn++)
    2119     mark[iColumn]=-1;
    2120   int i;
    2121   for (i=0;i<firstDynamic_;i++) {
    2122     assert (backward_[i]==-1);
    2123     next_[i]=-1;
    2124   }
    2125   for (i=firstDynamic_;i<firstAvailable_;i++) {
    2126     iColumn = id_[i-firstDynamic_];
    2127     mark[iColumn]=i;
    2128   }
    2129   for (i=0;i<numberSets_;i++) {
    2130     int iKey=keyVariable_[i];
    2131     int lastNext = -1;
    2132     int firstNext = -1;
    2133     for (CoinBigIndex k= fullStart_[i];k<fullStart_[i+1];k++) {
    2134       iColumn = mark[k];
    2135       if (iColumn>=0) {
    2136         if (iColumn!=iKey) {
    2137           if (lastNext>=0)
    2138             next_[lastNext]=iColumn;
    2139           else
    2140             firstNext = iColumn;
    2141           lastNext=iColumn;
    2142         }
    2143         backward_[iColumn]=i;
    2144       }
    2145     }
    2146     setFeasible(i);
    2147     if (firstNext>=0) {
    2148       // others
    2149       next_[iKey]=firstNext;
    2150       next_[lastNext]=-(iKey+1);
    2151     } else if (iKey<numberColumns) {
    2152       next_[iKey]=-(iKey+1);
    2153     }
    2154   }
    2155   delete [] mark;
    2156   // fill matrix
    2157   double * element =  matrix_->getMutableElements();
    2158   int * row = matrix_->getMutableIndices();
    2159   CoinBigIndex * startColumn = matrix_->getMutableVectorStarts();
    2160   int * length = matrix_->getMutableVectorLengths();
    2161   CoinBigIndex numberElements = startColumn[firstDynamic_];
    2162   for (i=firstDynamic_;i<firstAvailable_;i++) {
    2163     int iColumn = id_[i-firstDynamic_];
    2164     int numberThis = startColumn_[iColumn+1]-startColumn_[iColumn];
    2165     length[i]=numberThis;
    2166     for (CoinBigIndex jBigIndex=startColumn_[iColumn];
    2167          jBigIndex<startColumn_[iColumn+1];jBigIndex++) {
    2168       row[numberElements] = row_[jBigIndex];
    2169       element[numberElements++] = element_[jBigIndex];
    2170     }
    2171     startColumn[i+1]=numberElements;
    2172   }
    2173 }
  • trunk/Clp/src/ClpGubDynamicMatrix.hpp

    r798 r799  
    5656  */
    5757  virtual int checkFeasible(ClpSimplex * model,double & sum) const;
    58   /// Cleans data after setWarmStart
    59   void cleanData(ClpSimplex * model);
    6058  //@}
    6159
     
    155153  inline int firstAvailable() const
    156154  { return firstAvailable_;};
    157   /// set first free
    158   inline void setFirstAvailable(int value)
    159   { firstAvailable_ = value;};
    160155  /// first dynamic
    161156  inline int firstDynamic() const
  • trunk/Clp/src/ClpGubMatrix.cpp

    r798 r799  
    1515// at end to get min/max!
    1616#include "ClpGubMatrix.hpp"
    17 //#include "ClpGubDynamicMatrix.hpp"
    1817#include "ClpMessage.hpp"
    1918//#define CLP_DEBUG
     
    913912  const int * row = matrix_->getIndices();
    914913  const double * elementByColumn = matrix_->getElements();
    915   //ClpGubDynamicMatrix* gubx =
    916   //dynamic_cast< ClpGubDynamicMatrix*>(this);
    917   //int * id = gubx->id();
    918914  // just count
    919915  for (i=0;i<numberColumnBasic;i++) {
     
    924920      numberElements += length;
    925921      numberBasic++;
    926       //printf("non gub - set %d id %d (column %d) nel %d\n",iSet,id[iColumn-20],iColumn,length);
    927922    } else {
    928923      // in gub set
     
    958953        }
    959954        numberElements+=extra;
    960         //printf("gub - set %d id %d (column %d) nel %d\n",iSet,id[iColumn-20],iColumn,extra);
    961955      }
    962956    }
     
    21262120      double relaxedTolerance=primalTolerance;
    21272121      // we can't really trust infeasibilities if there is primal error
    2128       double error = CoinMin(1.0e-2,model->largestPrimalError());
     2122      double error = CoinMin(1.0e-3,model->largestPrimalError());
    21292123      // allow tolerance at least slightly bigger than standard
    21302124      relaxedTolerance = relaxedTolerance +  error;
     
    23302324      double relaxedTolerance=dualTolerance;
    23312325      // we can't really trust infeasibilities if there is dual error
    2332       double error = CoinMin(1.0e-2,model->largestDualError());
     2326      double error = CoinMin(1.0e-3,model->largestDualError());
    23332327      // allow tolerance at least slightly bigger than standard
    23342328      relaxedTolerance = relaxedTolerance +  error;
  • trunk/Clp/src/ClpMain.cpp

    r798 r799  
    1414#include "CoinPragma.hpp"
    1515#include "CoinHelperFunctions.hpp"
    16 #include "CoinSort.hpp"
    1716// History since 1.0 at end
    18 #define CLPVERSION "1.03.01"
     17#define CLPVERSION "1.02.02"
    1918
    2019#include "CoinMpsIO.hpp"
     
    5049
    5150static double totalTime=0.0;
    52 static bool maskMatches(const int * starts, char ** masks,
    53                         std::string & check);
     51static bool maskMatches(std::string & mask, std::string & check);
    5452
    5553//#############################################################################
     
    6260              ClpSimplex empty, bool doPresolve,int switchOff);
    6361static void statistics(ClpSimplex * originalModel, ClpSimplex * model);
    64 static void generateCode(const char * fileName,int type);
    6562// Returns next valid field
    6663int CbcOrClpRead_mode=1;
     
    8178    int outputFormat=2;
    8279    int slpValue=-1;
    83     int cppValue=-1;
    8480    int printOptions=0;
    8581    int printMode=0;
     
    236232          std::cout<<"Commands are:"<<std::endl;
    237233          int maxAcross=5;
    238           bool evenHidden=false;
    239           if ((verbose&8)!=0) {
    240             // even hidden
    241             evenHidden = true;
    242             verbose &= ~8;
    243           }
    244234          if (verbose)
    245235            maxAcross=1;
     
    260250            for ( iParam=0; iParam<numberParameters; iParam++ ) {
    261251              int type = parameters[iParam].type();
    262               if ((parameters[iParam].displayThis()||evenHidden)&&
    263                   type>=limits[iType]
     252              if (parameters[iParam].displayThis()&&type>=limits[iType]
    264253                  &&type<limits[iType+1]) {
    265254                if (!across) {
     
    347336            else if (parameters[iParam].type()==SLPVALUE)
    348337              slpValue = value;
    349             else if (parameters[iParam].type()==CPP)
    350               cppValue = value;
    351338            else if (parameters[iParam].type()==PRESOLVEOPTIONS)
    352339              presolveOptions = value;
     
    641628              }
    642629              int status;
    643               if (cppValue>=0) {
    644                 // generate code
    645                 FILE * fp = fopen("user_driver.cpp","w");
    646                 if (fp) {
    647                   // generate enough to do solveOptions
    648                   model2->generateCpp(fp);
    649                   solveOptions.generateCpp(fp);
    650                   fclose(fp);
    651                   // now call generate code
    652                   generateCode("user_driver.cpp",cppValue);
    653                 } else {
    654                   std::cout<<"Unable to open file user_driver.cpp"<<std::endl;
    655                 }
    656               }
    657630              try {
    658631                status=model2->initialSolve(solveOptions);
     
    14471420            }
    14481421            break;
    1449           case USERCLP:
    1450             // Replace the sample code by whatever you want
    1451             if (goodModels[iModel]) {
    1452               ClpSimplex * thisModel = &models[iModel];
    1453               printf("Dummy user code - model has %d rows and %d columns\n",
    1454                      thisModel->numberRows(),thisModel->numberColumns());
    1455             }
    1456             break;
    14571422          case HELP:
    14581423            std::cout<<"Coin LP version "<<CLPVERSION
     
    15321497                sprintf(format,"%%-%ds",CoinMax(lengthName,8));
    15331498                bool doMask = (printMask!=""&&lengthName);
    1534                 int * maskStarts=NULL;
    1535                 int maxMasks=0;
    1536                 char ** masks =NULL;
    1537                 if (doMask) {
    1538                   int nAst =0;
    1539                   const char * pMask2 = printMask.c_str();
    1540                   char pMask[100];
    1541                   int iChar;
    1542                   int lengthMask = strlen(pMask2);
    1543                   assert (lengthMask<100);
    1544                   if (*pMask2=='"') {
    1545                     if (pMask2[lengthMask-1]!='"') {
    1546                       printf("mismatched \" in mask %s\n",pMask2);
    1547                       break;
    1548                     } else {
    1549                       strcpy(pMask,pMask2+1);
    1550                       *strchr(pMask,'"')='\0';
    1551                     }
    1552                   } else if (*pMask2=='\'') {
    1553                     if (pMask2[lengthMask-1]!='\'') {
    1554                       printf("mismatched ' in mask %s\n",pMask2);
    1555                       break;
    1556                     } else {
    1557                       strcpy(pMask,pMask2+1);
    1558                       *strchr(pMask,'\'')='\0';
    1559                     }
    1560                   } else {
    1561                     strcpy(pMask,pMask2);
    1562                   }
    1563                   if (lengthMask>lengthName) {
    1564                     printf("mask %s too long - skipping\n",pMask);
    1565                     break;
    1566                   }
    1567                   maxMasks = 1;
    1568                   for (iChar=0;iChar<lengthMask;iChar++) {
    1569                     if (pMask[iChar]=='*') {
    1570                       nAst++;
    1571                       maxMasks *= (lengthName+1);
    1572                     }
    1573                   }
    1574                   int nEntries = 1;
    1575                   maskStarts = new int[lengthName+2];
    1576                   masks = new char * [maxMasks];
    1577                   char ** newMasks = new char * [maxMasks];
    1578                   int i;
    1579                   for (i=0;i<maxMasks;i++) {
    1580                     masks[i] = new char[lengthName+1];
    1581                     newMasks[i] = new char[lengthName+1];
    1582                   }
    1583                   strcpy(masks[0],pMask);
    1584                   for (int iAst=0;iAst<nAst;iAst++) {
    1585                     int nOldEntries = nEntries;
    1586                     nEntries=0;
    1587                     for (int iEntry = 0;iEntry<nOldEntries;iEntry++) {
    1588                       char * oldMask = masks[iEntry];
    1589                       char * ast = strchr(oldMask,'*');
    1590                       assert (ast);
    1591                       int length = strlen(oldMask)-1;
    1592                       int nBefore = ast-oldMask;
    1593                       int nAfter = length-nBefore;
    1594                       // and add null
    1595                       nAfter++;
    1596                       for (int i=0;i<=lengthName-length;i++) {
    1597                         char * maskOut = newMasks[nEntries];
    1598                         memcpy(maskOut,oldMask,nBefore);
    1599                         for (int k=0;k<i;k++)
    1600                           maskOut[k+nBefore]='?';
    1601                         memcpy(maskOut+nBefore+i,ast+1,nAfter);
    1602                         nEntries++;
    1603                         assert (nEntries<=maxMasks);
    1604                       }
    1605                     }
    1606                     char ** temp = masks;
    1607                     masks = newMasks;
    1608                     newMasks = temp;
    1609                   }
    1610                   // Now extend and sort
    1611                   int * sort = new int[nEntries];
    1612                   for (i=0;i<nEntries;i++) {
    1613                     char * maskThis = masks[i];
    1614                     int length = strlen(maskThis);
    1615                     while (maskThis[length-1]==' ')
    1616                       length--;
    1617                     maskThis[length]='\0';
    1618                     sort[i]=length;
    1619                   }
    1620                   CoinSort_2(sort,sort+nEntries,masks);
    1621                   int lastLength=-1;
    1622                   for (i=0;i<nEntries;i++) {
    1623                     int length = sort[i];
    1624                     while (length>lastLength)
    1625                       maskStarts[++lastLength] = i;
    1626                   }
    1627                   maskStarts[++lastLength]=nEntries;
    1628                   delete [] sort;
    1629                   for (i=0;i<maxMasks;i++)
    1630                     delete [] newMasks[i];
    1631                   delete [] newMasks;
    1632                 }
    16331499                if (printMode>2) {
    16341500                  for (iRow=0;iRow<numberRows;iRow++) {
     
    16431509                      type=3;
    16441510                    }
    1645                     if (doMask&&!maskMatches(maskStarts,masks,rowNames[iRow]))
     1511                    if (doMask&&!maskMatches(printMask,rowNames[iRow]))
    16461512                      type=0;
    16471513                    if (type) {
     
    16571523                int numberColumns=models[iModel].numberColumns();
    16581524                double * dualColumnSolution =
    1659   models[iModel].dualColumnSolution();
     1525                  models[iModel].dualColumnSolution();
    16601526                double * primalColumnSolution =
    1661   models[iModel].primalColumnSolution();
     1527                  models[iModel].primalColumnSolution();
    16621528                double * columnLower = models[iModel].columnLower();
    16631529                double * columnUpper = models[iModel].columnUpper();
     
    16731539                    type=3;
    16741540                  }
    1675                   if (doMask&&!maskMatches(maskStarts,masks,
    1676                                            columnNames[iColumn]))
     1541                  if (doMask&&!maskMatches(printMask,columnNames[iColumn]))
    16771542                    type =0;
    16781543                  if (type) {
     
    16871552                if (fp!=stdout)
    16881553                  fclose(fp);
    1689                 if (masks) {
    1690                   delete [] maskStarts;
    1691                   for (int i=0;i<maxMasks;i++)
    1692                     delete [] masks[i];
    1693                   delete [] masks;
    1694                 }
    16951554              } else {
    16961555                std::cout<<"Unable to open file "<<fileName<<std::endl;
     
    17001559             
    17011560            }
    1702          
    17031561            break;
    17041562          case SAVESOL:
     
    20801938  breakdown("Objective",numberColumns,objective);
    20811939}
    2082 static bool maskMatches(const int * starts, char ** masks,
    2083                         std::string & check)
     1940static bool maskMatches(std::string & mask, std::string & check)
    20841941{
    20851942  // back to char as I am old fashioned
     1943  const char * maskC = mask.c_str();
    20861944  const char * checkC = check.c_str();
    2087   int length = strlen(checkC);
    2088   while (checkC[length-1]==' ')
    2089     length--;
    2090   for (int i=starts[length];i<starts[length+1];i++) {
    2091     char * thisMask = masks[i];
    2092     int k;
    2093     for ( k=0;k<length;k++) {
    2094       if (thisMask[k]!='?'&&thisMask[k]!=checkC[k])
    2095         break;
    2096     }
    2097     if (k==length)
    2098       return true;
     1945  int length = strlen(maskC);
     1946  int lengthCheck;
     1947  for (lengthCheck=length-1;lengthCheck>=0;lengthCheck--) {
     1948    if (maskC[lengthCheck]!='*')
     1949      break;
    20991950  }
    2100   return false;
    2101 }
    2102 static void clean(char * temp)
    2103 {
    2104   char * put = temp;
    2105   while (*put>=' ')
    2106     put++;
    2107   *put='\0';
    2108 }
    2109 static void generateCode(const char * fileName,int type)
    2110 {
    2111   FILE * fp = fopen(fileName,"r");
    2112   assert (fp);
    2113   int numberLines=0;
    2114 #define MAXLINES 500
    2115 #define MAXONELINE 200
    2116   char line[MAXLINES][MAXONELINE];
    2117   while (fgets(line[numberLines],MAXONELINE,fp)) {
    2118     assert (numberLines<MAXLINES);
    2119     clean(line[numberLines]);
    2120     numberLines++;
    2121   }
    2122   fclose(fp);
    2123   // add in actual solve
    2124   strcpy(line[numberLines],"5  clpModel->initialSolve(clpSolve);");
    2125   numberLines++;
    2126   fp = fopen(fileName,"w");
    2127   assert (fp);
    2128   char apo='"';   
    2129   char backslash = '\\';
    2130 
    2131   fprintf(fp,"#include %cClpSimplex.hpp%c\n",apo,apo);
    2132   fprintf(fp,"#include %cClpSolve.hpp%c\n",apo,apo);
    2133 
    2134   fprintf(fp,"\nint main (int argc, const char *argv[])\n{\n");
    2135   fprintf(fp,"  ClpSimplex  model;\n");
    2136   fprintf(fp,"  int status=1;\n");
    2137   fprintf(fp,"  if (argc<2)\n");
    2138   fprintf(fp,"    fprintf(stderr,%cPlease give file name%cn%c);\n",
    2139           apo,backslash,apo);
    2140   fprintf(fp,"  else\n");
    2141   fprintf(fp,"    status=model.readMps(argv[1],true);\n");
    2142   fprintf(fp,"  if (status) {\n");
    2143   fprintf(fp,"    fprintf(stderr,%cBad readMps %%s%cn%c,argv[1]);\n",
    2144                 apo,backslash,apo);
    2145   fprintf(fp,"    exit(1);\n");
    2146   fprintf(fp,"  }\n\n");
    2147   fprintf(fp,"  // Now do requested saves and modifications\n");
    2148   fprintf(fp,"  ClpSimplex * clpModel = & model;\n");
    2149   int wanted[9];
    2150   memset(wanted,0,sizeof(wanted));
    2151   wanted[0]=wanted[3]=wanted[5]=wanted[8]=1;
    2152   if (type>0)
    2153     wanted[1]=wanted[6]=1;
    2154   if (type>1)
    2155     wanted[2]=wanted[4]=wanted[7]=1;
    2156   std::string header[9]=
    2157   { "","Save values","Redundant save of default values","Set changed values",
    2158     "Redundant set default values","Solve","Restore values","Redundant restore values","Add to model"};
    2159   for (int iType=0;iType<9;iType++) {
    2160     if (!wanted[iType])
    2161       continue;
    2162     int n=0;
    2163     int iLine;
    2164     for (iLine=0;iLine<numberLines;iLine++) {
    2165       if (line[iLine][0]=='0'+iType) {
    2166         if (!n)
    2167           fprintf(fp,"\n  // %s\n\n",header[iType].c_str());
    2168         n++;
    2169         fprintf(fp,"%s\n",line[iLine]+1);
    2170       }
     1951  lengthCheck++;
     1952  int lengthC = strlen(checkC);
     1953  if (lengthC>length)
     1954    return false; // can't be true
     1955  if (lengthC<lengthCheck) {
     1956    // last lot must be blank for match
     1957    for (int i=lengthC;i<lengthCheck;i++) {
     1958      if (maskC[i]!=' ')
     1959        return false;
    21711960    }
    21721961  }
    2173   fprintf(fp,"\n  // Now you would use solution etc etc\n\n");
    2174   fprintf(fp,"  return 0;\n}\n");
    2175   fclose(fp);
    2176   printf("C++ file written to %s\n",fileName);
     1962  // need only check this much
     1963  lengthC = CoinMin(lengthC,lengthCheck);
     1964  for (int i=0;i<lengthC;i++) {
     1965    if (maskC[i]!='*'&&maskC[i]!=checkC[i])
     1966      return false;
     1967  }
     1968  return true; // matches
    21771969}
    21781970/*
    21791971  Version 1.00.00 October 13 2004.
    2180   1.00.01 October 18.  Added basis handling helped/prodded by Thorsten Koch.
     1972  1.00.01 October 18.  Added basis handline helped/prodded by Thorsten Koch.
    21811973  Also modifications to make faster with sbb (I hope I haven't broken anything).
    21821974  1.00.02 March 21 2005.  Redid ClpNonLinearCost to save memory also redid
     
    21911983  branch and cut.
    21921984  1.02.02 May 19 2005.  Stuff for strong branching and some improvements to simplex
    2193   1.03.01 May 24 2006.  Lots done but I can't remember what!
    21941985 */
  • trunk/Clp/src/ClpMatrixBase.cpp

    r798 r799  
    191191  smallestPositive=0.0;
    192192  largestPositive=0.0;
    193 }
    194 /* The length of a major-dimension vector. */
    195 int
    196 ClpMatrixBase::getVectorLength(int index) const
    197 {
    198   return getVectorLengths()[index];
    199193}
    200194// Says whether it can do partial pricing
     
    578572   is thrown. */
    579573void
    580 ClpMatrixBase::setDimensions(int numrows, int numcols){
     574ClpMatrixBase::setDimensions(int numrows, int numcols) throw(CoinError)
     575{
    581576  // If odd matrix assume user knows what they are doing
    582577}
  • trunk/Clp/src/ClpMatrixBase.hpp

    r798 r799  
    5555  /** The lengths of the major-dimension vectors. */
    5656  virtual const int * getVectorLengths() const = 0 ;
    57   /** The length of a single major-dimension vector. */
    58   virtual int getVectorLength(int index) const ;
    5957  /** Delete the columns whose indices are listed in <code>indDel</code>. */
    6058  virtual void deleteCols(const int numDel, const int * indDel) = 0;
     
    105103  virtual void scaleRowCopy(ClpModel * model) const
    106104  { };
    107   /// Returns true if can create row copy
    108   virtual bool canGetRowCopy() const
    109   { return true;};
    110105  /** Realy really scales column copy
    111106      Only called if scales already exist.
     
    133128      MUST be at least as large as the current ones otherwise an exception
    134129      is thrown. */
    135   virtual void setDimensions(int numrows, int numcols);
     130  virtual void setDimensions(int numrows, int numcols) throw(CoinError);
    136131  /** Returns largest and smallest elements of both signs.
    137132      Largest refers to largest absolute value.
     
    145140                      int column) const =0;
    146141  /** Unpacks a column into an CoinIndexedvector
    147    ** in packed format
     142   ** in packed foramt
    148143   Note that model is NOT const.  Bounds and objective could
    149144   be modified if doing column generation (just for this variable) */
  • trunk/Clp/src/ClpModel.cpp

    r798 r799  
    1 // copyright (C) 2002, International Business Machines
     1// Copyright (C) 2002, International Business Machines
    22// Corporation and others.  All Rights Reserved.
    33
     
    34553455  return *this;
    34563456}
    3457 // Create C++ lines to get to current state
    3458 void
    3459 ClpModel::generateCpp( FILE * fp)
    3460 {
    3461   // Stuff that can't be done easily
    3462   if (!lengthNames_) {
    3463     // no names
    3464     fprintf(fp,"  clpModel->dropNames();\n");
    3465   }
    3466   ClpModel defaultModel;
    3467   ClpModel * other = &defaultModel;
    3468   int iValue1, iValue2;
    3469   double dValue1, dValue2;
    3470   iValue1 = this->maximumIterations();
    3471   iValue2 = other->maximumIterations();
    3472   fprintf(fp,"%d  int save_maximumIterations = clpModel->maximumIterations();\n",iValue1==iValue2 ? 2 : 1);
    3473   fprintf(fp,"%d  clpModel->setMaximumIterations(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    3474   fprintf(fp,"%d  clpModel->setMaximumIterations(save_maximumIterations);\n",iValue1==iValue2 ? 7 : 6);
    3475   dValue1 = this->primalTolerance();
    3476   dValue2 = other->primalTolerance();
    3477   fprintf(fp,"%d  double save_primalTolerance = clpModel->primalTolerance();\n",dValue1==dValue2 ? 2 : 1);
    3478   fprintf(fp,"%d  clpModel->setPrimalTolerance(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    3479   fprintf(fp,"%d  clpModel->setPrimalTolerance(save_primalTolerance);\n",dValue1==dValue2 ? 7 : 6);
    3480   dValue1 = this->dualTolerance();
    3481   dValue2 = other->dualTolerance();
    3482   fprintf(fp,"%d  double save_dualTolerance = clpModel->dualTolerance();\n",dValue1==dValue2 ? 2 : 1);
    3483   fprintf(fp,"%d  clpModel->setDualTolerance(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    3484   fprintf(fp,"%d  clpModel->setDualTolerance(save_dualTolerance);\n",dValue1==dValue2 ? 7 : 6);
    3485   iValue1 = this->numberIterations();
    3486   iValue2 = other->numberIterations();
    3487   fprintf(fp,"%d  int save_numberIterations = clpModel->numberIterations();\n",iValue1==iValue2 ? 2 : 1);
    3488   fprintf(fp,"%d  clpModel->setNumberIterations(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    3489   fprintf(fp,"%d  clpModel->setNumberIterations(save_numberIterations);\n",iValue1==iValue2 ? 7 : 6);
    3490   dValue1 = this->maximumSeconds();
    3491   dValue2 = other->maximumSeconds();
    3492   fprintf(fp,"%d  double save_maximumSeconds = clpModel->maximumSeconds();\n",dValue1==dValue2 ? 2 : 1);
    3493   fprintf(fp,"%d  clpModel->setMaximumSeconds(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    3494   fprintf(fp,"%d  clpModel->setMaximumSeconds(save_maximumSeconds);\n",dValue1==dValue2 ? 7 : 6);
    3495   dValue1 = this->optimizationDirection();
    3496   dValue2 = other->optimizationDirection();
    3497   fprintf(fp,"%d  double save_optimizationDirection = clpModel->optimizationDirection();\n",dValue1==dValue2 ? 2 : 1);
    3498   fprintf(fp,"%d  clpModel->setOptimizationDirection(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    3499   fprintf(fp,"%d  clpModel->setOptimizationDirection(save_optimizationDirection);\n",dValue1==dValue2 ? 7 : 6);
    3500   dValue1 = this->objectiveScale();
    3501   dValue2 = other->objectiveScale();
    3502   fprintf(fp,"%d  double save_objectiveScale = clpModel->objectiveScale();\n",dValue1==dValue2 ? 2 : 1);
    3503   fprintf(fp,"%d  clpModel->setObjectiveScale(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    3504   fprintf(fp,"%d  clpModel->setObjectiveScale(save_objectiveScale);\n",dValue1==dValue2 ? 7 : 6);
    3505   dValue1 = this->rhsScale();
    3506   dValue2 = other->rhsScale();
    3507   fprintf(fp,"%d  double save_rhsScale = clpModel->rhsScale();\n",dValue1==dValue2 ? 2 : 1);
    3508   fprintf(fp,"%d  clpModel->setRhsScale(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    3509   fprintf(fp,"%d  clpModel->setRhsScale(save_rhsScale);\n",dValue1==dValue2 ? 7 : 6);
    3510   iValue1 = this->scalingFlag();
    3511   iValue2 = other->scalingFlag();
    3512   fprintf(fp,"%d  int save_scalingFlag = clpModel->scalingFlag();\n",iValue1==iValue2 ? 2 : 1);
    3513   fprintf(fp,"%d  clpModel->scaling(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    3514   fprintf(fp,"%d  clpModel->scaling(save_scalingFlag);\n",iValue1==iValue2 ? 7 : 6);
    3515   dValue1 = this->getSmallElementValue();
    3516   dValue2 = other->getSmallElementValue();
    3517   fprintf(fp,"%d  double save_getSmallElementValue = clpModel->getSmallElementValue();\n",dValue1==dValue2 ? 2 : 1);
    3518   fprintf(fp,"%d  clpModel->setSmallElementValue(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    3519   fprintf(fp,"%d  clpModel->setSmallElementValue(save_getSmallElementValue);\n",dValue1==dValue2 ? 7 : 6);
    3520   iValue1 = this->logLevel();
    3521   iValue2 = other->logLevel();
    3522   fprintf(fp,"%d  int save_logLevel = clpModel->logLevel();\n",iValue1==iValue2 ? 2 : 1);
    3523   fprintf(fp,"%d  clpModel->setLogLevel(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    3524   fprintf(fp,"%d  clpModel->setLogLevel(save_logLevel);\n",iValue1==iValue2 ? 7 : 6);
    3525 }
  • trunk/Clp/src/ClpModel.hpp

    r798 r799  
    1414//#define COIN_USE_CLP
    1515//#endif
    16 #include "ClpPackedMatrix.hpp"
     16#include "ClpMatrixBase.hpp"
    1717#include "CoinMessageHandler.hpp"
    1818#include "ClpParameters.hpp"
     
    571571      and new is used)
    572572      So up to user to delete current.  This was used where
    573       matrices were being rotated. ClpModel takes ownership.
    574   /** Replace Clp Matrix (current is not deleted unless told to
    575       and new is used) So up to user to delete current.  This was used where
    576       matrices were being rotated.  This version changes CoinPackedMatrix
    577       to ClpPackedMatrix.  ClpModel takes ownership.
    578   */
    579    inline void replaceMatrix(CoinPackedMatrix * matrix,
    580                              bool deleteCurrent=false)
    581   { replaceMatrix(new ClpPackedMatrix(matrix),deleteCurrent);};
     573      matrices were being rotated.
    582574  */
    583575   void replaceMatrix(ClpMatrixBase * matrix,bool deleteCurrent=false);
     
    770762        return false;
    771763      }
    772     /// Create C++ lines to get to current state
    773     void generateCpp( FILE * fp);
    774764    }
    775765#endif
  • trunk/Clp/src/ClpNonLinearCost.hpp

    r798 r799  
    5050{ status &= ~(15<<4);status |= (CLP_SAME<<4);}
    5151// Use second version to get more speed
    52 //#define FAST_CLPNON
     52#define FAST_CLPNON
    5353#ifndef FAST_CLPNON
    5454#define CLP_METHOD1 ((method_&1)!=0)
  • trunk/Clp/src/ClpPackedMatrix.cpp

    r798 r799  
    28382838   is thrown. */
    28392839void
    2840 ClpPackedMatrix::setDimensions(int numrows, int numcols)
     2840ClpPackedMatrix::setDimensions(int numrows, int numcols) throw(CoinError)
    28412841{
    28422842  matrix_->setDimensions(numrows,numcols);
  • trunk/Clp/src/ClpPackedMatrix.hpp

    r798 r799  
    5252   virtual const int * getVectorLengths() const
    5353  { return matrix_->getVectorLengths();} ;
    54   /** The length of a single major-dimension vector. */
    55   virtual int getVectorLength(int index) const
    56   { return matrix_->getVectorSize(index);};
    5754
    5855    /** Delete the columns whose indices are listed in <code>indDel</code>. */
     
    168165      MUST be at least as large as the current ones otherwise an exception
    169166      is thrown. */
    170   virtual void setDimensions(int numrows, int numcols);
     167  virtual void setDimensions(int numrows, int numcols) throw(CoinError);
    171168   //@}
    172169
  • trunk/Clp/src/ClpPlusMinusOneMatrix.cpp

    r798 r799  
    159159  } else {
    160160    numberRows_ ++; //  correct
    161     // but number should be same as rhs
    162     assert (numberRows_<=rhs.getNumRows());
    163     numberRows_ = rhs.getNumRows();
    164161    columnOrdered_ = true;
    165162  }
     
    18741871void
    18751872ClpPlusMinusOneMatrix::setDimensions(int newnumrows, int newnumcols)
     1873  throw(CoinError)
    18761874{
    18771875  if (newnumrows < 0)
  • trunk/Clp/src/ClpPlusMinusOneMatrix.hpp

    r798 r799  
    115115      MUST be at least as large as the current ones otherwise an exception
    116116      is thrown. */
    117   virtual void setDimensions(int numrows, int numcols);
     117  virtual void setDimensions(int numrows, int numcols) throw(CoinError);
    118118  /// Just checks matrix valid - will say if dimensions not quite right if detail
    119119  void checkValid(bool detail) const;
  • trunk/Clp/src/ClpPrimalColumnSteepest.cpp

    r798 r799  
    180180  // we can't really trust infeasibilities if there is dual error
    181181  // this coding has to mimic coding in checkDualSolution
    182   double error = CoinMin(1.0e-2,model_->largestDualError());
     182  double error = CoinMin(1.0e-3,model_->largestDualError());
    183183  // allow tolerance at least slightly bigger than standard
    184184  tolerance = tolerance +  error;
     
    273273      if (switchType==5) {
    274274        numberLook *= 5; // needs tuning for gub
    275         if (model_->numberIterations()%1000==0&&model_->logLevel()>1) {
     275        if (model_->numberIterations()%1000==0)
    276276          printf("numels %d ratio %g wanted %d look %d\n",
    277277                 sizeFactorization_,ratio,numberWanted,numberLook);
    278         }
    279278        // Update duals and row djs
    280279        // Do partial pricing
     
    487486    infeasible_->setNumElements(number);
    488487  }
    489   if(model_->numberIterations()<model_->lastBadIteration()+200&&
    490      model_->factorization()->pivots()>10) {
     488  if(model_->numberIterations()<model_->lastBadIteration()+200) {
    491489    // we can't really trust infeasibilities if there is dual error
    492490    double checkTolerance = 1.0e-8;
     491    if (!model_->factorization()->pivots())
     492      checkTolerance = 1.0e-6;
    493493    if (model_->largestDualError()>checkTolerance)
    494494      tolerance *= model_->largestDualError()/checkTolerance;
     
    606606  // we can't really trust infeasibilities if there is dual error
    607607  // this coding has to mimic coding in checkDualSolution
    608   double error = CoinMin(1.0e-2,model_->largestDualError());
     608  double error = CoinMin(1.0e-3,model_->largestDualError());
    609609  // allow tolerance at least slightly bigger than standard
    610610  tolerance = tolerance +  error;
     
    711711  // we can't really trust infeasibilities if there is dual error
    712712  // this coding has to mimic coding in checkDualSolution
    713   double error = CoinMin(1.0e-2,model_->largestDualError());
     713  double error = CoinMin(1.0e-3,model_->largestDualError());
    714714  // allow tolerance at least slightly bigger than standard
    715715  tolerance = tolerance +  error;
     
    951951  // we can't really trust infeasibilities if there is dual error
    952952  // this coding has to mimic coding in checkDualSolution
    953   double error = CoinMin(1.0e-2,model_->largestDualError());
     953  double error = CoinMin(1.0e-3,model_->largestDualError());
    954954  // allow tolerance at least slightly bigger than standard
    955955  tolerance = tolerance +  error;
     
    12211221  // we can't really trust infeasibilities if there is dual error
    12221222  // this coding has to mimic coding in checkDualSolution
    1223   double error = CoinMin(1.0e-2,model_->largestDualError());
     1223  double error = CoinMin(1.0e-3,model_->largestDualError());
    12241224  // allow tolerance at least slightly bigger than standard
    12251225  tolerance = tolerance +  error;
     
    14131413  // we can't really trust infeasibilities if there is dual error
    14141414  // this coding has to mimic coding in checkDualSolution
    1415   double error = CoinMin(1.0e-2,model_->largestDualError());
     1415  double error = CoinMin(1.0e-3,model_->largestDualError());
    14161416  // allow tolerance at least slightly bigger than standard
    14171417  tolerance = tolerance +  error;
     
    17351735  // we can't really trust infeasibilities if there is dual error
    17361736  // this coding has to mimic coding in checkDualSolution
    1737   double error = CoinMin(1.0e-2,model_->largestDualError());
     1737  double error = CoinMin(1.0e-3,model_->largestDualError());
    17381738  // allow tolerance at least slightly bigger than standard
    17391739  tolerance = tolerance +  error;
     
    18431843  // we can't really trust infeasibilities if there is dual error
    18441844  // this coding has to mimic coding in checkDualSolution
    1845   double error = CoinMin(1.0e-2,model_->largestDualError());
     1845  double error = CoinMin(1.0e-3,model_->largestDualError());
    18461846  // allow tolerance at least slightly bigger than standard
    18471847  tolerance = tolerance +  error;
     
    19921992  // we can't really trust infeasibilities if there is dual error
    19931993  // this coding has to mimic coding in checkDualSolution
    1994   double error = CoinMin(1.0e-2,model_->largestDualError());
     1994  double error = CoinMin(1.0e-3,model_->largestDualError());
    19951995  // allow tolerance at least slightly bigger than standard
    19961996  tolerance = tolerance +  error;
     
    33743374  // we can't really trust infeasibilities if there is dual error
    33753375  // this coding has to mimic coding in checkDualSolution
    3376   double error = CoinMin(1.0e-2,model_->largestDualError());
     3376  double error = CoinMin(1.0e-3,model_->largestDualError());
    33773377  // allow tolerance at least slightly bigger than standard
    33783378  tolerance = tolerance +  error;
     
    35023502  // we can't really trust infeasibilities if there is dual error
    35033503  // this coding has to mimic coding in checkDualSolution
    3504   double error = CoinMin(1.0e-2,model_->largestDualError());
     3504  double error = CoinMin(1.0e-3,model_->largestDualError());
    35053505  // allow tolerance at least slightly bigger than standard
    35063506  tolerance = tolerance +  error;
     
    36133613  double * duals2 = duals-numberColumns;
    36143614  int chunk = CoinMin(1024,(numberColumns+nSlacks)/32);
    3615   if (model_->numberIterations()%1000==0&&model_->logLevel()>1) {
     3615  if (model_->numberIterations()%1000==0) {
    36163616    printf("%d wanted, nSlacks %d, chunk %d\n",numberWanted,nSlacks,chunk);
    36173617    int i;
  • trunk/Clp/src/ClpQuadraticObjective.cpp

    r798 r799  
    692692
    693693  // Btran basic costs
     694  double * work = workSpace->denseVector();
    694695  model->factorization()->updateColumnTranspose(workSpace,&arrayVector);
    695   double * work = workSpace->denseVector();
    696696  ClpFillN(work,numberRows,0.0);
    697697  // now look at dual solution
  • trunk/Clp/src/ClpSimplex.cpp

    r798 r799  
    554554  double lastError=COIN_DBL_MAX;
    555555  int iRefine;
     556  double * work = workSpace->denseVector();
    556557  CoinIndexedVector * thisVector = arrayVector;
    557558  CoinIndexedVector * lastVector = previousVector;
    558559  factorization_->updateColumn(workSpace,thisVector);
    559   double * work = workSpace->denseVector();
    560560#ifdef CLP_DEBUG
    561561  if (numberIterations_==-3840) {
     
    15321532      // need to reject something
    15331533      int iSequence;
    1534       if (algorithm_>0)
     1534      if (algorithm_<0)
    15351535        iSequence = sequenceIn_;
    15361536      else
     
    20512051  double relaxedTolerance=primalTolerance_;
    20522052  // we can't really trust infeasibilities if there is primal error
    2053   double error = CoinMin(1.0e-2,largestPrimalError_);
     2053  double error = CoinMin(1.0e-3,largestPrimalError_);
    20542054  // allow tolerance at least slightly bigger than standard
    20552055  relaxedTolerance = relaxedTolerance +  error;
     
    21642164  double relaxedTolerance=dualTolerance_;
    21652165  // we can't really trust infeasibilities if there is dual error
    2166   double error = CoinMin(1.0e-2,largestDualError_);
     2166  double error = CoinMin(1.0e-3,largestDualError_);
    21672167  // allow tolerance at least slightly bigger than standard
    21682168  relaxedTolerance = relaxedTolerance +  error;
     
    23452345  double relaxedToleranceP=primalTolerance_;
    23462346  // we can't really trust infeasibilities if there is primal error
    2347   double error = CoinMin(1.0e-2,largestPrimalError_);
     2347  double error = CoinMin(1.0e-3,largestPrimalError_);
    23482348  // allow tolerance at least slightly bigger than standard
    23492349  relaxedToleranceP = relaxedToleranceP +  error;
     
    23542354  double relaxedToleranceD=dualTolerance;
    23552355  // we can't really trust infeasibilities if there is dual error
    2356   error = CoinMin(1.0e-2,largestDualError_);
     2356  error = CoinMin(1.0e-3,largestDualError_);
    23572357  // allow tolerance at least slightly bigger than standard
    23582358  relaxedToleranceD = relaxedToleranceD +  error;
     
    25222522bool
    25232523ClpSimplex::createRim(int what,bool makeRowCopy, int startFinishOptions)
    2524   spareIntArray_[0]=0;
    2525   if (!matrix_->canGetRowCopy())
    2526     makeRowCopy=false; // switch off row copy if can't produce
    25272524{
    25282525  bool goodMatrix=true;
     
    47434740#elif UFL_BARRIER
    47444741 if (!doKKT) {
    4745    ClpCholeskyBase * cholesky = new ClpCholeskyBase();
    4746    // not yetClpCholeskyUfl * cholesky = new ClpCholeskyUfl();
     4742   ClpCholeskyUfl * cholesky = new ClpCholeskyUfl();
    47474743   barrier.setCholesky(cholesky);
    47484744 } else {
     
    50115007  primalTolerance_ = otherModel.primalTolerance_;
    50125008  delete dualRowPivot_;
    5013   dualRowPivot_ = otherModel.dualRowPivot_->clone(true);
     5009  dualRowPivot_ = otherModel.dualRowPivot_->clone(false);
    50145010  delete primalColumnPivot_;
    5015   primalColumnPivot_ = otherModel.primalColumnPivot_->clone(true);
     5011  primalColumnPivot_ = otherModel.primalColumnPivot_->clone(false);
    50165012  perturbation_ = otherModel.perturbation_;
    50175013  specialOptions_ = otherModel.specialOptions_;
     
    73227318          char x = model_->isColumn(iSequence) ? 'C' :'R';
    73237319          if (model_->messageHandler()->logLevel()>=63)
    7324           // if Gub then needs to be sequenceIn_
    7325           int save=model_->sequenceIn();
    7326           model_->setSequenceIn(iSequence);
    73277320            model_->messageHandler()->message(CLP_SIMPLEX_FLAG,model_->messages())
    7328           model_->setSequenceIn(save);
    73297321              <<x<<model_->sequenceWithin(iSequence)
    73307322              <<CoinMessageEol;
     
    87948786    else
    87958787      frequency=base+cutoff1/freq0 + (cutoff2-cutoff1)/freq1 + (numberRows_-cutoff2)/freq2;
    8796 // Create C++ lines to get to current state
    8797 void
    8798 ClpSimplex::generateCpp( FILE * fp, bool defaultFactor)
    8799 {
    8800   ClpModel::generateCpp(fp);
    8801   ClpSimplex defaultModel;
    8802   ClpSimplex * other = &defaultModel;
    8803   int iValue1, iValue2;
    8804   double dValue1, dValue2;
    8805   // Stuff that can't be done easily
    8806   if (factorizationFrequency()==other->factorizationFrequency()) {
    8807     if (defaultFactor) {
    8808       fprintf(fp,"3  // For branchAndBound this may help\n");
    8809       fprintf(fp,"3  clpModel->defaultFactorizationFrequency();\n");
    8810     } else {
    8811       // tell user about default
    8812       fprintf(fp,"3  // For initialSolve you don't need below but ...\n");
    8813       fprintf(fp,"3  // clpModel->defaultFactorizationFrequency();\n");
    8814     }
    8815   }
    8816   iValue1 = this->factorizationFrequency();
    8817   iValue2 = other->factorizationFrequency();
    8818   fprintf(fp,"%d  int save_factorizationFrequency = clpModel->factorizationFrequency();\n",iValue1==iValue2 ? 2 : 1);
    8819   fprintf(fp,"%d  clpModel->setFactorizationFrequency(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    8820   fprintf(fp,"%d  clpModel->setFactorizationFrequency(save_factorizationFrequency);\n",iValue1==iValue2 ? 7 : 6);
    8821   dValue1 = this->dualBound();
    8822   dValue2 = other->dualBound();
    8823   fprintf(fp,"%d  double save_dualBound = clpModel->dualBound();\n",dValue1==dValue2 ? 2 : 1);
    8824   fprintf(fp,"%d  clpModel->setDualBound(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    8825   fprintf(fp,"%d  clpModel->setDualBound(save_dualBound);\n",dValue1==dValue2 ? 7 : 6);
    8826   dValue1 = this->infeasibilityCost();
    8827   dValue2 = other->infeasibilityCost();
    8828   fprintf(fp,"%d  double save_infeasibilityCost = clpModel->infeasibilityCost();\n",dValue1==dValue2 ? 2 : 1);
    8829   fprintf(fp,"%d  clpModel->setInfeasibilityCost(%g);\n",dValue1==dValue2 ? 4 : 3,dValue1);
    8830   fprintf(fp,"%d  clpModel->setInfeasibilityCost(save_infeasibilityCost);\n",dValue1==dValue2 ? 7 : 6);
    8831   iValue1 = this->perturbation();
    8832   iValue2 = other->perturbation();
    8833   fprintf(fp,"%d  int save_perturbation = clpModel->perturbation();\n",iValue1==iValue2 ? 2 : 1);
    8834   fprintf(fp,"%d  clpModel->setPerturbation(%d);\n",iValue1==iValue2 ? 4 : 3,iValue1);
    8835   fprintf(fp,"%d  clpModel->setPerturbation(save_perturbation);\n",iValue1==iValue2 ? 7 : 6);
    8836 }
    88378788    setFactorizationFrequency(CoinMin(maximum,frequency));
    88388789  }
  • trunk/Clp/src/ClpSimplex.hpp

    r798 r799  
    932932  inline int maximumBasic() const
    933933  { return maximumBasic_;};
    934   /// Create C++ lines to get to current state
    935   void generateCpp( FILE * fp,bool defaultFactor=false);
    936934  /** For advanced options
    937935      1 - Don't keep changing infeasibility weight
  • trunk/Clp/src/ClpSimplexDual.cpp

    r798 r799  
    16981698  double tolerance = dualTolerance_;
    16991699  // we can't really trust infeasibilities if there is dual error
    1700   double error = CoinMin(1.0e-2,largestDualError_);
     1700  double error = CoinMin(1.0e-3,largestDualError_);
    17011701  // allow tolerance at least slightly bigger than standard
    17021702  tolerance = tolerance +  error;
     
    36143614            cleanDuals=1;
    36153615            // make sure fake bounds are back
    3616             //computeObjectiveValue();
    36173616            changeBounds(true,NULL,changeCost);
    3618             //computeObjectiveValue();
    36193617            createRim(4);
    36203618            // make sure duals are current
    3621             computeDuals(givenDuals);
    3622             checkDualSolution();
     3619            //computeDuals(givenDuals);
     3620            //checkDualSolution();
    36233621            //if (numberDualInfeasibilities_)
    36243622              numberChanged_=1; // force something to happen
    3625             //else
    3626             //computeObjectiveValue();
     3623              //else
     3624              computeObjectiveValue();
    36273625          }
    36283626          if (lastCleaned<numberIterations_&&numberTimesOptimal_<4&&
     
    39783976           limit&&
    39793977           !numberAtFakeBound()&&!numberDualInfeasibilities_) {
    3980     //printf("lim %g obj %g %g\n",limit,objectiveValue_,objectiveValue());
    39813978    problemStatus_=1;
    39823979    secondaryStatus_ = 1; // and say was on cutoff
     
    41894186  double maximumFraction = 1.0e-5;
    41904187  double constantPerturbation = 100.0*dualTolerance_;
     4188  const int * lengths = matrix_->getVectorLengths();
    41914189  int maxLength=0;
    41924190  int minLength=numberRows_;
     
    42484246  for (iColumn=0;iColumn<numberColumns_;iColumn++) {
    42494247    if (columnLowerWork_[iColumn]<columnUpperWork_[iColumn]) {
    4250       int length = matrix_->getVectorLength(iColumn);
     4248      int length = lengths[iColumn];
    42514249      if (length>2) {
    42524250        maxLength = CoinMax(maxLength,length);
     
    44544452      }
    44554453      if (value) {
    4456         int length = matrix_->getVectorLength(iColumn);
     4454        int length = lengths[iColumn];
    44574455        if (length>3) {
    44584456          length = (int) ((double) length * factor);
  • trunk/Clp/src/ClpSimplexNonlinear.cpp

    r798 r799  
    774774  normUnflagged=1.0;
    775775  double dualTolerance2 = CoinMin(1.0e-8,1.0e-2*dualTolerance_);
    776   double dualTolerance3 = CoinMin(1.0e-2,1.0e3*dualTolerance_);
     776  double dualTolerance3 = CoinMin(1.0e-3,1.0e3*dualTolerance_);
    777777  if (!numberNonBasic) {
    778778    //if (nonLinearCost_->sumInfeasibilities()>1.0e-4)
     
    23322332  if (saveObj-currentObj<1.0e-5&&nTotalPasses>2000) {
    23332333    normUnflagged=0.0;
    2334     double dualTolerance3 = CoinMin(1.0e-2,1.0e3*dualTolerance_);
     2334    double dualTolerance3 = CoinMin(1.0e-3,1.0e3*dualTolerance_);
    23352335    for (int iSequence=0;iSequence<numberColumns_+numberRows_;iSequence++) {
    23362336      switch(getStatus(iSequence)) {
  • trunk/Clp/src/ClpSimplexPrimal.cpp

    r798 r799  
    638638{
    639639  int dummy; // for use in generalExpanded
    640   int saveFirstFree=firstFree_;
    641640  // number of pivots done
    642641  int numberPivots = factorization_->pivots();
     
    11561155  if (goToDual)
    11571156    problemStatus_=10; // try dual
    1158   // make sure first free monotonic
    1159   if (firstFree_>=0&&saveFirstFree>=0) {
    1160     firstFree_=saveFirstFree;
    1161     nextSuperBasic(1,NULL);
    1162   }
    11631157#if 0
    11641158  double thisObj = progress->lastObjective(0);
     
    23792373    if (largestDualError_>1.0e-5)
    23802374      checkValue=1.0e-1;
    2381     if (!ifValuesPass&&solveType_==1&&(saveDj*dualIn_<1.0e-20||
    2382         fabs(saveDj-dualIn_)>checkValue*(1.0+fabs(saveDj))||
    2383                         fabs(dualIn_)<dualTolerance_)) {
     2375    if (solveType_==1&&((saveDj*dualIn_<1.0e-20&&!ifValuesPass)||
     2376        fabs(saveDj-dualIn_)>checkValue*(1.0+fabs(saveDj)))) {
    23842377      char x = isColumn(sequenceIn_) ? 'C' :'R';
    23852378      handler_->message(CLP_PRIMAL_DJ,messages_)
     
    24012394        // take on more relaxed criterion
    24022395        if (saveDj*dualIn_<1.0e-20||
    2403             fabs(saveDj-dualIn_)>2.0e-1*(1.0+fabs(dualIn_))||
    2404             fabs(dualIn_)<dualTolerance_) {
     2396            fabs(saveDj-dualIn_)>2.0e-1*(1.0+fabs(dualIn_))) {
    24052397          // need to reject something
    24062398          char x = isColumn(sequenceIn_) ? 'C' :'R';
     
    24452437          int ii = index[i];
    24462438          dj_[ii] += element[ii];
    2447           reducedCost_[ii] = dj_[ii];
    24482439          element[ii]=0.0;
    24492440        }
  • trunk/Clp/src/ClpSolve.cpp

    r798 r799  
    2222#include "ClpNetworkMatrix.hpp"
    2323#endif
    24 #include "ClpLinearObjective.hpp"
    2524#include "ClpSolve.hpp"
    2625#include "ClpPackedMatrix.hpp"
     
    374373  double time2;
    375374  ClpMatrixBase * saveMatrix=NULL;
    376   ClpObjective * savedObjective=NULL;
    377   if (objective_->type()>=2&&optimizationDirection_==0) {
    378     // pretend linear
    379     savedObjective=objective_;
    380     // make up objective
    381     double * obj = new double[numberColumns_];
    382     for (int i=0;i<numberColumns_;i++) {
    383       double l = fabs(columnLower_[i]);
    384       double u = fabs(columnUpper_[i]);
    385       obj[i]=0.0;
    386       if (CoinMin(l,u)<1.0e20) {
    387         if (l<u)
    388           obj[i]=1.0+CoinDrand48()*1.0e-2;
    389         else
    390           obj[i]=-1.0-CoinDrand48()*1.0e-2;
    391       }
    392     }
    393     objective_= new ClpLinearObjective(obj,numberColumns_);
    394     delete [] obj;
    395   }
    396375  ClpSimplex * model2 = this;
    397376  bool interrupt = (options.getSpecialOption(2)==0);
     
    640619  int numberColumns = model2->numberColumns();
    641620  int numberRows = model2->numberRows();
    642   // If not all slack basis - switch off all except sprint
     621  // If not all slack basis - switch off all
    643622  int number=0;
    644623  int iRow;
     
    649628    doIdiot=0;
    650629    doCrash=0;
    651     //doSprint=0;
     630    doSprint=0;
    652631  }
    653632  if (options.getSpecialOption(3)==0) {
     
    12761255   
    12771256    // We will need arrays to choose variables.  These are too big but ..
    1278     float * weight = new float [numberRows+originalNumberColumns];
     1257    double * weight = new double [numberRows+originalNumberColumns];
    12791258    int * sort = new int [numberRows+originalNumberColumns];
    12801259    int numberSort=0;
    12811260    // We are going to add slacks to get feasible.
    12821261    // initial list will just be artificials
     1262    // first we will set all variables as close to zero as possible
    12831263    int iColumn;
    12841264    const double * columnLower = model2->columnLower();
    12851265    const double * columnUpper = model2->columnUpper();
    12861266    double * columnSolution = model2->primalColumnSolution();
    1287 
    1288     // See if we have costed slacks
    1289     int * negSlack = new int[numberRows];
    1290     int * posSlack = new int[numberRows];
    1291     int iRow;
    1292     for (iRow=0;iRow<numberRows;iRow++) {
    1293       negSlack[iRow]=-1;
    1294       posSlack[iRow]=-1;
    1295     }
    1296     const double * element = model2->matrix()->getElements();
    1297     const int * row = model2->matrix()->getIndices();
    1298     const CoinBigIndex * columnStart = model2->matrix()->getVectorStarts();
    1299     const int * columnLength = model2->matrix()->getVectorLengths();
     1267   
    13001268    for (iColumn=0;iColumn<originalNumberColumns;iColumn++) {
    1301       if (!columnSolution[iColumn]||fabs(columnSolution[iColumn])>1.0e20) {
    1302         double value =0.0;
    1303         if (columnLower[iColumn]>0.0)
    1304           value = columnLower[iColumn];
    1305         else if (columnUpper[iColumn]<0.0)
    1306           value = columnUpper[iColumn];
    1307         columnSolution[iColumn]=value;
    1308       }
    1309       if (columnLength[iColumn]==1) {
    1310         int jRow=row[columnStart[iColumn]];
    1311         if (!columnLower[iColumn]) {
    1312           if (element[columnStart[iColumn]]>0.0&&posSlack[jRow]<0)
    1313             posSlack[jRow]=iColumn;
    1314           else if (element[columnStart[iColumn]]<0.0&&negSlack[jRow]<0)
    1315             negSlack[jRow]=iColumn;
    1316         } else if (!columnUpper[iColumn]) {
    1317           if (element[columnStart[iColumn]]<0.0&&posSlack[jRow]<0)
    1318             posSlack[jRow]=iColumn;
    1319           else if (element[columnStart[iColumn]]>0.0&&negSlack[jRow]<0)
    1320             negSlack[jRow]=iColumn;
    1321         }
    1322       }
     1269      double value =0.0;
     1270      if (columnLower[iColumn]>0.0)
     1271        value = columnLower[iColumn];
     1272      else if (columnUpper[iColumn]<0.0)
     1273        value = columnUpper[iColumn];
     1274      columnSolution[iColumn]=value;
    13231275    }
    13241276    // now see what that does to row solution
     
    13261278    CoinZeroN (rowSolution,numberRows);
    13271279    model2->times(1.0,columnSolution,rowSolution);
    1328     // See if we can adjust using costed slacks
    1329     double penalty=infeasibilityCost_*optimizationDirection_;
    1330     const double * lower = model2->rowLower();
    1331     const double * upper = model2->rowUpper();
    1332     for (iRow=0;iRow<numberRows;iRow++) {
    1333       if (lower[iRow]>rowSolution[iRow]+1.0e-8) {
    1334         int jColumn = posSlack[iRow];
    1335         if (jColumn>=0) {
    1336           if (columnSolution[jColumn])
    1337             continue;
    1338           double difference = lower[iRow]-rowSolution[iRow];
    1339           double elementValue = element[columnStart[jColumn]];
    1340           if (elementValue>0.0) {
    1341             double movement = CoinMin(difference/elementValue,columnUpper[jColumn]);
    1342             columnSolution[jColumn] = movement;
    1343             rowSolution[iRow] += movement*elementValue;
    1344           } else {
    1345             double movement = CoinMax(difference/elementValue,columnLower[jColumn]);
    1346             columnSolution[jColumn] = movement;
    1347             rowSolution[iRow] += movement*elementValue;
    1348           }
    1349         }
    1350       } else if (upper[iRow]<rowSolution[iRow]-1.0e-8) {
    1351         int jColumn = negSlack[iRow];
    1352         if (jColumn>=0) {
    1353           if (columnSolution[jColumn])
    1354             continue;
    1355           double difference = upper[iRow]-rowSolution[iRow];
    1356           double elementValue = element[columnStart[jColumn]];
    1357           if (elementValue<0.0) {
    1358             double movement = CoinMin(difference/elementValue,columnUpper[jColumn]);
    1359             columnSolution[jColumn] = movement;
    1360             rowSolution[iRow] += movement*elementValue;
    1361           } else {
    1362             double movement = CoinMax(difference/elementValue,columnLower[jColumn]);
    1363             columnSolution[jColumn] = movement;
    1364             rowSolution[iRow] += movement*elementValue;
    1365           }
    1366         }
    1367       }
    1368     }
    1369     delete [] negSlack;
    1370     delete [] posSlack;
     1280   
    13711281    int * addStarts = new int [numberRows+1];
    13721282    int * addRow = new int[numberRows];
    13731283    double * addElement = new double[numberRows];
     1284    const double * lower = model2->rowLower();
     1285    const double * upper = model2->rowUpper();
    13741286    addStarts[0]=0;
    13751287    int numberArtificials=0;
    13761288    double * addCost = new double [numberRows];
     1289    const double penalty=1.0e8*optimizationDirection_;
     1290    int iRow;
    13771291    for (iRow=0;iRow<numberRows;iRow++) {
    1378       if (lower[iRow]>rowSolution[iRow]+1.0e-8) {
     1292      if (lower[iRow]>rowSolution[iRow]) {
    13791293        addRow[numberArtificials]=iRow;
    13801294        addElement[numberArtificials]=1.0;
     
    13821296        numberArtificials++;
    13831297        addStarts[numberArtificials]=numberArtificials;
    1384       } else if (upper[iRow]<rowSolution[iRow]-1.0e-8) {
     1298      } else if (upper[iRow]<rowSolution[iRow]) {
    13851299        addRow[numberArtificials]=iRow;
    13861300        addElement[numberArtificials]=-1.0;
     
    14441358    }
    14451359    int i;
     1360    // Set up initial list
     1361    if (numberArtificials) {
     1362      numberSort=numberArtificials;
     1363      for (i=0;i<numberSort;i++)
     1364        sort[i] = i+originalNumberColumns;
     1365    } else {
     1366      numberSort = CoinMin(numberRows_,numberColumns_);
     1367      for (i=0;i<numberSort;i++)
     1368        sort[i] = i;
     1369    }
     1370   
     1371    // redo as will have changed
     1372    columnLower = model2->columnLower();
     1373    columnUpper = model2->columnUpper();
     1374    int numberColumns = model2->numberColumns();
     1375    double * fullSolution = model2->primalColumnSolution();
     1376   
    14461377    // Just do this number of passes in Sprint
    14471378    if (doSprint>0)
    14481379      maxSprintPass=options.getExtraInfo(1);
    1449     // but if big use to get ratio
    1450     int ratio=3;
    1451     if (maxSprintPass>1000) {
    1452       ratio = CoinMax(maxSprintPass/1000,3);
    1453       maxSprintPass= maxSprintPass %1000;
    1454       printf("%d passes wanted with ratio of %d\n",maxSprintPass,ratio);
    1455     }
     1380    int iPass;
     1381    double lastObjective=1.0e31;
     1382    // It will be safe to allow dense
     1383    model2->setInitialDenseFactorization(true);
     1384   
    14561385    // Just take this number of columns in small problem
    1457     int smallNumberColumns = CoinMin(ratio*numberRows,numberColumns);
     1386    int smallNumberColumns = CoinMin(3*numberRows,numberColumns);
    14581387    smallNumberColumns = CoinMax(smallNumberColumns,3000);
    14591388    smallNumberColumns = CoinMin(smallNumberColumns,numberColumns);
     
    14611390    //smallNumberColumns = CoinMax(smallNumberColumns,3000);
    14621391    //smallNumberColumns = CoinMax(smallNumberColumns,numberRows+1000);
    1463     // redo as may have changed
    1464     columnLower = model2->columnLower();
    1465     columnUpper = model2->columnUpper();
    1466     columnSolution = model2->primalColumnSolution();
    1467     // Set up initial list
    1468     numberSort=0;
    1469     if (numberArtificials) {
    1470       numberSort=numberArtificials;
    1471       for (i=0;i<numberSort;i++)
    1472         sort[i] = i+originalNumberColumns;
    1473     }
    1474     // maybe a solution there already
    1475     for (iColumn=0;iColumn<originalNumberColumns;iColumn++) {
    1476       if (model2->getColumnStatus(iColumn)==basic)
    1477         sort[numberSort++]=iColumn;
    1478     }
    1479     for (iColumn=0;iColumn<originalNumberColumns;iColumn++) {
    1480       if (model2->getColumnStatus(iColumn)!=basic) {
    1481         if (columnSolution[iColumn]>columnLower[iColumn]&&
    1482             columnSolution[iColumn]<columnUpper[iColumn])
    1483           sort[numberSort++]=iColumn;
    1484       }
    1485     }
    1486     numberSort = CoinMin(numberSort,smallNumberColumns);
    1487    
    1488     int numberColumns = model2->numberColumns();
    1489     double * fullSolution = model2->primalColumnSolution();
    1490    
    1491    
    1492     int iPass;
    1493     double lastObjective=1.0e31;
    1494     // It will be safe to allow dense
    1495     model2->setInitialDenseFactorization(true);
    1496    
    14971392    // We will be using all rows
    14981393    int * whichRows = new int [numberRows];
     
    15081403      ClpSimplex small(model2,numberRows,whichRows,numberSort,sort);
    15091404      small.setPerturbation(model2->perturbation());
    1510       small.setInfeasibilityCost(model2->infeasibilityCost());
    1511       if (model2->factorizationFrequency()==200) {
    1512         // User did not touch preset
    1513         small.defaultFactorizationFrequency();
    1514       }
    15151405      // now see what variables left out do to row solution
    15161406      double * rowSolution = model2->primalRowSolution();
     
    15581448             numberRows,model2->primalRowSolution());
    15591449      // get reduced cost for large problem
    1560       double * djs = model2->dualColumnSolution();
    1561       CoinMemcpyN(model2->objective(),numberColumns,djs);
    1562       model2->transposeTimes(-1.0,small.dualRowSolution(),djs);
     1450      CoinMemcpyN(model2->objective(),numberColumns,weight);
     1451      model2->transposeTimes(-1.0,small.dualRowSolution(),weight);
    15631452      int numberNegative=0;
    15641453      double sumNegative = 0.0;
    15651454      // now massage weight so all basic in plus good djs
    1566       // first count and do basic
    1567       numberSort=0;
    15681455      for (iColumn=0;iColumn<numberColumns;iColumn++) {
    1569         double dj = djs[iColumn]*optimizationDirection_;
     1456        double dj = weight[iColumn]*optimizationDirection_;
    15701457        double value = fullSolution[iColumn];
    1571         if (model2->getColumnStatus(iColumn)==ClpSimplex::basic) {
    1572           sort[numberSort++] = iColumn;
    1573         } else if (dj<-dualTolerance_&&value<columnUpper[iColumn]) {
     1458        if (model2->getColumnStatus(iColumn)==ClpSimplex::basic)
     1459          dj = -1.0e50;
     1460        else if (dj<0.0&&value<columnUpper[iColumn])
     1461          dj = dj;
     1462        else if (dj>0.0&&value>columnLower[iColumn])
     1463          dj = -dj;
     1464        else if (columnUpper[iColumn]>columnLower[iColumn])
     1465          dj = fabs(dj);
     1466        else
     1467          dj = 1.0e50;
     1468        weight[iColumn] = dj;
     1469        if (dj<-dualTolerance_&&dj>-1.0e50) {
    15741470          numberNegative++;
    15751471          sumNegative -= dj;
    1576         } else if (dj>dualTolerance_&&value>columnLower[iColumn]) {
    1577           numberNegative++;
    1578           sumNegative += dj;
    15791472        }
     1473        sort[iColumn] = iColumn;
    15801474      }
    15811475      handler_->message(CLP_SPRINT,messages_)
     
    15841478        <<CoinMessageEol;
    15851479      if ((small.objectiveValue()*optimizationDirection_>lastObjective-1.0e-7&&iPass>5)||
    1586           (!small.numberIterations()&&iPass)||
     1480          !small.numberIterations()||
    15871481          iPass==maxSprintPass-1||small.status()==3) {
    15881482       
     
    15901484      } else {
    15911485        lastObjective = small.objectiveValue()*optimizationDirection_;
    1592         double tolerance;
    1593         double averageNegDj = sumNegative/((double) (numberNegative+1));
    1594         if (numberNegative+numberSort>smallNumberColumns)
    1595           tolerance = -dualTolerance_;
    1596         else
    1597           tolerance = 10.0*averageNegDj;
    1598         int saveN = numberSort;
    1599         for (iColumn=0;iColumn<numberColumns;iColumn++) {
    1600           double dj = djs[iColumn]*optimizationDirection_;
    1601           double value = fullSolution[iColumn];
    1602           if (model2->getColumnStatus(iColumn)!=ClpSimplex::basic) {
    1603             if (dj<-dualTolerance_&&value<columnUpper[iColumn])
    1604               dj = dj;
    1605             else if (dj>dualTolerance_&&value>columnLower[iColumn])
    1606               dj = -dj;
    1607             else if (columnUpper[iColumn]>columnLower[iColumn])
    1608               dj = fabs(dj);
    1609             else
    1610               dj = 1.0e50;
    1611             if (dj<tolerance) {
    1612               weight[numberSort] = dj;
    1613               sort[numberSort++] = iColumn;
    1614             }
    1615           }
    1616         }
    16171486        // sort
    1618         CoinSort_2(weight+saveN,weight+numberSort,sort+saveN);
    1619         numberSort = CoinMin(smallNumberColumns,numberSort);
     1487        CoinSort_2(weight,weight+numberColumns,sort);
     1488        numberSort = smallNumberColumns;
    16201489      }
    16211490    }
     
    16561525#ifndef SLIM_CLP
    16571526    //printf("***** experimental pretty crude barrier\n");
    1658     //#define SAVEIT 2
     1527    //#define SAVEIT 1
    16591528#ifndef SAVEIT
    16601529#define BORROW
     
    19091778        // solve
    19101779        model2->setPerturbation(100);
    1911         if (model2->factorizationFrequency()==200) {
    1912           // User did not touch preset
    1913           model2->defaultFactorizationFrequency();
    1914         }
    19151780#if 1
    19161781        // throw some into basis
     
    19571822          delete [] dsort;
    19581823        }
    1959         // model2->allSlackBasis();
    19601824        if (gap<1.0e-3*((double) (numberRows+numberColumns))) {
    19611825          if (saveUpper) {
     
    21712035  perturbation_=savePerturbation;
    21722036  scalingFlag_=saveScaling;
    2173   // If faking objective - put back correct one
    2174   if (savedObjective) {
    2175     delete objective_;
    2176     objective_=savedObjective;
    2177   }
    21782037  return finalStatus;
    21792038}
     
    22232082 
    22242083}
    2225 // Constructor when you really know what you are doing
    2226 ClpSolve::ClpSolve ( SolveType method, PresolveType presolveType,
    2227              int numberPasses, int options[6],
    2228              int extraInfo[6], int independentOptions[3])
    2229 {
    2230   method_ = method;
    2231   presolveType_=presolveType;
    2232   numberPasses_=numberPasses;
    2233   int i;
    2234   for (i=0;i<6;i++)
    2235     options_[i]=options[i];
    2236   for (i=0;i<6;i++)
    2237     extraInfo_[i]=extraInfo[i];
    2238   for (i=0;i<3;i++)
    2239     independentOptions_[i]=independentOptions[i];
    2240 }
    22412084
    22422085// Copy constructor.
     
    23332176  independentOptions_[0]= trueFalse ? 1 : 0;
    23342177}
    2335 #include <string>
    2336 // Generates code for above constructor
    2337 void
    2338 ClpSolve::generateCpp(FILE * fp)
    2339 {
    2340   std::string solveType[] = {
    2341     "ClpSolve::useDual",
    2342     "ClpSolve::usePrimal",
    2343     "ClpSolve::usePrimalorSprint",
    2344     "ClpSolve::useBarrier",
    2345     "ClpSolve::useBarrierNoCross",
    2346     "ClpSolve::automatic",
    2347     "ClpSolve::notImplemented"
    2348   };
    2349   std::string presolveType[] =  {
    2350     "ClpSolve::presolveOn",
    2351     "ClpSolve::presolveOff",
    2352     "ClpSolve::presolveNumber",
    2353     "ClpSolve::presolveNumberCost"
    2354   };
    2355   fprintf(fp,"3  ClpSolve::SolveType method = %s;\n",solveType[method_].c_str());
    2356   fprintf(fp,"3  ClpSolve::PresolveType presolveType = %s;\n",
    2357     presolveType[presolveType_].c_str());
    2358   fprintf(fp,"3  int numberPasses = %d;\n",numberPasses_);
    2359   fprintf(fp,"3  int options[] = {%d,%d,%d,%d,%d,%d};\n",
    2360     options_[0],options_[1],options_[2],
    2361     options_[3],options_[4],options_[5]);
    2362   fprintf(fp,"3  int extraInfo[] = {%d,%d,%d,%d,%d,%d};\n",
    2363     extraInfo_[0],extraInfo_[1],extraInfo_[2],
    2364     extraInfo_[3],extraInfo_[4],extraInfo_[5]);
    2365   fprintf(fp,"3  int independentOptions[] = {%d,%d,%d};\n",
    2366     independentOptions_[0],independentOptions_[1],independentOptions_[2]);
    2367   fprintf(fp,"3  ClpSolve clpSolve(method,presolveType,numberPasses,\n");
    2368   fprintf(fp,"3                    options,extraInfo,independentOptions);\n");
    2369 }
  • trunk/Clp/src/ClpSolve.hpp

    r798 r799  
    4141  //@{
    4242  /// Default constructor
    43   ClpSolve (  );
    44   /// Constructor when you really know what you are doing
    45   ClpSolve ( SolveType method, PresolveType presolveType,
    46              int numberPasses, int options[6],
    47              int extraInfo[6], int independentOptions[3]);
    48   /// Generates code for above constructor
    49   void generateCpp(FILE * fp);
     43    ClpSolve (  );
     44
    5045  /// Copy constructor.
    5146  ClpSolve(const ClpSolve &);
  • trunk/Clp/src/unitTest.cpp

    r798 r799  
    899899             valueDecrease[i],sequenceDecrease[i]);
    900900    assert (fabs(valueDecrease[3]-0.642857)<1.0e-4);
    901 #if 0
    902     // out until I find optimization bug
    903901    assert (fabs(valueDecrease[8]-2.95113)<1.0e-4);
    904902#if 0
     
    909907    double endingTheta=1.0;
    910908    model2->scaling(0);
    911 #endif
    912909    model2->setLogLevel(63);
    913910    model2->parametrics(0.0,endingTheta,0.1,
Note: See TracChangeset for help on using the changeset viewer.