Changeset 1321


Ignore:
Timestamp:
Jan 14, 2009 4:14:09 PM (11 years ago)
Author:
forrest
Message:

out compiler warnings and stability improvements

Location:
trunk/Clp/src
Files:
43 edited

Legend:

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

    r1320 r1321  
    3333#else
    3434static char coin_prompt[]="Clp:";
     35#endif
     36#if WSSMP_BARRIER>=2
     37#ifndef CBC_THREAD
     38#define CBC_THREAD
     39#endif
    3540#endif
    3641static bool doPrinting=true;
     
    335340    std::cout<<" "<<thisOne;
    336341  }
    337   assert (currentKeyWord_>=0&&currentKeyWord_<(int)definedKeyWords_.size());
     342  assert (currentKeyWord_>=0&&currentKeyWord_<static_cast<int>(definedKeyWords_.size()));
    338343  std::string current = definedKeyWords_[currentKeyWord_];
    339344  std::string::size_type  shriekPos = current.find('!');
     
    576581    case SPECIALOPTIONS:
    577582      model->setSpecialOptions(value);
    578 #ifdef COIN_HAS_CBC
     583#ifndef COIN_HAS_CBC
     584#ifdef CBC_THREAD
    579585    case THREADS:
    580586      model->setNumberThreads(value);
    581587      break;
     588#endif
    582589#endif
    583590    default:
     
    611618    break;
    612619#ifndef COIN_HAS_CBC
     620#ifdef CBC_THREAD
    613621  case THREADS:
    614622    value = model->numberThreads();
     623#endif
    615624#endif
    616625  default:
     
    13501359  parameters[numberParameters-1].append("ifmove");
    13511360  parameters[numberParameters-1].append("forceOn");
     1361  parameters[numberParameters-1].append("onglobal");
     1362  parameters[numberParameters-1].append("rootglobal");
    13521363  parameters[numberParameters-1].setLonghelp
    13531364    (
     
    13591370                  "off",COMBINE);
    13601371  parameters[numberParameters-1].append("on");
    1361   parameters[numberParameters-1].append("do");
     1372  parameters[numberParameters-1].append("both");
     1373  parameters[numberParameters-1].append("before");
    13621374  parameters[numberParameters-1].setLonghelp
    13631375    (
     
    13651377using variables which have appeared in one or more solutions. \
    13661378It obviously only tries after two or more solutions. \
    1367 The Do option switches on before preprocessing."
     1379See Rounding for meaning of on,both,before"
    13681380     );
    13691381  parameters[numberParameters++]=
     
    15201532      CbcOrClpParam("Dins","Whether to try Distance Induced Neighborhood Search",
    15211533                    "off",DINS);
    1522     parameters[numberParameters-1].append("on");
    1523     parameters[numberParameters-1].append("often");
    1524   parameters[numberParameters-1].setLonghelp
    1525     (
    1526      "This switches on Distance induced neighborhood Search."
     1534  parameters[numberParameters-1].append("on");
     1535  parameters[numberParameters-1].append("both");
     1536  parameters[numberParameters-1].append("before");
     1537  parameters[numberParameters-1].append("often");
     1538  parameters[numberParameters-1].setLonghelp
     1539    (
     1540     "This switches on Distance induced neighborhood Search. \
     1541See Rounding for meaning of on,both,before"
    15271542     );
    15281543#endif
     
    15921607                    "off",DIVINGS);
    15931608  parameters[numberParameters-1].append("on");
    1594   parameters[numberParameters-1].append("do");
     1609  parameters[numberParameters-1].append("both");
     1610  parameters[numberParameters-1].append("before");
    15951611  parameters[numberParameters-1].setLonghelp
    15961612    (
    15971613     "This switches on a random diving heuristic at various times. \
    15981614C - Coefficient, F - Fractional, G - Guided, L - LineSearch, P - PseudoCost, V - VectorLength. \
    1599 You may prefer to use individual on/off"
     1615You may prefer to use individual on/off \
     1616See Rounding for meaning of on,both,before"
    16001617     );
    16011618  parameters[numberParameters++]=
     
    16031620                    "off",DIVINGC);
    16041621  parameters[numberParameters-1].append("on");
    1605   parameters[numberParameters-1].append("do");
     1622  parameters[numberParameters-1].append("both");
     1623  parameters[numberParameters-1].append("before");
    16061624  parameters[numberParameters++]=
    16071625      CbcOrClpParam("DivingF!ractional","Whether to try DiveFractional",
    16081626                    "off",DIVINGF);
    16091627  parameters[numberParameters-1].append("on");
    1610   parameters[numberParameters-1].append("do");
     1628  parameters[numberParameters-1].append("both");
     1629  parameters[numberParameters-1].append("before");
    16111630  parameters[numberParameters++]=
    16121631      CbcOrClpParam("DivingG!uided","Whether to try DiveGuided",
    16131632                    "off",DIVINGG);
    16141633  parameters[numberParameters-1].append("on");
    1615   parameters[numberParameters-1].append("do");
     1634  parameters[numberParameters-1].append("both");
     1635  parameters[numberParameters-1].append("before");
    16161636  parameters[numberParameters++]=
    16171637      CbcOrClpParam("DivingL!ineSearch","Whether to try DiveLineSearch",
    16181638                    "off",DIVINGL);
    16191639  parameters[numberParameters-1].append("on");
    1620   parameters[numberParameters-1].append("do");
     1640  parameters[numberParameters-1].append("both");
     1641  parameters[numberParameters-1].append("before");
    16211642  parameters[numberParameters++]=
    16221643      CbcOrClpParam("DivingP!seudoCost","Whether to try DivePseudoCost",
    16231644                    "off",DIVINGP);
    16241645  parameters[numberParameters-1].append("on");
    1625   parameters[numberParameters-1].append("do");
     1646  parameters[numberParameters-1].append("both");
     1647  parameters[numberParameters-1].append("before");
    16261648  parameters[numberParameters++]=
    16271649      CbcOrClpParam("DivingV!ectorLength","Whether to try DiveVectorLength",
    16281650                    "off",DIVINGV);
    16291651  parameters[numberParameters-1].append("on");
    1630   parameters[numberParameters-1].append("do");
     1652  parameters[numberParameters-1].append("both");
     1653  parameters[numberParameters-1].append("before");
    16311654  parameters[numberParameters++]=
    16321655    CbcOrClpParam("doH!euristic","Do heuristics before any preprocessing",
     
    17801803                  "off",FPUMP);
    17811804  parameters[numberParameters-1].append("on");
    1782   parameters[numberParameters-1].append("do");
    1783   parameters[numberParameters-1].setLonghelp
    1784     (
    1785      "This switches on feasibility pump heuristic at root. This is due to Fischetti and Lodi and Glover \
     1805  parameters[numberParameters-1].append("both");
     1806  parameters[numberParameters-1].append("before");
     1807  parameters[numberParameters-1].setLonghelp
     1808    (
     1809     "This switches on feasibility pump heuristic at root. This is due to Fischetti, Lodi and Glover \
    17861810and uses a sequence of Lps to try and get an integer feasible solution. \
    17871811Some fine tuning is available by passFeasibilityPump and also pumpTune. \
    1788 Do option does heuristic before preprocessing"
     1812See Rounding for meaning of on,both,before"
    17891813     );
    17901814  parameters[numberParameters++]=
     
    18041828    parameters[numberParameters-1].append("ifmove");
    18051829    parameters[numberParameters-1].append("forceOn");
     1830  parameters[numberParameters-1].append("onglobal");
     1831  parameters[numberParameters-1].append("rootglobal");
    18061832    parameters[numberParameters-1].setLonghelp
    18071833    (
     
    18381864  parameters[numberParameters-1].append("ifmove");
    18391865  parameters[numberParameters-1].append("forceOn");
     1866  parameters[numberParameters-1].append("onglobal");
     1867  parameters[numberParameters-1].append("rootglobal");
    18401868  parameters[numberParameters-1].append("forceLongOn");
    18411869  parameters[numberParameters-1].append("long");
     
    18521880                  "off",GREEDY);
    18531881  parameters[numberParameters-1].append("on");
    1854   parameters[numberParameters-1].append("do");
     1882  parameters[numberParameters-1].append("both");
     1883  parameters[numberParameters-1].append("before");
    18551884  //parameters[numberParameters-1].append("root");
    18561885  parameters[numberParameters-1].setLonghelp
     
    18581887     "Switches on a greedy heuristic which will try and obtain a solution.  It may just fix a \
    18591888percentage of variables and then try a small branch and cut run. \
    1860 The Do option switches on before preprocessing."
     1889See Rounding for meaning of on,both,before"
    18611890     );
    18621891  parameters[numberParameters++]=
     
    18801909     );
    18811910#ifdef COIN_HAS_CBC
     1911  parameters[numberParameters++]=
     1912    CbcOrClpParam("hOp!tions","Heuristic options",
     1913                  -9999999,9999999,HOPTIONS);
     1914  parameters[numberParameters-1].setLonghelp
     1915    (
     1916     "0 doh 1 nodes -1 2 doh+hot 3 nodes-1+hot 4 ord heur+hot. \
     1917More usefully 100 says stop heuristic immediately allowable gap reached."
     1918     );
     1919  parameters[numberParameters-1].setIntValue(0);
    18821920  parameters[numberParameters++]=
    18831921    CbcOrClpParam("hot!StartMaxIts","Maximum iterations on hot start",
     
    19662004  parameters[numberParameters-1].append("ifmove");
    19672005  parameters[numberParameters-1].append("forceOn");
     2006  parameters[numberParameters-1].append("onglobal");
     2007  parameters[numberParameters-1].append("rootglobal");
    19682008  parameters[numberParameters-1].setLonghelp
    19692009    (
     
    20802120  parameters[numberParameters-1].append("ifmove");
    20812121  parameters[numberParameters-1].append("forceOn");
     2122  parameters[numberParameters-1].append("onglobal");
     2123  parameters[numberParameters-1].append("rootglobal");
    20822124  parameters[numberParameters-1].setLonghelp
    20832125    (
     
    21132155                    "off",NAIVE);
    21142156  parameters[numberParameters-1].append("on");
    2115   parameters[numberParameters-1].append("do");
    2116   parameters[numberParameters-1].setLonghelp
    2117     (
    2118      "Really silly stuff e.g. fix all integers with costs to zero!."
    2119      );
     2157  parameters[numberParameters-1].append("both");
     2158  parameters[numberParameters-1].append("before");
     2159  parameters[numberParameters-1].setLonghelp
     2160    (
     2161     "Really silly stuff e.g. fix all integers with costs to zero!. \
     2162Do options does heuristic before preprocessing"     );
    21202163#endif
    21212164#ifdef COIN_HAS_CLP
     
    22942337                    "off",PIVOTANDFIX);
    22952338  parameters[numberParameters-1].append("on");
    2296   parameters[numberParameters-1].append("do");
    2297   parameters[numberParameters-1].setLonghelp
    2298     (
    2299      "stuff needed."
    2300      );
     2339  parameters[numberParameters-1].append("both");
     2340  parameters[numberParameters-1].append("before");
     2341  parameters[numberParameters-1].setLonghelp
     2342    (
     2343     "stuff needed. \
     2344Do options does heuristic before preprocessing"     );
    23012345#endif
    23022346#ifdef COIN_HAS_CLP
     
    24702514  parameters[numberParameters-1].append("ifmove");
    24712515  parameters[numberParameters-1].append("forceOn");
     2516  parameters[numberParameters-1].append("onglobal");
     2517  parameters[numberParameters-1].append("rootglobal");
    24722518  parameters[numberParameters-1].append("forceOnBut");
    24732519  parameters[numberParameters-1].append("forceOnStrong");
     
    25062552                    "off",RANDROUND);
    25072553  parameters[numberParameters-1].append("on");
    2508   parameters[numberParameters-1].append("do");
    2509   parameters[numberParameters-1].setLonghelp
    2510     (
    2511      "stuff needed."
    2512      );
     2554  parameters[numberParameters-1].append("both");
     2555  parameters[numberParameters-1].append("before");
     2556  parameters[numberParameters-1].setLonghelp
     2557    (
     2558     "stuff needed. \
     2559Do options does heuristic before preprocessing"     );
    25132560  parameters[numberParameters++]=
    25142561    CbcOrClpParam("ratio!Gap","Stop when gap between best possible and \
     
    25222569way of using absolute value rather than fraction."
    25232570     );
     2571  parameters[numberParameters++]=
     2572    CbcOrClpParam("readS!tored","Import stored cuts from file",
     2573                  STOREDFILE,3,false);
    25242574#endif
    25252575#ifdef COIN_HAS_CLP
     
    25942644                    "off",RENS);
    25952645    parameters[numberParameters-1].append("on");
     2646    parameters[numberParameters-1].append("both");
     2647    parameters[numberParameters-1].append("before");
    25962648    parameters[numberParameters-1].append("200");
    25972649    parameters[numberParameters-1].append("1000");
     
    26012653     "This switches on Relaxation enforced neighborhood Search. \
    26022654on just does feasibility pump \
    2603 200 or 1000 does that many nodes."
    2604      );
     2655200 or 1000 does that many nodes. \
     2656Do options does heuristic before preprocessing"     );
    26052657  parameters[numberParameters++]=
    26062658      CbcOrClpParam("Rins","Whether to try Relaxed Induced Neighborhood Search",
    26072659                    "off",RINS);
    26082660    parameters[numberParameters-1].append("on");
     2661    parameters[numberParameters-1].append("both");
     2662    parameters[numberParameters-1].append("before");
    26092663    parameters[numberParameters-1].append("often");
    26102664  parameters[numberParameters-1].setLonghelp
    26112665    (
    2612      "This switches on Relaxed induced neighborhood Search."
    2613      );
     2666     "This switches on Relaxed induced neighborhood Search. \
     2667Do options does heuristic before preprocessing"     );
    26142668  parameters[numberParameters++]=
    26152669    CbcOrClpParam("round!ingHeuristic","Whether to use Rounding heuristic",
    26162670                  "off",ROUNDING);
    26172671  parameters[numberParameters-1].append("on");
    2618   parameters[numberParameters-1].append("do");
     2672  parameters[numberParameters-1].append("both");
     2673  parameters[numberParameters-1].append("before");
    26192674  parameters[numberParameters-1].setLonghelp
    26202675    (
    26212676     "This switches on a simple (but effective) rounding heuristic at each node of tree.  \
    2622 The Do option switches on before preprocessing."
    2623      );
     2677On means do in solve i.e. after preprocessing, \
     2678Before means do if doHeuristics used, off otherwise, \
     2679and both means do if doHeuristics and in solve."
     2680     );
     2681
    26242682#endif
    26252683  parameters[numberParameters++]=
     
    28422900  parameters[numberParameters++]=
    28432901    CbcOrClpParam("thread!s","Number of threads to try and use",
    2844                   -100,10000,THREADS,false);
     2902                  -100,100000,THREADS,false);
    28452903  parameters[numberParameters-1].setLonghelp
    28462904    (
    28472905     "To use multiple threads, set threads to number wanted.  It may be better \
    28482906to use one or two more than number of cpus available.  If 100+n then n threads and \
    2849 threads used in sub-trees, if 200+n use threads for root cuts, 300+n - both."
     2907search is repeatable (maybe be somewhat slower), \
     2908if 200+n use threads for root cuts, 400+n threads used in sub-trees."
    28502909     );
    28512910#endif
     
    28962955  parameters[numberParameters-1].append("ifmove");
    28972956  parameters[numberParameters-1].append("forceOn");
     2957  parameters[numberParameters-1].append("onglobal");
     2958  parameters[numberParameters-1].append("rootglobal");
    28982959  parameters[numberParameters-1].append("forceLongOn");
    28992960  parameters[numberParameters-1].setLonghelp
     
    29533014     );
    29543015  parameters[numberParameters-1].setIntValue(-1);
     3016  parameters[numberParameters++]=
     3017    CbcOrClpParam("zero!HalfCuts","Whether to use zero half cuts",
     3018                  "off",ZEROHALFCUTS);
     3019  parameters[numberParameters-1].append("on");
     3020  parameters[numberParameters-1].append("root");
     3021  parameters[numberParameters-1].append("ifmove");
     3022  parameters[numberParameters-1].append("forceOn");
     3023  parameters[numberParameters-1].append("onglobal");
     3024  parameters[numberParameters-1].append("rootglobal");
     3025  parameters[numberParameters-1].setLonghelp
     3026    (
     3027     "This switches on knapsack cuts (either at root or in entire tree) \
     3028See branchAndCut for information on options."
     3029     );
    29553030#endif
    29563031  assert(numberParameters<CBCMAXPARAMETERS);
  • trunk/Clp/src/CbcOrClpParam.hpp

    r1304 r1321  
    6767    FPUMPTUNE,TESTOSI,EXTRA1,EXTRA2,EXTRA3,EXTRA4,CUTPASSINTREE,
    6868    THREADS,CUTPASS,VUBTRY,DENSE,EXPERIMENT,DIVEOPT,STRATEGY,SMALLFACT,
     69    HOPTIONS,
    6970#ifdef COIN_HAS_CBC
    7071    LOGLEVEL ,
     
    8081    TWOMIRCUTS,PREPROCESS,FPUMP,GREEDY,COMBINE,LOCALTREE,SOS,
    8182    LANDPCUTS,RINS,RESIDCUTS,RENS,DIVINGS,DIVINGC,DIVINGF,DIVINGG,DIVINGL,
    82     DIVINGP,DIVINGV,DINS,PIVOTANDFIX,RANDROUND,NAIVE,
     83    DIVINGP,DIVINGV,DINS,PIVOTANDFIX,RANDROUND,NAIVE,ZEROHALFCUTS,
    8384   
    8485    DIRECTORY=301,DIRSAMPLE,DIRNETLIB,DIRMIPLIB,IMPORT,EXPORT,RESTORE,SAVE,DUALSIMPLEX,PRIMALSIMPLEX,EITHERSIMPLEX,
     
    8687    TIGHTEN,FAKEBOUND,HELP,PLUSMINUS,NETWORK,ALLSLACK,REVERSE,BARRIER,NETLIB_BARRIER,NETLIB_TUNE,
    8788    REALLY_SCALE,BASISIN,BASISOUT,SOLVECONTINUOUS,CLEARCUTS,VERSION,STATISTICS,DEBUG,DUMMY,PRINTMASK,
    88     OUTDUPROWS,USERCLP,MODELIN,CSVSTATISTICS,
     89    OUTDUPROWS,USERCLP,MODELIN,CSVSTATISTICS,STOREDFILE,
    8990
    9091    BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,USERCBC,DOHEURISTIC,
  • trunk/Clp/src/ClpCholeskyBase.cpp

    r1264 r1321  
    12271227  for (iRow=0;iRow<numberRows_;iRow++) {
    12281228    int length = choleskyStart_[iRow+1]-choleskyStart_[iRow];
    1229     flops += ((double) length) * (length + 2.0);
     1229    flops += static_cast<double> (length) * (length + 2.0);
    12301230  }
    12311231  if (model_->messageHandler()->logLevel()>0)
     
    12771277ClpCholeskyBase::symbolic1(const CoinBigIndex * Astart, const int * Arow)
    12781278{
    1279   int * marked = (int *) workInteger_;
     1279  int * marked = reinterpret_cast<int *> (workInteger_);
    12801280  int iRow;
    12811281  // may not need to do this here but makes debugging easier
     
    13111311{
    13121312  int * mergeLink = clique_;
    1313   int * marker = (int *) workInteger_;
     1313  int * marker = reinterpret_cast<int *> (workInteger_);
    13141314  int iRow;
    13151315  for (iRow=0;iRow<numberRows_;iRow++) {
     
    14291429    double n=numberleft;
    14301430    double threshold = n*(n-1.0)*0.5*goDense_;
    1431     if ((double) left >= threshold)
     1431    if ( left >= threshold)
    14321432      break;
    14331433    numberleft--;
     
    25532553  }
    25542554#endif
    2555   longWork * work = (longWork *) workDouble_;
     2555  longWork * work = reinterpret_cast<longWork *> (workDouble_);
    25562556  int i;
    25572557  CoinBigIndex j;
  • trunk/Clp/src/ClpCholeskyDense.cpp

    r1264 r1321  
    7373#define BLOCK 16
    7474#define BLOCKSHIFT 4
     75// Block unroll if power of 2 and at least 8
     76#define BLOCKUNROLL
    7577
    7678#define BLOCKSQ ( BLOCK*BLOCK )
     
    682684    aother=aUnder+number_entries(i);
    683685    recRec(aTri+number_entries(nb),nThis-nThis2,nLeft,nThis2,aUnder,aother,
    684           diagonal,work,iBlock,kBlock,jBlock,numberBlocks);
     686          work,kBlock,jBlock,numberBlocks);
    685687    triRec(aTri+number_entries(nintri+nbelow),nThis-nThis2,aother,diagonal+nThis2,
    686688           work+nThis2,nLeft,
     
    719721    aother=aTri+number_entries(nb);
    720722    recRec(aUnder,nTri2,nTri-nTri2,nDo,aUnder+number_entries(nb),aother,
    721            diagonal,work,iBlock+nb,iBlock,jBlock,numberBlocks);
     723           work,iBlock,jBlock,numberBlocks);
    722724    recTri(aUnder+number_entries(nb),nTri-nTri2,nDo,iBlock+nb,jBlock,
    723725         aTri+number_entries(i),diagonal,work,numberBlocks);
    724726  }
    725727}
    726 #ifdef CHOL_USING_BLAS
    727 // using simple blas interface
    728 extern "C"
    729 {
    730   /** BLAS Fortran subroutine DGEMM. */
    731   void F77_FUNC(dgemm,DGEMM)(char* transa, char* transb,
    732                              ipfint *m, ipfint *n, ipfint *k,
    733                              const double *alpha, const double *a, ipfint *lda,
    734                              const double *b, ipfint *ldb, const double *beta,
    735                              double *c, ipfint *ldc,
    736                              int transa_len, int transb_len);
    737 }
    738 #endif
    739728/* Non leaf recursive rectangle rectangle update,
    740729   nUnder is number of rows in iBlock,
     
    743732void
    744733ClpCholeskyDense::recRec(longDouble * above, int nUnder, int nUnderK,
    745                          int nDo, longDouble * aUnder, longDouble *aOther, longDouble * diagonal, longDouble * work,
    746             int kBlock,int iBlock, int jBlock,
    747             int numberBlocks)
    748 {
    749 #ifdef CHOL_USING_BLAS
    750     recRecLeaf(above , aUnder ,  aOther, diagonal,work, nUnderK);
    751 void
    752 ClpCholeskyDense::recRecLeaf(longDouble * above,
    753                              longDouble * aUnder, longDouble *aOther, longDouble * diagonal, longDouble * work,
    754                              int nUnder)
    755   aa = aOther-BLOCK;
    756   for (j = 0; j < BLOCK; j ++) {
    757     aa+=BLOCK;
    758     for (i=0;i< nUnderK;i++) {
    759       longDouble t00=aa[i+0*BLOCK];
    760       for (k=0;k<BLOCK;k++) {
    761         longDouble a00=aUnder[i+k*BLOCK]*work[k];
    762         t00 -= a00 * above[j + k * BLOCK];
    763       }
    764       aa[i]=t00;
    765     }
    766   return;
    767 #endif
     734                         int nDo, longDouble * aUnder, longDouble *aOther,
     735                         longDouble * work,
     736                         int iBlock, int jBlock,
     737                         int numberBlocks)
     738{
    768739  if (nDo<=BLOCK&&nUnder<=BLOCK&&nUnderK<=BLOCK) {
    769740    assert (nDo==BLOCK&&nUnder==BLOCK);
    770     recRecLeaf(above , aUnder ,  aOther, diagonal,work, nUnderK);
     741    recRecLeaf(above , aUnder ,  aOther, work, nUnderK);
    771742  } else if (nDo<=nUnderK&&nUnder<=nUnderK) {
    772743    int nb=number_blocks((nUnderK+1)>>1);
    773744    int nUnder2=number_rows(nb);
    774     recRec(above,nUnder,nUnder2,nDo,aUnder,aOther,diagonal,work,
    775                kBlock,iBlock,jBlock,numberBlocks);
     745    recRec(above,nUnder,nUnder2,nDo,aUnder,aOther,work,
     746               iBlock,jBlock,numberBlocks);
    776747    recRec(above,nUnder,nUnderK-nUnder2,nDo,aUnder+number_entries(nb),
    777         aOther+number_entries(nb),diagonal,work,kBlock+nb,iBlock,jBlock,numberBlocks);
     748        aOther+number_entries(nb),work,iBlock,jBlock,numberBlocks);
    778749  } else if (nUnderK<=nDo&&nUnder<=nDo) {
    779750    int nb=number_blocks((nDo+1)>>1);
    780751    int nDo2=number_rows(nb);
    781752    int i;
    782     recRec(above,nUnder,nUnderK,nDo2,aUnder,aOther,diagonal,work,
    783          kBlock,iBlock,jBlock,numberBlocks);
     753    recRec(above,nUnder,nUnderK,nDo2,aUnder,aOther,work,
     754         iBlock,jBlock,numberBlocks);
    784755    i=((numberBlocks-jBlock)*(numberBlocks-jBlock-1)-
    785756      (numberBlocks-jBlock-nb)*(numberBlocks-jBlock-nb-1))>>1;
    786757    recRec(above+number_entries(i),nUnder,nUnderK,nDo-nDo2,
    787758           aUnder+number_entries(i),
    788            aOther,diagonal+nDo2,work+nDo2,
    789            kBlock-nb,iBlock-nb,jBlock,numberBlocks-nb);
     759           aOther,work+nDo2,
     760           iBlock-nb,jBlock,numberBlocks-nb);
    790761  } else {
    791762    int nb=number_blocks((nUnder+1)>>1);
    792763    int nUnder2=number_rows(nb);
    793764    int i;
    794     recRec(above,nUnder2,nUnderK,nDo,aUnder,aOther,diagonal,work,
    795                kBlock,iBlock,jBlock,numberBlocks);
     765    recRec(above,nUnder2,nUnderK,nDo,aUnder,aOther,work,
     766               iBlock,jBlock,numberBlocks);
    796767    i=((numberBlocks-iBlock)*(numberBlocks-iBlock-1)-
    797768      (numberBlocks-iBlock-nb)*(numberBlocks-iBlock-nb-1))>>1;
    798769    recRec(above+number_entries(nb),nUnder-nUnder2,nUnderK,nDo,aUnder,
    799         aOther+number_entries(i),diagonal,work,kBlock,iBlock+nb,jBlock,numberBlocks);
     770        aOther+number_entries(i),work,iBlock+nb,jBlock,numberBlocks);
    800771  }
    801772}
     
    898869  int j;
    899870  longDouble * aa;
    900 #if BLOCK==16
     871#ifdef BLOCKUNROLL
    901872  if (nUnder==BLOCK) {
    902873    aa = aTri-2*BLOCK;
     
    947918      }
    948919    }
    949 #if BLOCK==16
     920#ifdef BLOCKUNROLL
    950921  }
    951922#endif
     
    968939  longDouble t00;
    969940  longDouble * aa;
    970 #if BLOCK==16
     941#ifdef BLOCKUNROLL
    971942  if (nUnder==BLOCK) {
    972943    longDouble * aUnder2 = aUnder-2;
     
    1026997      }
    1027998    }
    1028 #if BLOCK==16
     999#ifdef BLOCKUNROLL
    10291000  }
    10301001#endif
     
    10351006*/
    10361007void
    1037 ClpCholeskyDense::recRecLeaf(longDouble * above,
    1038                              longDouble * aUnder, longDouble *aOther, longDouble * diagonal, longDouble * work,
     1008ClpCholeskyDense::recRecLeaf(const longDouble * COIN_RESTRICT above,
     1009                             const longDouble * COIN_RESTRICT aUnder,
     1010                             longDouble * COIN_RESTRICT aOther,
     1011                             const longDouble * COIN_RESTRICT work,
    10391012                             int nUnder)
    10401013{
     
    10491022  printf("recrecleaf above (%d,%d), under (%d,%d), other (%d,%d)\n",
    10501023         ira,ica,iru,icu,iro,ico);
    1051   assert (diagonal==diagonal_+ica*BLOCK);
    10521024#endif
    10531025  int i, j, k;
    10541026  longDouble * aa;
    1055 #if BLOCK==16
     1027#ifdef BLOCKUNROLL
    10561028  aa = aOther-4*BLOCK;
    10571029  if (nUnder==BLOCK) {
     
    11011073        longDouble t23=aa[i+3+2*BLOCK];
    11021074        longDouble t33=aa[i+3+3*BLOCK];
     1075        const longDouble * COIN_RESTRICT aUnderNow = aUnder+i;
     1076        const longDouble * COIN_RESTRICT aboveNow = above+j;
    11031077        for (k=0;k<BLOCK;k++) {
    11041078          longDouble multiplier = work[k];
    1105           longDouble a00=aUnder[i+0+k*BLOCK]*multiplier;
    1106           longDouble a01=aUnder[i+1+k*BLOCK]*multiplier;
    1107           longDouble a02=aUnder[i+2+k*BLOCK]*multiplier;
    1108           longDouble a03=aUnder[i+3+k*BLOCK]*multiplier;
    1109           t00 -= a00 * above[j + 0 + k * BLOCK];
    1110           t10 -= a00 * above[j + 1 + k * BLOCK];
    1111           t20 -= a00 * above[j + 2 + k * BLOCK];
    1112           t30 -= a00 * above[j + 3 + k * BLOCK];
    1113           t01 -= a01 * above[j + 0 + k * BLOCK];
    1114           t11 -= a01 * above[j + 1 + k * BLOCK];
    1115           t21 -= a01 * above[j + 2 + k * BLOCK];
    1116           t31 -= a01 * above[j + 3 + k * BLOCK];
    1117           t02 -= a02 * above[j + 0 + k * BLOCK];
    1118           t12 -= a02 * above[j + 1 + k * BLOCK];
    1119           t22 -= a02 * above[j + 2 + k * BLOCK];
    1120           t32 -= a02 * above[j + 3 + k * BLOCK];
    1121           t03 -= a03 * above[j + 0 + k * BLOCK];
    1122           t13 -= a03 * above[j + 1 + k * BLOCK];
    1123           t23 -= a03 * above[j + 2 + k * BLOCK];
    1124           t33 -= a03 * above[j + 3 + k * BLOCK];
     1079          longDouble a00=aUnderNow[0]*multiplier;
     1080          longDouble a01=aUnderNow[1]*multiplier;
     1081          longDouble a02=aUnderNow[2]*multiplier;
     1082          longDouble a03=aUnderNow[3]*multiplier;
     1083          t00 -= a00 * aboveNow[0];
     1084          t10 -= a00 * aboveNow[1];
     1085          t20 -= a00 * aboveNow[2];
     1086          t30 -= a00 * aboveNow[3];
     1087          t01 -= a01 * aboveNow[0];
     1088          t11 -= a01 * aboveNow[1];
     1089          t21 -= a01 * aboveNow[2];
     1090          t31 -= a01 * aboveNow[3];
     1091          t02 -= a02 * aboveNow[0];
     1092          t12 -= a02 * aboveNow[1];
     1093          t22 -= a02 * aboveNow[2];
     1094          t32 -= a02 * aboveNow[3];
     1095          t03 -= a03 * aboveNow[0];
     1096          t13 -= a03 * aboveNow[1];
     1097          t23 -= a03 * aboveNow[2];
     1098          t33 -= a03 * aboveNow[3];
     1099          aUnderNow += BLOCK;
     1100          aboveNow += BLOCK;
    11251101        }
    11261102        aa[i+0+0*BLOCK]=t00;
     
    11571133        longDouble t21=aa[i+1+2*BLOCK];
    11581134        longDouble t31=aa[i+1+3*BLOCK];
     1135        const longDouble * COIN_RESTRICT aUnderNow = aUnder+i;
     1136        const longDouble * COIN_RESTRICT aboveNow = above+j;
    11591137        for (k=0;k<BLOCK;k++) {
    11601138          longDouble multiplier = work[k];
    1161           longDouble a00=aUnder[i+k*BLOCK]*multiplier;
    1162           longDouble a01=aUnder[i+1+k*BLOCK]*multiplier;
    1163           t00 -= a00 * above[j + 0 + k * BLOCK];
    1164           t10 -= a00 * above[j + 1 + k * BLOCK];
    1165           t20 -= a00 * above[j + 2 + k * BLOCK];
    1166           t30 -= a00 * above[j + 3 + k * BLOCK];
    1167           t01 -= a01 * above[j + 0 + k * BLOCK];
    1168           t11 -= a01 * above[j + 1 + k * BLOCK];
    1169           t21 -= a01 * above[j + 2 + k * BLOCK];
    1170           t31 -= a01 * above[j + 3 + k * BLOCK];
     1139          longDouble a00=aUnderNow[0]*multiplier;
     1140          longDouble a01=aUnderNow[1]*multiplier;
     1141          t00 -= a00 * aboveNow[0];
     1142          t10 -= a00 * aboveNow[1];
     1143          t20 -= a00 * aboveNow[2];
     1144          t30 -= a00 * aboveNow[3];
     1145          t01 -= a01 * aboveNow[0];
     1146          t11 -= a01 * aboveNow[1];
     1147          t21 -= a01 * aboveNow[2];
     1148          t31 -= a01 * aboveNow[3];
     1149          aUnderNow += BLOCK;
     1150          aboveNow += BLOCK;
    11711151        }
    11721152        aa[i+0*BLOCK]=t00;
     
    13391319{
    13401320  int j, k;
    1341 #if BLOCK==16
     1321#ifdef BLOCKUNROLL
    13421322  if (n==BLOCK) {
    13431323    for (k = 0; k < BLOCK; k+=4) {
     
    14421422      region2[k] = t00;
    14431423    }
    1444 #if BLOCK==16
     1424#ifdef BLOCKUNROLL
    14451425  }
    14461426#endif
     
    14661446{
    14671447  int j, k;
    1468 #if BLOCK==16
     1448#ifdef BLOCKUNROLL
    14691449  if (n==BLOCK) {
    14701450    for (j = 0; j < BLOCK; j +=4) {
     
    15701550      region[j] = t00;
    15711551    }
    1572 #if BLOCK==16
     1552#ifdef BLOCKUNROLL
    15731553  }
    15741554#endif
     
    16571637{
    16581638  int j, k;
    1659 #if BLOCK==16
     1639#ifdef BLOCKUNROLL
    16601640  if (n==BLOCK) {
    16611641    for (k = 0; k < BLOCK; k+=4) {
     
    17601740      region2[k] = t00;
    17611741    }
    1762 #if BLOCK==16
     1742#ifdef BLOCKUNROLL
    17631743  }
    17641744#endif
     
    17841764{
    17851765  int j, k;
    1786 #if BLOCK==16
     1766#ifdef BLOCKUNROLL
    17871767  if (n==BLOCK) {
    17881768    for (j = 0; j < BLOCK; j +=4) {
     
    18881868      region[j] = t00;
    18891869    }
    1890 #if BLOCK==16
     1870#ifdef BLOCKUNROLL
    18911871  }
    18921872#endif
     
    19751955{
    19761956  int j, k;
    1977 #if BLOCK==16
     1957#ifdef BLOCKUNROLL
    19781958  if (n==BLOCK) {
    19791959    for (k = 0; k < BLOCK; k+=4) {
     
    20782058      region2[k] = t00;
    20792059    }
    2080 #if BLOCK==16
     2060#ifdef BLOCKUNROLL
    20812061  }
    20822062#endif
     
    21022082{
    21032083  int j, k;
    2104 #if BLOCK==16
     2084#ifdef BLOCKUNROLL
    21052085  if (n==BLOCK) {
    21062086    for (j = 0; j < BLOCK; j +=4) {
     
    22062186      region[j] = t00;
    22072187    }
    2208 #if BLOCK==16
    2209   }
    2210 #endif
    2211 }
     2188#ifdef BLOCKUNROLL
     2189  }
     2190#endif
     2191}
  • trunk/Clp/src/ClpCholeskyDense.hpp

    r754 r1321  
    5959  */
    6060  void recRec(longDouble * above, int nUnder, int nUnderK,
    61               int nDo, longDouble * aUnder, longDouble *aOther,longDouble * diagonal, longDouble * work,
    62               int kBlock,int iBlock, int jBlock,
     61              int nDo, longDouble * aUnder, longDouble *aOther,
     62              longDouble * work,
     63              int iBlock, int jBlock,
    6364              int numberBlocks);
    6465  /// Leaf recursive factor
     
    7677      nUnderK is number of rows in kBlock
    7778  */
    78   void recRecLeaf(longDouble * above,
    79                   longDouble * aUnder, longDouble *aOther, longDouble * diagonal, longDouble * work,
     79  void recRecLeaf(const longDouble * COIN_RESTRICT above,
     80                  const longDouble * COIN_RESTRICT aUnder,
     81                  longDouble * COIN_RESTRICT aOther,
     82                  const longDouble * COIN_RESTRICT work,
    8083                  int nUnder);
    8184  /// Forward part of solve
  • trunk/Clp/src/ClpCholeskyUfl.hpp

    r754 r1321  
    1111#else
    1212#include "cholmod.h"
    13 #endif
     13#endif 
    1414#ifdef __cplusplus
    1515          }
  • trunk/Clp/src/ClpCholeskyWssmp.cpp

    r1034 r1321  
    328328    std::cout<<"wssmp returning error code of "<<integerParameters_[63]<<std::endl;
    329329    return 1;
     330  }
     331  // Modify gamma and delta if 0.0
     332  if (!model->gamma()&&!model->delta()) {
     333    model->setGamma(5.0e-5);
     334    model->setDelta(5.0e-5);
    330335  }
    331336  std::cout<<integerParameters_[23]<<" elements in sparse Cholesky"<<std::endl;
     
    561566      newDropped=0;
    562567      for (int i=0;i<numberRows_;i++) {
    563         char dropped = rowsDropped[i];
     568        char dropped = static_cast<char>(rowsDropped[i]);
    564569        rowsDropped_[i]=dropped;
     570        rowsDropped_[i]=0;
    565571        if (dropped==2) {
    566572          //dropped this time
     
    576582      newDropped=0;
    577583      for (int i=0;i<numberRows_;i++) {
    578         char dropped = rowsDropped[i];
     584        char dropped = static_cast<char>(rowsDropped[i]);
    579585        rowsDropped_[i]=dropped;
    580586        if (dropped==2) {
     
    606612  integerParameters_[1]=4;
    607613  integerParameters_[2]=4;
    608 #if 0
     614#if 1
    609615  integerParameters_[5]=3;
    610616  doubleParameters_[5]=1.0e-10;
  • trunk/Clp/src/ClpDualRowSteepest.cpp

    r1287 r1321  
    290290  } else {
    291291    int numberElements = model_->factorization()->numberElements();
    292     double ratio = (double) numberElements/(double) model_->numberRows();
     292    double ratio = static_cast<double> (numberElements)/
     293      static_cast<double> (model_->numberRows());
    293294    numberWanted = CoinMax(2000,number/8);
    294295    if (ratio<1.0) {
     
    299300        numberWanted=number+1;
    300301      else
    301         numberWanted = CoinMax(2000,(int) ratio);
     302        numberWanted = CoinMax(2000,static_cast<int> (ratio));
    302303    }
    303304  }
     
    309310  start[1]=number;
    310311  start[2]=0;
    311   double dstart = ((double) number) * model_->randomNumberGenerator()->randomDouble();
    312   start[0]=(int) dstart;
     312  double dstart = static_cast<double> (number) * model_->randomNumberGenerator()->randomDouble();
     313  start[0]=static_cast<int> (dstart);
    313314  start[3]=start[0];
    314315  //double largestWeight=0.0;
     
    836837      }
    837838    }
    838   } else if (mode==2||mode==4||mode==5) {
     839  } else if (mode==2||mode==4||mode>=5) {
    839840    // restore
    840841    if (!weights_||state_==-1||mode==5) {
     
    887888        which[i]=pivotVariable[i];
    888889      }
    889     } else {
     890    } else if (mode!=6) {
    890891      int * which = alternateWeights_->getIndices();
    891892      CoinIndexedVector * rowArray3 = model_->rowArray(3);
     
    897898      if (mode!=4) {
    898899        // save
    899  CoinMemcpyN(which,     numberRows,savedWeights_->getIndices());
    900  CoinMemcpyN(weights_,  numberRows,savedWeights_->denseVector());
     900        CoinMemcpyN(which,      numberRows,savedWeights_->getIndices());
     901        CoinMemcpyN(weights_,   numberRows,savedWeights_->denseVector());
    901902      } else {
    902903        // restore
     
    924925          weights_[i]=1.0;
    925926        }
     927      }
     928    } else {
     929      // mode 6 - scale back weights as primal errors
     930      double primalError = model_->largestPrimalError();
     931      double allowed ;
     932      if (primalError>1.0e3)
     933        allowed=10.0;
     934      else if (primalError>1.0e2)
     935        allowed=50.0;
     936      else if (primalError>1.0e1)
     937        allowed=100.0;
     938      else
     939        allowed=1000.0;
     940      double allowedInv =1.0/allowed;
     941      for (i=0;i<numberRows;i++) {
     942        double value = weights_[i];
     943        if (value<allowedInv)
     944          value = allowedInv;
     945        else if (value>allowed)
     946          value=allowed;
     947        weights_[i]=allowed;
    926948      }
    927949    }
  • trunk/Clp/src/ClpDynamicExampleMatrix.cpp

    r1197 r1321  
    438438  } else {
    439439    // and do some proportion of full set
    440     int startG2 = (int) (startFraction*numberSets_);
    441     int endG2 = (int) (endFraction*numberSets_+0.1);
     440    int startG2 = static_cast<int> (startFraction*numberSets_);
     441    int endG2 = static_cast<int> (endFraction*numberSets_+0.1);
    442442    endG2 = CoinMin(endG2,numberSets_);
    443443    //printf("gub price - set start %d end %d\n",
  • trunk/Clp/src/ClpDynamicMatrix.cpp

    r1197 r1321  
    225225  // guess how much space needed
    226226  double guess = numberElements;
    227   guess /= (double) numberColumns;
     227  guess /= static_cast<double> (numberColumns);
    228228  guess *= 2*numberGubInSmall;
    229   numberElements_ = (int) guess;
     229  numberElements_ = static_cast<int> (guess);
    230230  numberElements_ = CoinMin(numberElements_,numberElements)+originalMatrix->getNumElements();
    231231  matrix_ = originalMatrix;
     
    406406  if (numberWanted>0) {
    407407    // and do some proportion of full set
    408     int startG2 = (int) (startFraction*numberSets_);
    409     int endG2 = (int) (endFraction*numberSets_+0.1);
     408    int startG2 = static_cast<int> (startFraction*numberSets_);
     409    int endG2 = static_cast<int> (endFraction*numberSets_+0.1);
    410410    endG2 = CoinMin(endG2,numberSets_);
    411411    //printf("gub price - set start %d end %d\n",
     
    839839    // out may have gone through barrier - so check
    840840    double valueOut = model->lowerRegion()[sequenceOut];
    841     if (fabs(valueOut -(double) lowerSet_[iSet])<
    842         fabs(valueOut -(double) upperSet_[iSet]))
     841    if (fabs(valueOut -static_cast<double> (lowerSet_[iSet]))<
     842        fabs(valueOut -static_cast<double> (upperSet_[iSet])))
    843843      setStatus(iSet,ClpSimplex::atLowerBound);
    844844    else
  • trunk/Clp/src/ClpFactorization.cpp

    r1302 r1321  
    677677    if (model->algorithm()==2) {
    678678      ClpObjective * obj = model->objectiveAsObject();
     679#ifndef NDEBUG
    679680      ClpQuadraticObjective * quadraticObj = (dynamic_cast< ClpQuadraticObjective*>(obj));
    680681      assert (quadraticObj);
     682#else
     683      ClpQuadraticObjective * quadraticObj = (static_cast< ClpQuadraticObjective*>(obj));
     684#endif
    681685      CoinPackedMatrix * quadratic = quadraticObj->quadraticObjective();
    682686      int numberXColumns = quadratic->getNumCols();
     
    20642068    if (model->algorithm()==2) {
    20652069      ClpObjective * obj = model->objectiveAsObject();
     2070#ifndef NDEBUG
    20662071      ClpQuadraticObjective * quadraticObj = (dynamic_cast< ClpQuadraticObjective*>(obj));
    20672072      assert (quadraticObj);
     2073#else
     2074      ClpQuadraticObjective * quadraticObj = (static_cast< ClpQuadraticObjective*>(obj));
     2075#endif
    20682076      CoinPackedMatrix * quadratic = quadraticObj->quadraticObjective();
    20692077      int numberXColumns = quadratic->getNumCols();
  • trunk/Clp/src/ClpGubDynamicMatrix.cpp

    r1197 r1321  
    163163  // guess how much space needed
    164164  double guess = originalMatrix->getNumElements()+10;
    165   guess /= (double) numberColumns;
     165  guess /= static_cast<double> (numberColumns);
    166166  guess *= 2*numberGubColumns_;
    167   numberElements_ = (int) CoinMin(guess,10000000.0);
     167  numberElements_ = static_cast<int> (CoinMin(guess,10000000.0));
    168168  numberElements_ = CoinMin(numberElements_,numberElements)+originalMatrix->getNumElements();
    169169  matrix_ = originalMatrix;
     
    295295  } else {
    296296    // and do some proportion of full set
    297     int startG2 = (int) (startFraction*numberSets_);
    298     int endG2 = (int) (endFraction*numberSets_+0.1);
     297    int startG2 = static_cast<int> (startFraction*numberSets_);
     298    int endG2 = static_cast<int> (endFraction*numberSets_+0.1);
    299299    endG2 = CoinMin(endG2,numberSets_);
    300300    //printf("gub price - set start %d end %d\n",
  • trunk/Clp/src/ClpGubMatrix.cpp

    r1302 r1321  
    527527  int numberInRowArray = rowArray->getNumElements();
    528528  // maybe I need one in OsiSimplex
    529   double zeroTolerance = model->factorization()->zeroTolerance();
     529  double zeroTolerance = model->zeroTolerance();
    530530  int numberRows = model->numberRows();
    531531  ClpPackedMatrix* rowCopy =
     
    13481348    // Do packed part before gub
    13491349    int numberColumns = matrix_->getNumCols();
    1350     double ratio = ((double) firstGub_)/((double) numberColumns);
     1350    double ratio = static_cast<double> (firstGub_)/
     1351      static_cast<double> (numberColumns);
    13511352    ClpPackedMatrix::partialPricing(model,startFraction*ratio,
    13521353                                    endFraction*ratio,bestSequence,numberWanted);
     
    13741375      int sequenceOut = model->sequenceOut();
    13751376      int saveSequence = bestSequence;
    1376       int startG = firstGub_+ (int) (startFraction* (lastGub_-firstGub_));
    1377       int endG = firstGub_+ (int) (endFraction* (lastGub_-firstGub_));
     1377      int startG = firstGub_+ static_cast<int> (startFraction* (lastGub_-firstGub_));
     1378      int endG = firstGub_+ static_cast<int> (endFraction* (lastGub_-firstGub_));
    13781379      endG = CoinMin(lastGub_,endG+1);
    13791380      // If nothing found yet can go all the way to end
     
    17731774    if (numberWanted) {
    17741775      // Do packed part after gub
    1775       double offset = ((double) lastGub_)/((double) numberColumns);
    1776       double ratio = ((double) numberColumns)/((double) numberColumns)-offset;
     1776      double offset = static_cast<double> (lastGub_)/
     1777        static_cast<double> (numberColumns);
     1778      double ratio = static_cast<double> (numberColumns)/
     1779        static_cast<double> (numberColumns)-offset;
    17771780      double start2 = offset + ratio*startFraction;
    17781781      double end2 = CoinMin(1.0,offset + ratio*endFraction+1.0e-6);
  • trunk/Clp/src/ClpGubMatrix.hpp

    r1302 r1321  
    251251    int iStat = status_[sequence]&31;
    252252    iStat = iStat>>3;
    253     return (double) (iStat-1);
     253    return static_cast<double> (iStat-1);
    254254  }
    255255  /// Starts
  • trunk/Clp/src/ClpInterior.cpp

    r1197 r1321  
    984984ClpInterior::primalDual()
    985985{
    986   return ((ClpPredictorCorrector *) this)->solve();
     986  return (static_cast<ClpPredictorCorrector *> (this))->solve();
    987987}
    988988
  • trunk/Clp/src/ClpMain.cpp

    r1287 r1321  
    598598                }
    599599                if (tryIt) {
    600                   model2 = ((ClpSimplexOther *) model2)->dualOfModel(fractionRow,fractionColumn);
     600                  model2 = static_cast<ClpSimplexOther *> (model2)->dualOfModel(fractionRow,fractionColumn);
    601601                  if (model2) {
    602602                    printf("Dual of model has %d rows and %d columns\n",
     
    747747              }
    748748              if (dualize) {
    749                 int returnCode=((ClpSimplexOther *) models+iModel)->restoreFromDual(model2);
     749                int returnCode=static_cast<ClpSimplexOther *> (models+iModel)->restoreFromDual(model2);
    750750                if (model2->status()==3)
    751751                  returnCode=0;
    752752                delete model2;
    753753                if (returnCode&&dualize!=2) {
    754                   CoinSighandler_t saveSignal=SIG_DFL;
    755754                  currentModel = models+iModel;
    756755                  // register signal handler
    757                   saveSignal = signal(SIGINT,signal_handler);
     756                  signal(SIGINT,signal_handler);
    758757                  models[iModel].primal(1);
    759758                  currentModel=NULL;
     
    959958                  if (CbcOrClpRead_mode==2&&argc==2) {
    960959                    // only if ends .mps
    961                     char * find = (char *)strstr(fileName.c_str(),".mps");
     960                    char * find = reinterpret_cast<char *>(strstr(fileName.c_str(),".mps"));
    962961                    if (find&&find[4]=='\0') {
    963962                      find[1]='p'; find[2]='a';find[3]='r';
     
    10411040                ClpSimplex * model2 = models+iModel;
    10421041                if (dualize&&dualize<3) {
    1043                   model2 = ((ClpSimplexOther *) model2)->dualOfModel();
     1042                  model2 = static_cast<ClpSimplexOther *> (model2)->dualOfModel();
    10441043                  printf("Dual of model has %d rows and %d columns\n",
    10451044                         model2->numberRows(),model2->numberColumns());
     
    19631962    1.0e1,1.0e2,1.0e3,1.0e4,1.0e5,1.0e8,1.0e11,1.0e15,
    19641963    COIN_DBL_MAX};
    1965   int nRanges = (int) (sizeof(range)/sizeof(double));
     1964  int nRanges = static_cast<int> (sizeof(range)/sizeof(double));
    19661965  int * number = new int[nRanges];
    19671966  memset(number,0,nRanges*sizeof(int));
     
    21832182  printf("Column breakdown:\n");
    21842183  int k;
    2185   for (k=0;k<(int) (sizeof(cType)/sizeof(int));k++) {
     2184  for (k=0;k<static_cast<int> (sizeof(cType)/sizeof(int));k++) {
    21862185    printf("%d of type %s ",cType[k],cName[k].c_str());
    21872186    if (((k+1)%3)==0)
     
    21912190    printf("\n");
    21922191  printf("Row breakdown:\n");
    2193   for (k=0;k<(int) (sizeof(rType)/sizeof(int));k++) {
     2192  for (k=0;k<static_cast<int> (sizeof(rType)/sizeof(int));k++) {
    21942193    printf("%d of type %s ",rType[k],rName[k].c_str());
    21952194    if (((k+1)%3)==0)
  • trunk/Clp/src/ClpModel.cpp

    r1314 r1321  
    192192{
    193193  if (!savedRowScale_) {
    194     delete [] (double *) rowScale_;
     194    delete [] reinterpret_cast<double *> (rowScale_);
    195195    rowScale_ = scale;
    196196  } else {
     
    203203{
    204204  if (!savedColumnScale_) {
    205     delete [] (double *) columnScale_;
     205    delete [] reinterpret_cast<double *> (columnScale_);
    206206    columnScale_ = scale;
    207207  } else {
     
    330330    matrix_=new ClpPackedMatrix(matrix);
    331331    if (special) {
    332       clpMatrix = dynamic_cast< ClpPackedMatrix*>(matrix_);
     332      clpMatrix = static_cast< ClpPackedMatrix*>(matrix_);
    333333      clpMatrix->makeSpecialColumnCopy();
    334334    }
     
    406406  gutsOfLoadModel(numberRows, numberColumns,
    407407                  columnLower, columnUpper, objective, rowLower, rowUpper, NULL);
     408  setObjectiveOffset(modelObject.objectiveOffset());
    408409  CoinBigIndex * startPositive = NULL;
    409410  CoinBigIndex * startNegative = NULL;
     
    14091410    if (status_) {
    14101411      if (numberColumns_+newSize) {
    1411         unsigned char * tempR  = (unsigned char *) deleteChar((char *)status_+numberColumns_,
    1412                                                               numberRows_,
    1413                                                               number, which, newSize,false);
     1412        unsigned char * tempR  = reinterpret_cast<unsigned char *>
     1413          (deleteChar(reinterpret_cast<char *>(status_)+numberColumns_,
     1414                      numberRows_,
     1415                      number, which, newSize,false));
    14141416        unsigned char * tempC = new unsigned char [numberColumns_+newSize];
    14151417        CoinMemcpyN(status_,numberColumns_,tempC);
     
    15191521  if (status_) {
    15201522    if (numberRows_+newSize) {
    1521       unsigned char * tempC  = (unsigned char *) deleteChar((char *)status_,
    1522                                                             numberColumns_,
    1523                                                             number, which, newSize,false);
     1523      unsigned char * tempC  = reinterpret_cast<unsigned char *>
     1524        (deleteChar(reinterpret_cast<char *>(status_),
     1525                    numberColumns_,
     1526                    number, which, newSize,false));
    15241527      unsigned char * temp = new unsigned char [numberRows_+newSize];
    15251528      CoinMemcpyN(tempC,newSize,temp);
     
    27512754      for (iRow=0;iRow<numberRows_;iRow++) {
    27522755        const char * name = m.rowName(iRow);
    2753         maxLength = CoinMax(maxLength,(unsigned int) strlen(name));
     2756        maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(name)));
    27542757          rowNames_.push_back(name);
    27552758      }
     
    27592762      for (iColumn=0;iColumn<numberColumns_;iColumn++) {
    27602763        const char * name = m.columnName(iColumn);
    2761         maxLength = CoinMax(maxLength,(unsigned int) strlen(name));
     2764        maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(name)));
    27622765        columnNames_.push_back(name);
    27632766      }
    2764       lengthNames_=(int) maxLength;
     2767      lengthNames_=static_cast<int> (maxLength);
    27652768    } else {
    27662769      lengthNames_=0;
     
    28352838      for (iRow=0;iRow<numberRows_;iRow++) {
    28362839        const char * name = m.rowName(iRow);
    2837         maxLength = CoinMax(maxLength,(unsigned int) strlen(name));
     2840        maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(name)));
    28382841          rowNames_.push_back(name);
    28392842      }
     
    28432846      for (iColumn=0;iColumn<numberColumns_;iColumn++) {
    28442847        const char * name = m.columnName(iColumn);
    2845         maxLength = CoinMax(maxLength,(unsigned int) strlen(name));
     2848        maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(name)));
    28462849        columnNames_.push_back(name);
    28472850      }
    2848       lengthNames_=(int) maxLength;
     2851      lengthNames_=static_cast<int> (maxLength);
    28492852    } else {
    28502853      lengthNames_=0;
     
    31683171    for (iRow=0;iRow<numberRows_;iRow++) {
    31693172      rowNames_.push_back(rhs->rowNames_[whichRow[iRow]]);
    3170       maxLength = CoinMax(maxLength,(unsigned int) strlen(rowNames_[iRow].c_str()));
     3173      maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(rowNames_[iRow].c_str())));
    31713174    }
    31723175    int iColumn;
     
    31743177    for (iColumn=0;iColumn<numberColumns_;iColumn++) {
    31753178      columnNames_.push_back(rhs->columnNames_[whichColumn[iColumn]]);
    3176       maxLength = CoinMax(maxLength,(unsigned int) strlen(columnNames_[iColumn].c_str()));
    3177     }
    3178     lengthNames_=(int) maxLength;
     3179      maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(columnNames_[iColumn].c_str())));
     3180    }
     3181    lengthNames_=static_cast<int> (maxLength);
    31793182  } else {
    31803183    lengthNames_ = 0;
     
    32523255  for (iRow=0;iRow<numberRows_;iRow++) {
    32533256    rowNames_.push_back(rowNames[iRow]);
    3254     maxLength = CoinMax(maxLength,(unsigned int) strlen(rowNames_[iRow].c_str()));
     3257    maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(rowNames_[iRow].c_str())));
    32553258  }
    32563259  int iColumn;
     
    32583261  for (iColumn=0;iColumn<numberColumns_;iColumn++) {
    32593262    columnNames_.push_back(columnNames[iColumn]);
    3260     maxLength = CoinMax(maxLength,(unsigned int) strlen(columnNames_[iColumn].c_str()));
    3261   }
    3262   lengthNames_=(int) maxLength;
     3263    maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(columnNames_[iColumn].c_str())));
     3264  }
     3265  lengthNames_=static_cast<int> (maxLength);
    32633266}
    32643267// Return name or Rnnnnnnn
     
    32953298    rowNames_.resize(iRow+1);
    32963299  rowNames_[iRow]= name;
    3297   maxLength = CoinMax(maxLength,(unsigned int) strlen(name.c_str()));
     3300  maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(name.c_str())));
    32983301  // May be too big - but we would have to check both rows and columns to be exact
    3299   lengthNames_=(int) maxLength;
     3302  lengthNames_=static_cast<int> (maxLength);
    33003303}
    33013304// Return name or Cnnnnnnn
     
    33323335    columnNames_.resize(iColumn+1);
    33333336  columnNames_[iColumn]= name;
    3334   maxLength = CoinMax(maxLength,(unsigned int) strlen(name.c_str()));
     3337  maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(name.c_str())));
    33353338  // May be too big - but we would have to check both columns and columns to be exact
    3336   lengthNames_=(int) maxLength;
     3339  lengthNames_=static_cast<int> (maxLength);
    33373340}
    33383341// Copies in Row names - modifies names first .. last-1
     
    33473350  for (iRow=first; iRow<last;iRow++) {
    33483351    rowNames_[iRow]= rowNames[iRow-first];
    3349     maxLength = CoinMax(maxLength,(unsigned int) strlen(rowNames_[iRow-first].c_str()));
     3352    maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(rowNames_[iRow-first].c_str())));
    33503353  }
    33513354  // May be too big - but we would have to check both rows and columns to be exact
    3352   lengthNames_=(int) maxLength;
     3355  lengthNames_=static_cast<int> (maxLength);
    33533356}
    33543357// Copies in Column names - modifies names first .. last-1
     
    33633366  for (iColumn=first; iColumn<last;iColumn++) {
    33643367    columnNames_[iColumn]= columnNames[iColumn-first];
    3365     maxLength = CoinMax(maxLength,(unsigned int) strlen(columnNames_[iColumn-first].c_str()));
     3368    maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(columnNames_[iColumn-first].c_str())));
    33663369  }
    33673370  // May be too big - but we would have to check both rows and columns to be exact
    3368   lengthNames_=(int) maxLength;
     3371  lengthNames_=static_cast<int> (maxLength);
    33693372}
    33703373// Copies in Row names - modifies names first .. last-1
     
    33803383    if (rowNames[iRow-first]&&strlen(rowNames[iRow-first])) {
    33813384      rowNames_[iRow]= rowNames[iRow-first];
    3382       maxLength = CoinMax(maxLength,(unsigned int) strlen(rowNames[iRow-first]));
     3385      maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(rowNames[iRow-first])));
    33833386    } else {
    3384       maxLength = CoinMax(maxLength,(unsigned int) 8);
     3387      maxLength = CoinMax(maxLength,static_cast<unsigned int> (8));
    33853388      char name[9];
    33863389      sprintf(name,"R%7.7d",iRow);
     
    33893392  }
    33903393  // May be too big - but we would have to check both rows and columns to be exact
    3391   lengthNames_=(int) maxLength;
     3394  lengthNames_=static_cast<int> (maxLength);
    33923395}
    33933396// Copies in Column names - modifies names first .. last-1
     
    34033406    if (columnNames[iColumn-first]&&strlen(columnNames[iColumn-first])) {
    34043407      columnNames_[iColumn]= columnNames[iColumn-first];
    3405       maxLength = CoinMax(maxLength,(unsigned int) strlen(columnNames[iColumn-first]));
     3408      maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(columnNames[iColumn-first])));
    34063409    } else {
    3407       maxLength = CoinMax(maxLength,(unsigned int) 8);
     3410      maxLength = CoinMax(maxLength,static_cast<unsigned int> (8));
    34083411      char name[9];
    34093412      sprintf(name,"C%7.7d",iColumn);
     
    34123415  }
    34133416  // May be too big - but we would have to check both rows and columns to be exact
    3414   lengthNames_=(int) maxLength;
     3417  lengthNames_=static_cast<int> (maxLength);
    34153418}
    34163419#endif
     
    35953598                    getColLower(), getColUpper(),
    35963599                    objective,
    3597                     (const char*) 0 /*integrality*/,
     3600                    reinterpret_cast<const char*> (NULL) /*integrality*/,
    35983601                    getRowLower(), getRowUpper(),
    35993602                    columnNames, rowNames);
     
    41104113            assert (!OK||!reflectionOK||!numberIn);
    41114114            //if (!numberLast) merit=1;
    4112             count[numberLeft++]=(rowStart[iRow+1]-rowStart[iRow]-1)*((double)merit);
     4115            count[numberLeft++]=(rowStart[iRow+1]-rowStart[iRow]-1)*
     4116              (static_cast<double>(merit));
    41134117            if (OK)
    41144118              rotate[iRow]=0;
     
    42184222  sparseThreshold_ = 0;
    42194223  pivotTolerance_=0.0;
     4224  zeroFactorizationTolerance_=1.0e13;
     4225  zeroSimplexTolerance_=1.0e-13;
    42204226  acceptablePivot_ = 0.0;
    42214227  objectiveScale_ = 1.0;
     
    42344240  infeasibilityCost_ = rhs.infeasibilityCost_;
    42354241  pivotTolerance_ = rhs.pivotTolerance_;
     4242  zeroFactorizationTolerance_= rhs.zeroFactorizationTolerance_;
     4243  zeroSimplexTolerance_= rhs.zeroSimplexTolerance_;
    42364244  acceptablePivot_ = rhs.acceptablePivot_;
    42374245  objectiveScale_ = rhs.objectiveScale_;
     
    42604268    infeasibilityCost_ = rhs.infeasibilityCost_;
    42614269    pivotTolerance_ = rhs.pivotTolerance_;
     4270    zeroFactorizationTolerance_=zeroFactorizationTolerance_;
     4271    zeroSimplexTolerance_=zeroSimplexTolerance_;
    42624272    acceptablePivot_ = rhs.acceptablePivot_;
    42634273    objectiveScale_ = rhs.objectiveScale_;
  • trunk/Clp/src/ClpModel.hpp

    r1267 r1321  
    10841084  double infeasibilityCost_;
    10851085  double pivotTolerance_;
     1086  double zeroFactorizationTolerance_;
     1087  double zeroSimplexTolerance_;
    10861088  double acceptablePivot_;
    10871089  double objectiveScale_;
  • trunk/Clp/src/ClpNetworkMatrix.cpp

    r1302 r1321  
    367367  int numberInRowArray = rowArray->getNumElements();
    368368  // maybe I need one in OsiSimplex
    369   double zeroTolerance = model->factorization()->zeroTolerance();
     369  double zeroTolerance = model->zeroTolerance();
    370370  int numberRows = model->numberRows();
    371371#ifndef NO_RTTI
     
    878878  numberWanted=currentWanted_;
    879879  int j;
    880   int start = (int) (startFraction*numberColumns_);
    881   int end = CoinMin((int) (endFraction*numberColumns_+1),numberColumns_);
     880  int start = static_cast<int> (startFraction*numberColumns_);
     881  int end = CoinMin(static_cast<int> (endFraction*numberColumns_+1),numberColumns_);
    882882  double tolerance=model->currentDualTolerance();
    883883  double * reducedCost = model->djRegion();
  • trunk/Clp/src/ClpNode.cpp

    r1287 r1321  
    183183  sequence_=-1;
    184184  double integerTolerance = stuff->integerTolerance_;
    185   double mostAway=integerTolerance;
     185  double mostAway=0.0;
    186186  sumInfeasibilities_ = 0.0;
    187187  numberInfeasibilities_ = 0;
     
    251251    if (integerType[iColumn]) {
    252252      double value = solution[iColumn];
    253       value = CoinMax(value,(double) lower[iColumn]);
    254       value = CoinMin(value,(double) upper[iColumn]);
     253      value = CoinMax(value,static_cast<double> (lower[iColumn]));
     254      value = CoinMin(value,static_cast<double> (upper[iColumn]));
    255255      double nearest = floor(value+0.5);
    256256      if (fabs(value-nearest)>integerTolerance) {
     
    295295            0.9*CoinMin(upValue,downValue) + integerTolerance;
    296296#elif PSEUDO==3
    297         double upValue = (ceil(value)-value)*(upPseudo[iInteger]/(1.0+numberUp[iInteger]+numberUpInfeasible[iInteger]));
    298         double downValue = (value-floor(value))*(downPseudo[iInteger]/(1.0+numberDown[iInteger]+numberDownInfeasible[iInteger]));
     297        // Extra 100% for infeasible branches
     298        double upValue = (ceil(value)-value)*(upPseudo[iInteger]/
     299                                              (1.0+numberUp[iInteger]));
     300        if (numberUp[iInteger]) {
     301          double ratio = 1.0+static_cast<double>(numberUpInfeasible[iInteger])/
     302            static_cast<double>(numberUp[iInteger]);
     303          upValue *= ratio;
     304        }
     305        double downValue = (value-floor(value))*(downPseudo[iInteger]/
     306                                                 (1.0+numberDown[iInteger]));
     307        if (numberDown[iInteger]) {
     308          double ratio = 1.0+static_cast<double>(numberDownInfeasible[iInteger])/
     309            static_cast<double>(numberDown[iInteger]);
     310          downValue *= ratio;
     311        }
    299312        double infeasibility;
    300313        if (depth>1000)
     
    307320        double infeasibility = fabs(value-nearest);
    308321#endif
     322        assert (infeasibility>0.0);
    309323        if (infeasibility>mostAway) {
    310324          mostAway=infeasibility;
     
    373387    for (iColumn=0;iColumn<numberColumns;iColumn++) {
    374388      if (integerType[iColumn]) {
    375         lower_[iInteger]=(int) lower[iColumn];
    376         upper_[iInteger]=(int) upper[iColumn];
     389        lower_[iInteger]=static_cast<int> (lower[iColumn]);
     390        upper_[iInteger]=static_cast<int> (upper[iColumn]);
    377391        iInteger++;
    378392      }
     
    509523      if (integerType[iColumn]) {
    510524        iInteger++;
    511         if (lower_[iInteger]!=(int) lower[iColumn])
     525        if (lower_[iInteger]!=static_cast<int> (lower[iColumn]))
    512526          model->setColumnLower(iColumn,lower_[iInteger]);
    513         if (upper_[iInteger]!=(int) upper[iColumn])
     527        if (upper_[iInteger]!=static_cast<int> (upper[iColumn]))
    514528          model->setColumnUpper(iColumn,upper_[iInteger]);
    515529      }
     
    772786  for (int i=0;i<number;i++) {
    773787    int n;
    774     n = numberDown_[i]+numberDownInfeasible_[i];
     788    n = numberDown_[i];
    775789    if (n)
    776790      downPseudo_[i] *= n;
    777     n = numberUp_[i]+numberUpInfeasible_[i];
     791    n = numberUp_[i];
    778792    if (n)
    779793      upPseudo_[i] *= n;
     
    784798ClpNodeStuff::update(int way,int sequence,double change,bool feasible)
    785799{
     800  assert (numberDown_[sequence]>=numberDownInfeasible_[sequence]);
     801  assert (numberUp_[sequence]>=numberUpInfeasible_[sequence]);
    786802  if (way<0) {
    787     if (feasible)
    788       numberDown_[sequence]++;
    789     else
     803    numberDown_[sequence]++;
     804    if (!feasible)
    790805      numberDownInfeasible_[sequence]++;
    791806    downPseudo_[sequence] += CoinMax(change,1.0e-12);
    792807  } else {
    793     if (feasible)
    794       numberUp_[sequence]++;
    795     else
     808    numberUp_[sequence]++;
     809    if (!feasible)
    796810      numberUpInfeasible_[sequence]++;
    797811    upPseudo_[sequence] += CoinMax(change,1.0e-12);
  • trunk/Clp/src/ClpNonLinearCost.cpp

    r1264 r1321  
    820820            // below
    821821            newWhere=CLP_BELOW_LOWER;
     822            assert (fabs(lowerValue)<1.0e100);
    822823            double infeasibility = lowerValue-value-primalTolerance;
    823824            sumInfeasibilities_ += infeasibility;
     
    998999        lowerValue=upperValue;
    9991000        upperValue=bound_[iSequence];
     1001        assert (fabs(lowerValue)<1.0e100);
    10001002      } else if (iWhere==CLP_ABOVE_UPPER) {
    10011003        upperValue=lowerValue;
     
    12661268        upperValue=bound_[iSequence];
    12671269        numberInfeasibilities_--;
     1270        assert (fabs(lowerValue)<1.0e100);
    12681271      } else if (iWhere==CLP_ABOVE_UPPER) {
    12691272        upperValue=lowerValue;
     
    12801283          // below
    12811284          newWhere=CLP_BELOW_LOWER;
     1285          assert (fabs(lowerValue)<1.0e100);
    12821286          costValue -= infeasibilityWeight_;
    12831287          numberInfeasibilities_++;
     
    13791383        upperValue=bound_[iSequence];
    13801384        numberInfeasibilities_--;
     1385        assert (fabs(lowerValue)<1.0e100);
    13811386      } else if (iWhere==CLP_ABOVE_UPPER) {
    13821387        upperValue=lowerValue;
     
    13951400          costValue -= infeasibilityWeight_;
    13961401          numberInfeasibilities_++;
     1402          assert (fabs(lowerValue)<1.0e100);
    13971403        }
    13981404      } else {
     
    15221528      upperValue=bound_[iSequence];
    15231529      numberInfeasibilities_--;
     1530      assert (fabs(lowerValue)<1.0e100);
    15241531    } else if (iWhere==CLP_ABOVE_UPPER) {
    15251532      upperValue=lowerValue;
     
    15381545        costValue -= infeasibilityWeight_;
    15391546        numberInfeasibilities_++;
     1547        assert (fabs(lowerValue)<1.0e100);
    15401548      }
    15411549    } else {
     
    17321740      upperValue=bound_[iSequence];
    17331741      numberInfeasibilities_--;
     1742      assert (fabs(lowerValue)<1.0e100);
    17341743    } else if (iWhere==CLP_ABOVE_UPPER) {
    17351744      upperValue=lowerValue;
     
    17511760        costValue -= infeasibilityWeight_;
    17521761        numberInfeasibilities_++;
     1762        assert (fabs(lowerValue)<1.0e100);
    17531763      }
    17541764    } else {
     
    18231833      lowerValue=upperValue;
    18241834      upperValue=bound_[iSequence];
     1835      assert (fabs(lowerValue)<1.0e100);
    18251836    } else if (iWhere==CLP_ABOVE_UPPER) {
    18261837      upperValue=lowerValue;
     
    18961907      lowerValue=upperValue;
    18971908      upperValue=bound_[iSequence];
     1909      assert (fabs(lowerValue)<1.0e100);
    18981910      costValue -= infeasibilityCost;
    18991911      assert (value<=lowerValue-primalTolerance);
  • trunk/Clp/src/ClpPackedMatrix.cpp

    r1310 r1321  
    527527  int numberInRowArray = rowArray->getNumElements();
    528528  // maybe I need one in OsiSimplex
    529   double zeroTolerance = model->factorization()->zeroTolerance();
     529  double zeroTolerance = model->zeroTolerance();
     530#if 0 //def COIN_DEVELOP
     531  if (zeroTolerance!=1.0e-13) {
     532    printf("small element in matrix - zero tolerance %g\n",zeroTolerance);
     533  }
     534#endif
    530535  int numberRows = model->numberRows();
    531 #ifndef NO_RTTI
    532   ClpPackedMatrix* rowCopy =
    533     dynamic_cast< ClpPackedMatrix*>(model->rowCopy());
    534 #else
    535536  ClpPackedMatrix* rowCopy =
    536537    static_cast< ClpPackedMatrix*>(model->rowCopy());
    537 #endif
    538538  bool packed = rowArray->packedMode();
    539539  double factor = (numberRows<100) ? 0.25 : 0.35;
     
    762762  int numberInRowArray = rowArray->getNumElements();
    763763  // maybe I need one in OsiSimplex
    764   double zeroTolerance = model->factorization()->zeroTolerance();
     764  double zeroTolerance = model->zeroTolerance();
    765765  bool packed = rowArray->packedMode();
    766766  // do by column
     
    989989  int numberInRowArray = rowArray->getNumElements();
    990990  // maybe I need one in OsiSimplex
    991   double zeroTolerance = model->factorization()->zeroTolerance();
     991  double zeroTolerance = model->zeroTolerance();
    992992  const int * column = matrix_->getIndices();
    993993  const CoinBigIndex * rowStart = getVectorStarts();
     
    10251025      numberNonZero=0;
    10261026      // and set up mark as char array
    1027       char * marked = (char *) markVector;
     1027      char * marked = reinterpret_cast<char *> (markVector);
    10281028      for (i=0;i<numberOriginal;i++) {
    10291029        int iColumn = index[i];
     
    12791279  }
    12801280  // and set up mark as char array
    1281   char * marked = (char *) (index+output->capacity());
     1281  char * marked = reinterpret_cast<char *> (index+output->capacity());
    12821282  int * lookup = spareVector->getIndices();
    12831283  double value = pi0*scalar;
     
    15341534  double * array = dj1->denseVector();
    15351535  int numberInRowArray = pi1->getNumElements();
    1536   double zeroTolerance = model->factorization()->zeroTolerance();
     1536  double zeroTolerance = model->zeroTolerance();
    15371537  bool packed = pi1->packedMode();
    15381538  // do by column
     
    20362036    rowCopyBase = reverseOrderedCopy();
    20372037  }
    2038 #ifndef NO_RTTI
     2038#ifndef NDEBUG
    20392039  ClpPackedMatrix* rowCopy =
    20402040    dynamic_cast< ClpPackedMatrix*>(rowCopyBase);
     
    21442144    return 1;
    21452145  } else {
    2146       // need to scale
     2146      // need to scale
     2147    if (largest>1.0e13*smallest) {
     2148      // safer to have smaller zero tolerance
     2149      double ratio = smallest/largest;
     2150      ClpSimplex * simplex = static_cast<ClpSimplex *> (model);
     2151      double newTolerance = CoinMax(ratio*0.5,1.0e-18);
     2152      if (simplex->zeroTolerance()>newTolerance)
     2153        simplex->setZeroTolerance(newTolerance);
     2154    }
    21472155    int scalingMethod = model->scalingFlag();
    21482156    if (scalingMethod==4) {
     
    24912499      <<overallLargest
    24922500      <<CoinMessageEol;
     2501    if (overallSmallest<1.0e-13) {
     2502      // Change factorization zero tolerance
     2503      double newTolerance = CoinMax(1.0e-15*(overallSmallest/1.0e-13),
     2504                                             1.0e-18);
     2505      ClpSimplex * simplex = static_cast<ClpSimplex *> (model);
     2506      if (simplex->factorization()->zeroTolerance()>newTolerance)
     2507        simplex->factorization()->zeroTolerance(newTolerance);
     2508      newTolerance = CoinMax(overallSmallest*0.5,1.0e-18);
     2509      simplex->setZeroTolerance(newTolerance);
     2510    }
    24932511    delete [] usefulRow;
    24942512    delete [] usefulColumn;
     
    28302848      matrix_->removeGaps();
    28312849#else
    2832       flags_ |= 2;
     2850      checkGaps();
    28332851#endif
    28342852#ifdef COIN_DEVELOP
     
    31063124{
    31073125  numberWanted=currentWanted_;
    3108   int start = (int) (startFraction*numberActiveColumns_);
    3109   int end = CoinMin((int) (endFraction*numberActiveColumns_+1),numberActiveColumns_);
     3126  int start = static_cast<int> (startFraction*numberActiveColumns_);
     3127  int end = CoinMin(static_cast<int> (endFraction*numberActiveColumns_+1),numberActiveColumns_);
    31103128  const double * element =matrix_->getElements();
    31113129  const int * row = matrix_->getIndices();
     
    33583376  columnCopy_=NULL;
    33593377  flags_ &= ~(4+8);
     3378  checkGaps();
    33603379 }
    33613380// makes sure active columns correct
     
    33973416#endif
    33983417    ClpMatrixBase * rowCopyBase=model->rowCopy();
    3399 #ifndef NO_RTTI
     3418#ifndef NDEBUG
    34003419    ClpPackedMatrix* rowCopy =
    34013420      dynamic_cast< ClpPackedMatrix*>(rowCopyBase);
     
    34893508  numberActiveColumns_ = matrix_->getNumCols();
    34903509  // may now have gaps
    3491   flags_ |= 2;
     3510  checkGaps();
    34923511  matrix_->setExtraGap(0.0);
    34933512}
     
    35013520  numberActiveColumns_ = matrix_->getNumCols();
    35023521  // may now have gaps
    3503   flags_ |= 2;
     3522  checkGaps();
    35043523  matrix_->setExtraGap(0.0);
    35053524}
     
    35203539  numberActiveColumns_ = matrix_->getNumCols();
    35213540  // may now have gaps
    3522   flags_ |= 2;
     3541  checkGaps();
    35233542  clearCopies();
    35243543}
     
    43214340  for (iBlock=0;iBlock<numberBlocks_;iBlock++) {
    43224341    double * dwork = work_+6*iBlock;
    4323     int * iwork = (int *) (dwork+3);
     4342    int * iwork = reinterpret_cast<int *> (dwork+3);
    43244343    if (!dualColumn) {
    43254344#ifndef THREAD
     
    45804599  // even if no blocks do a dummy one
    45814600  numberBlocks_ = CoinMax(numberBlocks_,1);
    4582   block_ = (blockStruct *) new char [numberBlocks_*sizeof(blockStruct)];
     4601  block_ = new blockStruct [numberBlocks_];
    45834602  memset(block_,0,numberBlocks_*sizeof(blockStruct));
    45844603  // Fill in what we can
     
    49014920  int * index = output->getIndices();
    49024921  double * array = output->denseVector();
    4903   double zeroTolerance = model->factorization()->zeroTolerance();
     4922  double zeroTolerance = model->zeroTolerance();
    49044923  double value = 0.0;
    49054924  CoinBigIndex j;
     
    50685087  int * index = output->getIndices();
    50695088  double * array = output->denseVector();
    5070   double zeroTolerance = model->factorization()->zeroTolerance();
     5089  double zeroTolerance = model->zeroTolerance();
    50715090  double value = 0.0;
    50725091  bool killDjs = (scaleFactor==0.0);
  • trunk/Clp/src/ClpPackedMatrix.hpp

    r1302 r1321  
    289289  inline int flags() const
    290290  { return flags_;}
     291  /// Sets flags_ correctly
     292  inline void checkGaps()
     293  { flags_ = (matrix_->hasGaps()) ? (flags_|2) : (flags_&(~2));}
    291294   //@}
    292295
  • trunk/Clp/src/ClpParameters.hpp

    r1267 r1321  
    8080ClpDisjointCopyN( const T * array, const int size, T * newArray)
    8181{
    82   memcpy((void *) newArray,array,size*sizeof(T));
     82  memcpy(reinterpret_cast<void *> (newArray),array,size*sizeof(T));
    8383}
    8484/// And set
  • trunk/Clp/src/ClpPlusMinusOneMatrix.cpp

    r1302 r1321  
    503503  int numberInRowArray = rowArray->getNumElements();
    504504  // maybe I need one in OsiSimplex
    505   double zeroTolerance = model->factorization()->zeroTolerance();
     505  double zeroTolerance = model->zeroTolerance();
    506506  int numberRows = model->numberRows();
    507507  bool packed = rowArray->packedMode();
     
    603603  int numberInRowArray = rowArray->getNumElements();
    604604  // maybe I need one in OsiSimplex
    605   double zeroTolerance = model->factorization()->zeroTolerance();
     605  double zeroTolerance = model->zeroTolerance();
    606606  const int * column = indices_;
    607607  const CoinBigIndex * startPositive = startPositive_;
     
    618618      numberNonZero=0;
    619619      // and set up mark as char array
    620       char * marked = (char *) (index+columnArray->capacity());
     620      char * marked = reinterpret_cast<char *> (index+columnArray->capacity());
    621621      double * array2 = y->denseVector();
    622622#ifdef CLP_DEBUG
     
    666666      numberNonZero=0;
    667667      // and set up mark as char array
    668       char * marked = (char *) markVector;
     668      char * marked = reinterpret_cast<char *> (markVector);
    669669      for (i=0;i<numberOriginal;i++) {
    670670        int iColumn = index[i];
     
    723723      }
    724724      // and set up mark as char array
    725       char * marked = (char *) (index+columnArray->capacity());
     725      char * marked = reinterpret_cast<char *> (index+columnArray->capacity());
    726726      int * lookup = y->getIndices();
    727727      double value = pi0*scalar;
     
    15041504{
    15051505  numberWanted=currentWanted_;
    1506   int start = (int) (startFraction*numberColumns_);
    1507   int end = CoinMin((int) (endFraction*numberColumns_+1),numberColumns_);
     1506  int start = static_cast<int> (startFraction*numberColumns_);
     1507  int end = CoinMin(static_cast<int> (endFraction*numberColumns_+1),numberColumns_);
    15081508  CoinBigIndex j;
    15091509  double tolerance=model->currentDualTolerance();
     
    16891689  double * array = dj1->denseVector();
    16901690  int numberInRowArray = pi1->getNumElements();
    1691   double zeroTolerance = model->factorization()->zeroTolerance();
     1691  double zeroTolerance = model->zeroTolerance();
    16921692  bool packed = pi1->packedMode();
    16931693  // do by column
  • trunk/Clp/src/ClpPredictorCorrector.cpp

    r1210 r1321  
    459459        return -1;
    460460      } else {
     461#ifndef NDEBUG
    461462        //int newDropped2=cholesky_->factorize(diagonal_,rowsDroppedThisTime);
    462463        //assert(!newDropped2);
     464#endif
    463465        if (newDropped<0&&0) {
    464466          //replace dropped
     
    523525      double phi;
    524526      if (numberComplementarityPairs_<=5000) {
    525         phi=pow((double) numberComplementarityPairs_,2.0);
     527        phi=pow(static_cast<double> (numberComplementarityPairs_),2.0);
    526528      } else {
    527         phi=pow((double) numberComplementarityPairs_,1.5);
     529        phi=pow(static_cast<double> (numberComplementarityPairs_),1.5);
    528530        if (phi<500.0*500.0) {
    529531          phi=500.0*500.0;
     
    690692      double phi;
    691693      if (numberComplementarityPairs_<=500) {
    692         phi=pow((double) numberComplementarityPairs_,2.0);
     694        phi=pow(static_cast<double> (numberComplementarityPairs_),2.0);
    693695      } else {
    694         phi=pow((double) numberComplementarityPairs_,1.5);
     696        phi=pow(static_cast<double> (numberComplementarityPairs_),1.5);
    695697        if (phi<500.0*500.0) {
    696698          phi=500.0*500.0;
     
    741743      smallestPrimalDualMu=mu_;
    742744    if (!goodMove)
    743       mu_=nextGap / ((double) 1.1*nextNumber);
     745      mu_=nextGap / (static_cast<double> (nextNumber)*1.1);
    744746    //if (quadraticObj)
    745747    //goodMove=true;
     
    13161318      }
    13171319    }
    1318     double mu = (sumL+sumU)/((double) (nL+nU));
     1320    double mu = (sumL+sumU)/(static_cast<double> (nL+nU));
    13191321
    13201322    double minBeta = 0.1*mu;
     
    17721774    maximumObjective=1.0; // objective all zero
    17731775  }
    1774   objectiveNorm2=sqrt(objectiveNorm2)/(double) numberTotal;
     1776  objectiveNorm2=sqrt(objectiveNorm2)/static_cast<double> (numberTotal);
    17751777  objectiveNorm_=maximumObjective;
    17761778  scaleFactor_=1.0;
     
    30183020    qDiagonal=1.0e-8*mu_;
    30193021  }
    3020   //double nextMu = nextGap/((double)(2*numberComplementarityPairs_));
     3022  //double nextMu = nextGap/(static_cast<double>(2*numberComplementarityPairs_));
    30213023  //printf("using gap of %g\n",nextMu);
    30223024  //qDiagonal *= 1.0e2;
  • trunk/Clp/src/ClpPresolve.cpp

    r1297 r1321  
    839839 
    840840  while (paction) {
    841 #if     PRESOLVE_DEBUG
     841#if PRESOLVE_DEBUG
    842842    printf("POSTSOLVING %s\n", paction->name());
    843843#endif
     
    999999
    10001000{
    1001   bulk0_ = (CoinBigIndex) (bulkRatio_*nelems_in);
     1001  bulk0_ = static_cast<CoinBigIndex> (bulkRatio_*nelems_in);
    10021002  hrow_  = new int   [bulk0_];
    10031003  colels_ = new double[bulk0_];
     
    11791179  delete mRow;
    11801180  if (si->integerInformation()) {
    1181     CoinMemcpyN((unsigned char *) si->integerInformation(),ncols_,integerType_);
     1181    CoinMemcpyN(reinterpret_cast<unsigned char *> (si->integerInformation()),ncols_,integerType_);
    11821182  } else {
    1183     ClpFillN<unsigned char>(integerType_, ncols_, (unsigned char) 0);
     1183    ClpFillN<unsigned char>(integerType_, ncols_, static_cast<unsigned char> (0));
    11841184  }
    11851185
     
    12891289  }
    12901290  if (numberIntegers)
    1291     si->copyInIntegerInformation((const char *) integerType_);
     1291    si->copyInIntegerInformation(reinterpret_cast<const char *> (integerType_));
    12921292  else
    12931293    si->copyInIntegerInformation(NULL);
  • trunk/Clp/src/ClpPrimalColumnSteepest.cpp

    r1197 r1321  
    242242      int numberColumns = model_->numberColumns();
    243243      int numberHiddenRows = model_->clpMatrix()->hiddenRows();
    244       double ratio = (double) (sizeFactorization_+numberHiddenRows)/
    245         (double) (numberRows + 2*numberHiddenRows);
     244      double ratio = static_cast<double> (sizeFactorization_+numberHiddenRows)/
     245        static_cast<double> (numberRows + 2*numberHiddenRows);
    246246      // Number of dual infeasibilities at last invert
    247247      int numberDual = model_->numberDualInfeasibilities();
     
    381381    int numberRows = model_->numberRows();
    382382    // ratio is done on number of columns here
    383     //double ratio = (double) sizeFactorization_/(double) numberColumns;
    384     double ratio = (double) sizeFactorization_/(double) numberRows;
    385     //double ratio = (double) sizeFactorization_/(double) model_->clpMatrix()->getNumElements();
     383    //double ratio = static_cast<double> sizeFactorization_/static_cast<double> numberColumns;
     384    double ratio = static_cast<double> (sizeFactorization_)/static_cast<double> (numberRows);
     385    //double ratio = static_cast<double> sizeFactorization_/static_cast<double> model_->clpMatrix()->getNumElements();
    386386    if (ratio<1.0) {
    387387      numberWanted = CoinMax(100,number/200);
     
    406406  int numberRows = model_->numberRows();
    407407  // ratio is done on number of rows here
    408   double ratio = (double) sizeFactorization_/(double) numberRows;
     408  double ratio = static_cast<double> (sizeFactorization_)/static_cast<double> (numberRows);
    409409  if(switchType==4) {
    410410    // Still in devex mode
     
    454454          numberWanted=number+1;
    455455        } else {
    456           numberWanted = CoinMax(2000,(int) ratio);
     456          numberWanted = CoinMax(2000,static_cast<int> (ratio));
    457457          numberWanted = CoinMax(numberWanted,numberColumns/10);
    458458        }
     
    517517  start[1]=number;
    518518  start[2]=0;
    519   double dstart = ((double) number) * model_->randomNumberGenerator()->randomDouble();
    520   start[0]=(int) dstart;
     519  double dstart = static_cast<double> (number) * model_->randomNumberGenerator()->randomDouble();
     520  start[0]=static_cast<int> (dstart);
    521521  start[3]=start[0];
    522522  //double largestWeight=0.0;
     
    24062406    int numberRows = model_->numberRows();
    24072407    // ratio is done on number of columns here
    2408     //double ratio = (double) sizeFactorization_/(double) numberColumns;
    2409     double ratio = (double) sizeFactorization_/(double) numberRows;
    2410     //double ratio = (double) sizeFactorization_/(double) model_->clpMatrix()->getNumElements();
     2408    //double ratio = static_cast<double> sizeFactorization_/static_cast<double> numberColumns;
     2409    double ratio = static_cast<double> (sizeFactorization_)/static_cast<double> (numberRows);
     2410    //double ratio = static_cast<double> sizeFactorization_/static_cast<double> model_->clpMatrix()->getNumElements();
    24112411    if (ratio<0.1) {
    24122412      numberWanted = CoinMax(100,number/200);
     
    24342434    int numberRows = model_->numberRows();
    24352435    // ratio is done on number of rows here
    2436     double ratio = (double) sizeFactorization_/(double) numberRows;
     2436    double ratio = static_cast<double> (sizeFactorization_)/static_cast<double> (numberRows);
    24372437    // Go to steepest if lot of iterations?
    24382438    if (ratio<1.0) {
     
    24662466      numberWanted = CoinMax(2000,number/8);
    24672467    } else {
    2468       double ratio = (double) sizeFactorization_/(double) model_->numberRows();
     2468      double ratio = static_cast<double> (sizeFactorization_)/static_cast<double> (model_->numberRows());
    24692469      if (ratio<1.0) {
    24702470        numberWanted = CoinMax(2000,number/20);
     
    24802480          numberWanted=number+1;
    24812481        } else {
    2482           numberWanted = CoinMax(2000,(int) ratio);
     2482          numberWanted = CoinMax(2000,static_cast<int> (ratio));
    24832483          numberWanted = CoinMax(numberWanted,numberColumns/10);
    24842484        }
     
    26832683  start[1]=number;
    26842684  start[2]=0;
    2685   double dstart = ((double) number) * model_->randomNumberGenerator()->randomDouble();
    2686   start[0]=(int) dstart;
     2685  double dstart = static_cast<double> (number) * model_->randomNumberGenerator()->randomDouble();
     2686  start[0]=static_cast<int> (dstart);
    26872687  start[3]=start[0];
    26882688  //double largestWeight=0.0;
     
    36053605  startR[2]=0;
    36063606  double randomR = model_->randomNumberGenerator()->randomDouble();
    3607   double dstart = ((double) nSlacks) * randomR;
    3608   startR[0]=(int) dstart;
     3607  double dstart = static_cast<double> (nSlacks) * randomR;
     3608  startR[0]=static_cast<int> (dstart);
    36093609  startR[3]=startR[0];
    36103610  double startC[4];
     
    37363736      // If we put this idea back then each function needs to update endFraction **
    37373737#if 0
    3738       double dchunk = ((double) chunk)/((double) numberColumns);
     3738      double dchunk = (static_cast<double> chunk)/(static_cast<double> numberColumns);
    37393739      double end = CoinMin(startC[iPassC+1],start+dchunk);;
    37403740#else
     
    37433743      model_->clpMatrix()->partialPricing(model_,start,end,bestSequence,numberWanted);
    37443744      numberWanted=model_->clpMatrix()->currentWanted();
    3745       numberLook -= (int) ((end-start)*numberColumns);
     3745      numberLook -= static_cast<int> ((end-start)*numberColumns);
    37463746      if (numberLook<0&&(10*(saveNumberWanted-numberWanted)>saveNumberWanted))
    37473747        numberWanted=0; // give up
  • trunk/Clp/src/ClpSimplex.cpp

    r1305 r1321  
    4141
    4242  ClpModel(emptyMessages),
    43   columnPrimalInfeasibility_(0.0),
    44   rowPrimalInfeasibility_(0.0),
     43  bestPossibleImprovement_(0.0),
     44  zeroTolerance_(1.0e-13),
    4545  columnPrimalSequence_(-2),
    4646  rowPrimalSequence_(-2),
     
    124124  allowedInfeasibility_(10.0),
    125125  automaticScale_(0),
     126  maximumPerturbationSize_(0),
     127  perturbationArray_(NULL),
    126128  baseModel_(NULL)
    127129{
     
    155157  : ClpModel(rhs, numberRows, whichRow,
    156158             numberColumns,whichColumn,dropNames,dropIntegers),
    157     columnPrimalInfeasibility_(0.0),
    158     rowPrimalInfeasibility_(0.0),
     159    bestPossibleImprovement_(0.0),
     160    zeroTolerance_(1.0e-13),
    159161    columnPrimalSequence_(-2),
    160162    rowPrimalSequence_(-2),
     
    238240  allowedInfeasibility_(10.0),
    239241    automaticScale_(0),
     242  maximumPerturbationSize_(0),
     243  perturbationArray_(NULL),
    240244  baseModel_(NULL)
    241245{
     
    306310  : ClpModel(rhs, numberRows, whichRow,
    307311             numberColumns,whichColumn,dropNames,dropIntegers),
    308     columnPrimalInfeasibility_(0.0),
    309     rowPrimalInfeasibility_(0.0),
     312    bestPossibleImprovement_(0.0),
     313    zeroTolerance_(1.0e-13),
    310314    columnPrimalSequence_(-2),
    311315    rowPrimalSequence_(-2),
     
    389393  allowedInfeasibility_(10.0),
    390394    automaticScale_(0),
     395  maximumPerturbationSize_(0),
     396  perturbationArray_(NULL),
    391397  baseModel_(NULL)
    392398{
     
    452458    }
    453459    delete [] solution;
    454   } 
     460  }
     461  if (rhs->maximumPerturbationSize_) {
     462    maximumPerturbationSize_ = 2*numberColumns;
     463    perturbationArray_ = new double [maximumPerturbationSize_];
     464    for (i=0;i<numberColumns;i++) {
     465      int iColumn = whichColumn[i];
     466      perturbationArray_[2*i]=rhs->perturbationArray_[2*iColumn];
     467      perturbationArray_[2*i+1]=rhs->perturbationArray_[2*iColumn+1];
     468    }
     469  }
    455470}
    456471// Puts solution back small model
     
    649664      <<largestDualError_
    650665      <<CoinMessageEol;
     666  if (largestPrimalError_>1.0e-1&&numberRows_>100&&numberIterations_) {
     667      // Change factorization tolerance
     668    if (factorization_->zeroTolerance()>1.0e-18)
     669      factorization_->zeroTolerance(1.0e-18);
     670  }
    651671  // Switch off false values pass indicator
    652672  if (!valuesPass&&algorithm_>0)
     
    15311551        }
    15321552        totalSlacks=numberBasic;
     1553#if 0
    15331554        for (iColumn=0;iColumn<numberColumns_;iColumn++) {
    15341555          if (getColumnStatus(iColumn)==basic)
    15351556            numberBasic++;
    15361557        }
     1558#endif
    15371559      } else {
    15381560        // all slack basis
     
    17271749          int * numberUnsatisfied;
    17281750        } clpSolution;
    1729         clpSolution * solution = (clpSolution *) trustedUserPointer_->data;
     1751        clpSolution * solution = reinterpret_cast<clpSolution *> (trustedUserPointer_->data);
    17301752        if (solution->numberSolutions==solution->maximumSolutions) {
    17311753          int n =  solution->maximumSolutions;
     
    18091831    progress_.startCheck();
    18101832    double random = randomNumberGenerator_.randomDouble();
    1811     int extra = (int) (9.999*random);
     1833    int extra = static_cast<int> (9.999*random);
    18121834    int off[]={1,1,1,1,2,2,2,3,3,4};
    18131835    if (factorization_->pivots()>cycle) {
     
    18801902ClpSimplex::ClpSimplex(const ClpSimplex &rhs,int scalingMode) :
    18811903  ClpModel(rhs,scalingMode),
    1882   columnPrimalInfeasibility_(0.0),
    1883   rowPrimalInfeasibility_(0.0),
     1904  bestPossibleImprovement_(0.0),
     1905  zeroTolerance_(1.0e-13),
    18841906  columnPrimalSequence_(-2),
    18851907  rowPrimalSequence_(-2),
     
    19631985  allowedInfeasibility_(10.0),
    19641986  automaticScale_(0),
     1987  maximumPerturbationSize_(0),
     1988  perturbationArray_(NULL),
    19651989  baseModel_(NULL)
    19661990{
     
    19872011ClpSimplex::ClpSimplex(const ClpModel &rhs, int scalingMode) :
    19882012  ClpModel(rhs,scalingMode),
    1989   columnPrimalInfeasibility_(0.0),
    1990   rowPrimalInfeasibility_(0.0),
     2013  bestPossibleImprovement_(0.0),
     2014  zeroTolerance_(1.0e-13),
    19912015  columnPrimalSequence_(-2),
    19922016  rowPrimalSequence_(-2),
     
    20702094  allowedInfeasibility_(10.0),
    20712095  automaticScale_(0),
     2096  maximumPerturbationSize_(0),
     2097  perturbationArray_(NULL),
    20722098  baseModel_(NULL)
    20732099{
     
    21932219    factorization_=NULL;
    21942220  }
    2195   columnPrimalInfeasibility_ = rhs.columnPrimalInfeasibility_;
     2221  bestPossibleImprovement_ = rhs.bestPossibleImprovement_;
    21962222  columnPrimalSequence_ = rhs.columnPrimalSequence_;
    2197   rowPrimalInfeasibility_ = rhs.rowPrimalInfeasibility_;
     2223  zeroTolerance_ = rhs.zeroTolerance_;
    21982224  rowPrimalSequence_ = rhs.rowPrimalSequence_;
    21992225  columnDualInfeasibility_ = rhs.columnDualInfeasibility_;
     
    22502276  allowedInfeasibility_ = rhs.allowedInfeasibility_;
    22512277  automaticScale_ = rhs.automaticScale_;
     2278  maximumPerturbationSize_ = rhs.maximumPerturbationSize_;
     2279  if (maximumPerturbationSize_&&maximumPerturbationSize_>=2*numberColumns_) {
     2280    perturbationArray_ = CoinCopyOfArray(rhs.perturbationArray_,
     2281                                         maximumPerturbationSize_);
     2282  } else {
     2283    maximumPerturbationSize_ = 0;
     2284    perturbationArray_ = NULL;
     2285  }
    22522286  if (rhs.baseModel_) {
    22532287    baseModel_ = new ClpSimplex(*rhs.baseModel_);
     
    23312365    delete baseModel_;
    23322366    baseModel_=NULL;
     2367    delete [] perturbationArray_;
     2368    perturbationArray_ = NULL;
     2369    maximumPerturbationSize_ = 0;
    23332370  } else {
    23342371    // delete any size information in methods
     
    24432480  int firstFreeDual = -1;
    24442481  int numberSuperBasicWithDj=0;
    2445   double relaxedTolerance=dualTolerance_;
     2482  bestPossibleImprovement_=0.0;
    24462483  // we can't really trust infeasibilities if there is dual error
    24472484  double error = CoinMin(1.0e-2,largestDualError_);
    24482485  // allow tolerance at least slightly bigger than standard
    2449   relaxedTolerance = relaxedTolerance +  error;
     2486  double relaxedTolerance = dualTolerance_ +  error;
     2487  // allow bigger tolerance for possible improvement
     2488  double possTolerance = 5.0*relaxedTolerance;
    24502489  sumOfRelaxedDualInfeasibilities_ = 0.0;
    24512490
     
    24812520              numberDualInfeasibilitiesWithoutFree_ ++;
    24822521              sumDualInfeasibilities_ += value-dualTolerance_;
     2522              if (value>possTolerance)
     2523                bestPossibleImprovement_ += distanceUp*value;
    24832524              if (value>relaxedTolerance)
    24842525                sumOfRelaxedDualInfeasibilities_ += value-relaxedTolerance;
     
    24892530              if (value>dualTolerance_) {
    24902531                sumDualInfeasibilities_ += value-dualTolerance_;
     2532                if (value>possTolerance)
     2533                  bestPossibleImprovement_=1.0e100;
    24912534                if (value>relaxedTolerance)
    24922535                  sumOfRelaxedDualInfeasibilities_ += value-relaxedTolerance;
     
    25032546          if (value>dualTolerance_) {
    25042547            sumDualInfeasibilities_ += value-dualTolerance_;
     2548            if (value>possTolerance)
     2549              bestPossibleImprovement_+= value*distanceDown;
    25052550            if (value>relaxedTolerance)
    25062551              sumOfRelaxedDualInfeasibilities_ += value-relaxedTolerance;
     
    25372582          if (value>dualTolerance_) {
    25382583            sumDualInfeasibilities_ += value-dualTolerance_;
     2584            if (value>possTolerance)
     2585              bestPossibleImprovement_+= value*distanceUp;
    25392586            if (value>relaxedTolerance)
    25402587              sumOfRelaxedDualInfeasibilities_ += value-relaxedTolerance;
     
    25512598          if (value>dualTolerance_) {
    25522599            sumDualInfeasibilities_ += value-dualTolerance_;
     2600            if (value>possTolerance)
     2601              bestPossibleImprovement_+= value*distanceDown;
    25532602            if (value>relaxedTolerance)
    25542603              sumOfRelaxedDualInfeasibilities_ += value-relaxedTolerance;
     
    26032652  // allow tolerance at least slightly bigger than standard
    26042653  relaxedToleranceD = relaxedToleranceD +  error;
     2654  // allow bigger tolerance for possible improvement
     2655  double possTolerance = 5.0*relaxedToleranceD;
    26052656  sumOfRelaxedDualInfeasibilities_ = 0.0;
     2657  bestPossibleImprovement_=0.0;
    26062658
    26072659  // Check any infeasibilities from dynamic rows
     
    26452697          if (distanceUp>primalTolerance&&djValue<-dualTolerance) {
    26462698            sumDualInfeasibilities_ -= djValue+dualTolerance;
     2699            if (djValue<-possTolerance)
     2700              bestPossibleImprovement_ -= distanceUp*djValue;
    26472701            if (djValue<-relaxedToleranceD)
    26482702              sumOfRelaxedDualInfeasibilities_ -= djValue+relaxedToleranceD;
     
    26522706          if (djValue>dualTolerance) {
    26532707            sumDualInfeasibilities_ += djValue-dualTolerance;
     2708            if (djValue>possTolerance)
     2709              bestPossibleImprovement_ += distanceDown*djValue;
    26542710            if (djValue>relaxedToleranceD)
    26552711              sumOfRelaxedDualInfeasibilities_ += djValue-relaxedToleranceD;
     
    26632719              numberDualInfeasibilitiesFree++;
    26642720            sumDualInfeasibilities_ += fabs(djValue)-dualTolerance;
     2721            bestPossibleImprovement_=1.0e100;
    26652722            numberDualInfeasibilities_ ++;
    26662723            if (fabs(djValue)>relaxedToleranceD) {
     
    55465603      As far as I can see this is perfectly safe.
    55475604  */
    5548   int returnCode = ((ClpSimplexDual *) this)->dual(ifValuesPass, startFinishOptions);
     5605#ifdef COIN_DEVELOP
     5606#define EXPENSIVE
     5607#endif
     5608#ifdef EXPENSIVE
     5609  static int dualCount=0;
     5610  static int dualCheckCount=-1;
     5611  dualCount++;
     5612  if (dualCount==dualCheckCount) {
     5613    printf("Bad dual coming up\n");
     5614  }
     5615  ClpSimplex saveModel=*this;
     5616#endif
     5617  int returnCode = static_cast<ClpSimplexDual *> (this)->dual(ifValuesPass, startFinishOptions);
     5618#ifdef EXPENSIVE
     5619  if (problemStatus_==1) {
     5620    saveModel.allSlackBasis(true);
     5621    static_cast<ClpSimplexDual *> (&saveModel)->dual(0,0);
     5622    if (saveModel.problemStatus_==0) {
     5623      if (saveModel.objectiveValue()<dblParam_[0]-1.0e-8*(1.0+fabs(dblParam_[0]))) {
     5624        if (objectiveValue()<dblParam_[0]-1.0e-6*(1.0+fabs(dblParam_[0]))) {
     5625          printf("BAD dual - objs %g ,savemodel %g cutoff %g at count %d\n",
     5626                 objectiveValue(),saveModel.objectiveValue(),dblParam_[0],dualCount);
     5627          saveModel=*this;
     5628          saveModel.setLogLevel(63);
     5629          static_cast<ClpSimplexDual *> (&saveModel)->dual(0,0);
     5630          // flatten solution and try again
     5631          int iRow,iColumn;
     5632          for (iRow=0;iRow<numberRows_;iRow++) {
     5633            if (getRowStatus(iRow)!=basic) {
     5634              setRowStatus(iRow,superBasic);
     5635              // but put to bound if close
     5636              if (fabs(rowActivity_[iRow]-rowLower_[iRow])
     5637                  <=primalTolerance_) {
     5638                rowActivity_[iRow]=rowLower_[iRow];
     5639                setRowStatus(iRow,atLowerBound);
     5640              } else if (fabs(rowActivity_[iRow]-rowUpper_[iRow])
     5641                         <=primalTolerance_) {
     5642                rowActivity_[iRow]=rowUpper_[iRow];
     5643                setRowStatus(iRow,atUpperBound);
     5644              }
     5645            }
     5646          }
     5647          for (iColumn=0;iColumn<numberColumns_;iColumn++) {
     5648            if (getColumnStatus(iColumn)!=basic) {
     5649              setColumnStatus(iColumn,superBasic);
     5650              // but put to bound if close
     5651              if (fabs(columnActivity_[iColumn]-columnLower_[iColumn])
     5652                  <=primalTolerance_) {
     5653                columnActivity_[iColumn]=columnLower_[iColumn];
     5654                setColumnStatus(iColumn,atLowerBound);
     5655              } else if (fabs(columnActivity_[iColumn]
     5656                              -columnUpper_[iColumn])
     5657                         <=primalTolerance_) {
     5658                columnActivity_[iColumn]=columnUpper_[iColumn];
     5659                setColumnStatus(iColumn,atUpperBound);
     5660              }
     5661            }
     5662          }
     5663          static_cast<ClpSimplexPrimal *> (&saveModel)->primal(0,0);
     5664        } else {
     5665          printf("bad? dual - objs %g ,savemodel %g cutoff %g at count %d\n",
     5666                 objectiveValue(),saveModel.objectiveValue(),dblParam_[0],dualCount);
     5667        }
     5668        if (dualCount>dualCheckCount&&dualCheckCount>=0)
     5669          abort();
     5670      }
     5671    }
     5672  }
     5673#endif
    55495674  //int lastAlgorithm = -1;
    55505675  if ((specialOptions_&2048)!=0&&problemStatus_==10&&!numberPrimalInfeasibilities_
     
    55815706    baseIteration_=numberIterations_;
    55825707    if ((matrix_->generalExpanded(this,4,dummy)&1)!=0)
    5583       returnCode = ((ClpSimplexPrimal *) this)->primal(1,startFinishOptions);
     5708      returnCode = static_cast<ClpSimplexPrimal *> (this)->primal(1,startFinishOptions);
    55845709    else
    5585       returnCode = ((ClpSimplexDual *) this)->dual(0,startFinishOptions);
     5710      returnCode = static_cast<ClpSimplexDual *> (this)->dual(0,startFinishOptions);
    55865711    baseIteration_=0;
    55875712    if (saveObjective != objective_) {
     
    55915716      if (!problemStatus_) {
    55925717        // carry on
    5593         returnCode = ((ClpSimplexPrimal *) this)->primal(1,startFinishOptions);
     5718        returnCode = static_cast<ClpSimplexPrimal *> (this)->primal(1,startFinishOptions);
    55945719      }
    55955720    }
     
    56375762      perturbation_=savePerturbation;
    56385763      baseIteration_=numberIterations_;
    5639       returnCode = ((ClpSimplexPrimal *) this)->primal(0);
     5764      returnCode = static_cast<ClpSimplexPrimal *> (this)->primal(0);
    56405765      baseIteration_=0;
    56415766      computeObjectiveValue();
     
    56975822      As far as I can see this is perfectly safe.
    56985823  */
    5699   int returnCode = ((ClpSimplexPrimal *) this)->primal(ifValuesPass,startFinishOptions);
     5824  int returnCode = static_cast<ClpSimplexPrimal *> (this)->primal(ifValuesPass,startFinishOptions);
    57005825  //int lastAlgorithm=1;
    57015826  if (problemStatus_==10) {
     
    57145839      // upperOut_ has largest away from bound
    57155840      dualBound_=CoinMin(CoinMax(2.0*upperOut_,1.0e8),dualBound_);
    5716       returnCode = ((ClpSimplexDual *) this)->dual(0,startFinishOptions);
     5841      returnCode = static_cast<ClpSimplexDual *> (this)->dual(0,startFinishOptions);
    57175842      dualBound_=saveBound;
    57185843    } else {
    5719       returnCode = ((ClpSimplexPrimal *) this)->primal(0,startFinishOptions);
     5844      returnCode = static_cast<ClpSimplexPrimal *> (this)->primal(0,startFinishOptions);
    57205845    }
    57215846    baseIteration_=0;
     
    57515876  int savePerturbation = perturbation_;
    57525877  perturbation_=100;
    5753   int returnCode = ((ClpSimplexPrimal *) this)->primal(0,1);
     5878  int returnCode = static_cast<ClpSimplexPrimal *> (this)->primal(0,1);
    57545879  if (problemStatus_==10) {
    57555880    //printf("Cleaning up with dual\n");
     
    57645889      if (upperOut_>0.0)
    57655890        dualBound_=2.0*upperOut_;
    5766       returnCode = ((ClpSimplexDual *) this)->dual(0,1);
     5891      returnCode = static_cast<ClpSimplexDual *> (this)->dual(0,1);
    57675892      dualBound_=saveBound;
    57685893    } else {
    5769       returnCode = ((ClpSimplexPrimal *) this)->primal(0,1);
     5894      returnCode = static_cast<ClpSimplexPrimal *> (this)->primal(0,1);
    57705895    }
    57715896    setInitialDenseFactorization(denseFactorization);
     
    57785903    return 1; // odd status
    57795904  }
    5780   ((ClpSimplexOther *) this)->dualRanging(numberCheck,which,
     5905  static_cast<ClpSimplexOther *> (this)->dualRanging(numberCheck,which,
    57815906                                          costIncrease,sequenceIncrease,
    57825907                                          costDecrease,sequenceDecrease,
     
    58015926  int savePerturbation = perturbation_;
    58025927  perturbation_=100;
    5803   int returnCode = ((ClpSimplexPrimal *) this)->primal(0,1);
     5928  int returnCode = static_cast<ClpSimplexPrimal *> (this)->primal(0,1);
    58045929  if (problemStatus_==10) {
    58055930    //printf("Cleaning up with dual\n");
     
    58145939      if (upperOut_>0.0)
    58155940        dualBound_=2.0*upperOut_;
    5816       returnCode = ((ClpSimplexDual *) this)->dual(0,1);
     5941      returnCode = static_cast<ClpSimplexDual *> (this)->dual(0,1);
    58175942      dualBound_=saveBound;
    58185943    } else {
    5819       returnCode = ((ClpSimplexPrimal *) this)->primal(0,1);
     5944      returnCode = static_cast<ClpSimplexPrimal *> (this)->primal(0,1);
    58205945    }
    58215946    setInitialDenseFactorization(denseFactorization);
     
    58285953    return 1; // odd status
    58295954  }
    5830   ((ClpSimplexOther *) this)->primalRanging(numberCheck,which,
     5955  static_cast<ClpSimplexOther *> (this)->primalRanging(numberCheck,which,
    58315956                                          valueIncrease,sequenceIncrease,
    58325957                                          valueDecrease,sequenceDecrease);
     
    58535978                            int formatType) const
    58545979{
    5855   return ((const ClpSimplexOther *) this)->writeBasis(filename,writeValues,
     5980  return static_cast<const ClpSimplexOther *> (this)->writeBasis(filename,writeValues,
    58565981                                         formatType);
    58575982}
     
    58605985ClpSimplex::readBasis(const char *filename)
    58615986{
    5862   return ((ClpSimplexOther *) this)->readBasis(filename);
     5987  return static_cast<ClpSimplexOther *> (this)->readBasis(filename);
    58635988}
    58645989#include "ClpSimplexNonlinear.hpp"
     
    58695994ClpSimplex::nonlinearSLP(int numberPasses, double deltaTolerance)
    58705995{
    5871   return ((ClpSimplexNonlinear *) this)->primalSLP(numberPasses,deltaTolerance);
     5996  return static_cast<ClpSimplexNonlinear *> (this)->primalSLP(numberPasses,deltaTolerance);
    58725997}
    58735998/* Solves problem with nonlinear constraints using SLP - may be used as crash
     
    58806005                   int numberPasses,double deltaTolerance)
    58816006{
    5882   return ((ClpSimplexNonlinear *) this)->primalSLP(numberConstraints,constraints,numberPasses,deltaTolerance);
     6007  return static_cast<ClpSimplexNonlinear *> (this)->primalSLP(numberConstraints,constraints,numberPasses,deltaTolerance);
    58836008}
    58846009// Solves non-linear using reduced gradient
     
    59026027  }
    59036028  // Now enter method
    5904   int returnCode = ((ClpSimplexNonlinear *) this)->primal();
     6029  int returnCode = static_cast<ClpSimplexNonlinear *> (this)->primal();
    59056030  return returnCode;
    59066031}
     
    60596184      delete [] dsort;
    60606185    }
    6061     if (gap<1.0e-3*((double) (numberRows+numberColumns))) {
     6186    if (gap<1.0e-3*(static_cast<double> (numberRows+numberColumns))) {
    60626187      int numberRows = model2->numberRows();
    60636188      int numberColumns = model2->numberColumns();
     
    61826307                                int startFinishOptions)
    61836308{
    6184   return ((ClpSimplexDual *) this)->strongBranching(numberVariables,variables,
     6309  return static_cast<ClpSimplexDual *> (this)->strongBranching(numberVariables,variables,
    61856310                                                    newLower,  newUpper,outputSolution,
    61866311                                                    outputStatus, outputIterations,
     
    62186343  moreSpecialOptions_ = otherModel.moreSpecialOptions_;
    62196344  automaticScale_ = otherModel.automaticScale_;
     6345  maximumPerturbationSize_ = otherModel.maximumPerturbationSize_;
     6346  perturbationArray_ = otherModel.perturbationArray_;
    62206347}
    62216348/// Saves scalars for ClpSimplex
     
    63796506        new char[CoinMax(numberRows_,numberColumns_)*(lengthNames_+1)];
    63806507      char * put = array;
    6381       CoinAssert (numberRows_ == (int) rowNames_.size());
     6508      CoinAssert (numberRows_ == static_cast<int> (rowNames_.size()));
    63826509      for (i=0;i<numberRows_;i++) {
    6383         assert((int)rowNames_[i].size()<=lengthNames_);
     6510        assert(static_cast<int>(rowNames_[i].size())<=lengthNames_);
    63846511        strcpy(put,rowNames_[i].c_str());
    63856512        put += lengthNames_+1;
     
    63896516        return 1;
    63906517      put=array;
    6391       CoinAssert (numberColumns_ == (int) columnNames_.size());
     6518      CoinAssert (numberColumns_ == static_cast<int> (columnNames_.size()));
    63926519      for (i=0;i<numberColumns_;i++) {
    6393         assert((int) columnNames_[i].size()<=lengthNames_);
     6520        assert(static_cast<int> (columnNames_[i].size())<=lengthNames_);
    63946521        strcpy(put,columnNames_[i].c_str());
    63956522        put += lengthNames_+1;
     
    71227249    const char * name = m.rowName(iRow);
    71237250    if (name) {
    7124       maxLength = CoinMax(maxLength,(unsigned int) strlen(name));
     7251      maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(name)));
    71257252      rowNames_.push_back(name);
    71267253    } else {
     
    71347261    const char * name = m.columnName(iColumn);
    71357262    if (name) {
    7136       maxLength = CoinMax(maxLength,(unsigned int) strlen(name));
     7263      maxLength = CoinMax(maxLength,static_cast<unsigned int> (strlen(name)));
    71377264      columnNames_.push_back(name);
    71387265    } else {
     
    71407267    }
    71417268  }
    7142   lengthNames_=(int) maxLength;
     7269  lengthNames_=static_cast<int> (maxLength);
    71437270 
    71447271  return 0;
     
    80468173  dualIn_=dj_[sequenceIn_];
    80478174
    8048   int returnCode = ((ClpSimplexPrimal *) this)->pivotResult();
     8175  int returnCode = static_cast<ClpSimplexPrimal *> (this)->pivotResult();
    80498176  if (returnCode<0&&returnCode>-4) {
    80508177    return 0;
     
    80658192ClpSimplex::dualPivotResult()
    80668193{
    8067   return ((ClpSimplexDual *) this)->pivotResult();
     8194  return static_cast<ClpSimplexDual *> (this)->pivotResult();
    80688195}
    80698196// Factorization frequency
     
    81778304      if (perturbation_<100) {
    81788305        if (algorithm_>0&&(objective_->type()<2||!objective_->activated())) {
    8179           ((ClpSimplexPrimal *) this)->perturb(0);
     8306          static_cast<ClpSimplexPrimal *> (this)->perturb(0);
    81808307        } else if (algorithm_<0) {
    8181         ((ClpSimplexDual *) this)->perturb();
     8308          static_cast<ClpSimplexDual *> (this)->perturb();
    81828309        }
    81838310      }
     
    83308457  saved.sparseThreshold_ = factorization_->sparseThreshold();
    83318458  saved.pivotTolerance_ = factorization_->pivotTolerance();
     8459  saved.zeroFactorizationTolerance_ = factorization_->zeroTolerance();
     8460  saved.zeroSimplexTolerance_=zeroTolerance_;
    83328461  saved.perturbation_ = perturbation_;
    83338462  saved.forceFactorization_=forceFactorization_;
     
    83448473  //factorization_->sparseThreshold(saved.sparseThreshold_);
    83458474  factorization_->pivotTolerance(saved.pivotTolerance_);
     8475  factorization_->zeroTolerance(saved.zeroFactorizationTolerance_);
     8476  zeroTolerance_ = saved.zeroSimplexTolerance_;
    83468477  perturbation_ = saved.perturbation_;
    83478478  infeasibilityCost_ = saved.infeasibilityCost_;
     
    84208551{
    84218552  ClpModel::returnModel(otherModel);
    8422   otherModel.columnPrimalInfeasibility_ = columnPrimalInfeasibility_;
     8553  otherModel.bestPossibleImprovement_ = bestPossibleImprovement_;
    84238554  otherModel.columnPrimalSequence_ = columnPrimalSequence_;
    8424   otherModel.rowPrimalInfeasibility_ = rowPrimalInfeasibility_;
     8555  otherModel.zeroTolerance_ = zeroTolerance_;
    84258556  otherModel.rowPrimalSequence_ = rowPrimalSequence_;
    84268557  otherModel.columnDualInfeasibility_ = columnDualInfeasibility_;
     
    84588589  otherModel.sumOfRelaxedDualInfeasibilities_ = sumOfRelaxedDualInfeasibilities_;
    84598590  otherModel.sumOfRelaxedPrimalInfeasibilities_ = sumOfRelaxedPrimalInfeasibilities_;
     8591  if (perturbationArray_ != otherModel.perturbationArray_)
     8592    delete [] perturbationArray_;
     8593  perturbationArray_ = NULL;
     8594 
    84608595}
    84618596/* Constructs a non linear cost from list of non-linearities (columns only)
     
    86028737#endif
    86038738  // Save mapping somewhere - doesn't matter
    8604   rowUpper_ = (double *) mapping;
     8739  rowUpper_ = reinterpret_cast<double *> (mapping);
    86058740  upper_ = wholeModel->upper_;
    86068741  wholeModel->upper_ = new double [numberTotal];
     
    87358870  // copy back
    87368871  int iColumn;
    8737   int * mapping = (int *) miniModel->rowUpper_;
     8872  int * mapping = reinterpret_cast<int *> (miniModel->rowUpper_);
    87388873#ifdef CLP_DEBUG
    87398874  for (iColumn=0;iColumn<numberRows_+numberColumns_;iColumn++)
     
    98179952      int iStatus = getRowStatus(iRow);
    98189953      iStatus = lookupA[iStatus];
    9819       basis->setArtifStatus(iRow,(CoinWarmStartBasis::Status) iStatus);
     9954      basis->setArtifStatus(iRow,static_cast<CoinWarmStartBasis::Status> (iStatus));
    98209955    }
    98219956    int lookupS[]={0,1,2,3,0,3};
     
    98239958      int iStatus = getColumnStatus(iColumn);
    98249959      iStatus = lookupS[iStatus];
    9825       basis->setStructStatus(iColumn,(CoinWarmStartBasis::Status) iStatus);
     9960      basis->setStructStatus(iColumn,static_cast<CoinWarmStartBasis::Status> (iStatus));
    98269961    }
    98279962  }
     
    1008710222{
    1008810223  assert (stuff);
    10089   ClpNodeStuff * info = (ClpNodeStuff *) stuff;
     10224  ClpNodeStuff * info = reinterpret_cast<ClpNodeStuff *> (stuff);
    1009010225  info->nNodes_=0;
    1009110226  // say can declare optimal
     
    1013710272    bool tightenBounds = ((specialOptions_&64)==0) ? false : true;
    1013810273    ClpSimplex * small =
    10139       ((ClpSimplexOther *) this)->crunch(rhs,whichRow,whichColumn,
     10274      static_cast<ClpSimplexOther *> (this)->crunch(rhs,whichRow,whichColumn,
    1014010275                                         nBound,false,tightenBounds);
    1014110276    if (small) {
     
    1016310298            info->upPseudo_[k]=info->upPseudo_[j];
    1016410299            info->numberUp_[k]=info->numberUp_[j];
     10300            info->numberUpInfeasible_[k]=info->numberUpInfeasible_[j];
    1016510301            info->downPseudo_[k]=info->downPseudo_[j];
    1016610302            info->numberDown_[k]=info->numberDown_[j];
     10303            info->numberDownInfeasible_[k]=info->numberDownInfeasible_[j];
    1016710304            assert (info->upPseudo_[k]>1.0e-40&&info->upPseudo_[k]<1.0e40);
    1016810305            assert (info->downPseudo_[k]>1.0e-40&&info->downPseudo_[k]<1.0e40);
     
    1023310370            info->upPseudo_[numberIntegers]=info->upPseudo_[k];
    1023410371            info->numberUp_[numberIntegers]=info->numberUp_[k];
     10372            info->numberUpInfeasible_[numberIntegers]=info->numberUpInfeasible_[k];
    1023510373            info->downPseudo_[numberIntegers]=info->downPseudo_[k];
    1023610374            info->numberDown_[numberIntegers]=info->numberDown_[k];
     10375            info->numberDownInfeasible_[numberIntegers]=info->numberDownInfeasible_[k];
    1023710376          }
    1023810377        }
     
    1024110380      if (returnCode) {
    1024210381        //check this does everything
    10243         ((ClpSimplexOther *) this)->afterCrunch(*small,
     10382        static_cast<ClpSimplexOther *> (this)->afterCrunch(*small,
    1024410383                                                whichRow,whichColumn,nBound);
    1024510384        for (int i=0;i<numberColumns_;i++) {
     
    1027010409    return returnCode;
    1027110410  }
     10411  // Get fake bounds correctly
     10412  //(static_cast<ClpSimplexDual *>(this))->resetFakeBounds(1);
    1027210413  gutsOfSolution ( NULL,NULL);
     10414  double dummyChange;
     10415  (static_cast<ClpSimplexDual *>(this))->changeBounds(3,NULL,dummyChange);
     10416  int saveNumberFake = numberFake_;
    1027310417  int status=fastDual2(info);
    1027410418#if 0
     
    1034510489  int maxDepth=0;
    1034610490  int depth=0;
     10491  // Get fake bounds correctly
     10492  (static_cast<ClpSimplexDual *>(this))->changeBounds(3,NULL,dummyChange);
     10493  saveNumberFake = numberFake_;
    1034710494  ClpNode ** nodes = new ClpNode * [maxDepthSize];
    1034810495  int numberTotal = numberRows_+numberColumns_;
     
    1043110578    }
    1043210579#endif
     10580    // Get fake bounds correctly
     10581    (static_cast<ClpSimplexDual *>(this))->changeBounds(3,NULL,dummyChange);
    1043310582    fastDual2(info);
    1043410583#if 0
     
    1061710766      CoinMemcpyN(saveLowerInternal,numberTotal,lower_);
    1061810767      CoinMemcpyN(saveUpperInternal,numberTotal,upper_);
     10768      numberFake_ = saveNumberFake;
    1061910769    }
    1062010770    CoinMemcpyN(saveLower,numberColumns_,columnLower_);
     
    1064310793{
    1064410794  assert (stuff);
    10645   ClpNodeStuff * info = (ClpNodeStuff *) stuff;
     10795  ClpNodeStuff * info = reinterpret_cast<ClpNodeStuff *> (stuff);
    1064610796  int nNodes = info->maximumNodes();
    1064710797  int goodNodes=0;
     
    1070010850    bool tightenBounds = ((specialOptions_&64)==0) ? false : true;
    1070110851    ClpSimplex * small =
    10702       ((ClpSimplexOther *) this)->crunch(rhs,whichRow,whichColumn,
     10852      static_cast<ClpSimplexOther *> (this)->crunch(rhs,whichRow,whichColumn,
    1070310853                                         nBound,false,tightenBounds);
    1070410854    if (small) {
     
    1073010880            info->upPseudo_[k]=info->upPseudo_[j];
    1073110881            info->numberUp_[k]=info->numberUp_[j];
     10882            info->numberUpInfeasible_[k]=info->numberUpInfeasible_[j];
    1073210883            info->downPseudo_[k]=info->downPseudo_[j];
    1073310884            info->numberDown_[k]=info->numberDown_[j];
     10885            info->numberDownInfeasible_[k]=info->numberDownInfeasible_[j];
    1073410886            assert (info->upPseudo_[k]>1.0e-40&&info->upPseudo_[k]<1.0e40);
    1073510887            assert (info->downPseudo_[k]>1.0e-40&&info->downPseudo_[k]<1.0e40);
     
    1078510937            info->upPseudo_[numberIntegers]=info->upPseudo_[k];
    1078610938            info->numberUp_[numberIntegers]=info->numberUp_[k];
     10939            info->numberUpInfeasible_[numberIntegers]=info->numberUpInfeasible_[k];
    1078710940            info->downPseudo_[numberIntegers]=info->downPseudo_[k];
    1078810941            info->numberDown_[numberIntegers]=info->numberDown_[k];
     10942            info->numberDownInfeasible_[numberIntegers]=info->numberDownInfeasible_[k];
    1078910943          }
    1079010944        }
     
    1082910983    status=problemStatus_;
    1083010984  }
    10831   assert (problemStatus_==0||problemStatus_==1);//((ClpSimplexDual *) this)->dual(0,0);
     10985  assert (problemStatus_==0||problemStatus_==1);//(static_cast<ClpSimplexDual *> this)->dual(0,0);
    1083210986  if (problemStatus_==10) {
    1083310987    printf("Cleaning up with primal - need coding without createRim!\n");
     
    1111611270              }
    1111711271            }
    11118             ((ClpSimplexOther *) info->large_)->afterCrunch(*this,
     11272            static_cast<ClpSimplexOther *> (info->large_)->afterCrunch(*this,
    1111911273                       info->whichRow_,info->whichColumn_,info->nBound_);
    1112011274            // do as for large
     
    1115811312                       node->dualSolution()[i]);
    1115911313#endif
    11160             ((ClpSimplexOther *) info->large_)->afterCrunch(*this,
     11314            static_cast<ClpSimplexOther *> (info->large_)->afterCrunch(*this,
    1116111315                       info->whichRow_,info->whichColumn_,info->nBound_);
    1116211316#ifdef CHECK_PATH
     
    1134811502  specialOptions_ |= 524288; // say use solution
    1134911503  ClpObjective * saveObjective = objective_;
    11350   int status = ((ClpSimplexDual *) this)->fastDual(true);
     11504#ifndef NDEBUG
     11505  (static_cast<ClpSimplexDual *>(this))->resetFakeBounds(-1);
     11506#endif
     11507  //int saveNumberFake = numberFake_;
     11508  int status = static_cast<ClpSimplexDual *> (this)->fastDual(true);
     11509  //numberFake_ = saveNumberFake;
    1135111510  specialOptions_ &= ~524288; // say dont use solution
    1135211511  CoinAssert (problemStatus_||objectiveValue_<1.0e50);
     
    1137611535    // check which algorithms allowed
    1137711536    baseIteration_=numberIterations_;
    11378     status = ((ClpSimplexPrimal *) this)->primal(1,7);
     11537    status = static_cast<ClpSimplexPrimal *> (this)->primal(1,7);
    1137911538    baseIteration_=0;
    1138011539    if (saveObjective != objective_) {
     
    1138411543      if (!problemStatus_) {
    1138511544        // carry on
    11386         status = ((ClpSimplexPrimal *) this)->primal(1,7);
     11545        status = static_cast<ClpSimplexPrimal *> (this)->primal(1,7);
    1138711546      }
    1138811547    }
     
    1141511574      perturbation_=savePerturbation;
    1141611575      baseIteration_=numberIterations_;
    11417       status = ((ClpSimplexPrimal *) this)->primal(0);
     11576      status = static_cast<ClpSimplexPrimal *> (this)->primal(0);
    1141811577      baseIteration_=0;
    1141911578      computeObjectiveValue();
     
    1147711636  save = info->saveCosts_;
    1147811637  CoinMemcpyN(save,numberTotal,cost_);
     11638#if 0
    1147911639  save += numberTotal;
    1148011640  CoinMemcpyN(save,numberTotal,lower_);
    1148111641  save += numberTotal;
    1148211642  CoinMemcpyN(save,numberTotal,upper_);
     11643#endif
    1148311644  return status;
    1148411645}
     
    1151311674    bool tightenBounds = ((specialOptions_&64)==0) ? false : true;
    1151411675    small =
    11515       ((ClpSimplexOther *) this)->crunch(rhs,whichRow,whichColumn,
     11676      static_cast<ClpSimplexOther *> (this)->crunch(rhs,whichRow,whichColumn,
    1151611677                                         nBound,false,tightenBounds);
    1151711678    if (small) {
     
    1153711698            info->upPseudo_[k]=info->upPseudo_[j];
    1153811699            info->numberUp_[k]=info->numberUp_[j];
     11700            info->numberUpInfeasible_[k]=info->numberUpInfeasible_[j];
    1153911701            info->downPseudo_[k]=info->downPseudo_[j];
    1154011702            info->numberDown_[k]=info->numberDown_[j];
     11703            info->numberDownInfeasible_[k]=info->numberDownInfeasible_[j];
    1154111704            assert (info->upPseudo_[k]>1.0e-40&&info->upPseudo_[k]<1.0e40);
    1154211705            assert (info->downPseudo_[k]>1.0e-40&&info->downPseudo_[k]<1.0e40);
     
    1155511718      ClpSimplex * other = info->large_;
    1155611719      assert (other!=this);
    11557       ((ClpSimplexOther *) other)->afterCrunch(*this,
     11720      static_cast<ClpSimplexOther *> (other)->afterCrunch(*this,
    1155811721                                               info->whichRow_,
    1155911722                                               info->whichColumn_,info->nBound_);
  • trunk/Clp/src/ClpSimplex.hpp

    r1311 r1321  
    1919class ClpPrimalColumnPivot;
    2020class ClpFactorization;
     21#include "ClpFactorization.hpp"
    2122class CoinIndexedVector;
    2223class ClpNonLinearCost;
     
    6566  enum FakeBound {
    6667    noFake = 0x00,
    67     bothFake = 0x01,
     68    lowerFake = 0x01,
    6869    upperFake = 0x02,
    69     lowerFake = 0x03
     70    bothFake = 0x03
    7071  };
    7172
     
    709710  /** This sets sum and number of infeasibilities (Dual and Primal) */
    710711  void checkBothSolutions();
     712  /**  If input negative scales objective so maximum <= -value
     713       and returns scale factor used.  If positive unscales and also
     714       redoes dual stuff
     715  */
     716  double scaleObjective(double value);
    711717public:
    712718  /** For advanced use.  When doing iterative solves things can get
     
    754760  inline void setLargestDualError(double value)
    755761          { largestDualError_=value;}
     762  /// Get zero tolerance
     763  inline double zeroTolerance() const
     764  { return zeroTolerance_;/*factorization_->zeroTolerance();*/}
     765  /// Set zero tolerance
     766  inline void setZeroTolerance( double value)
     767  { zeroTolerance_ = value;}
    756768  /// Basic variables pivoting on which rows
    757769  inline int * pivotVariable() const
     
    10181030  /// Progress flag - at present 0 bit says artificials out
    10191031  inline int progressFlag() const
    1020   {return progressFlag_;}
     1032  {return (progressFlag_&3);}
    10211033  /// Force re-factorization early
    10221034  inline void forceFactorization(int value)
     
    11651177  */
    11661178  //@{
    1167   /// Worst column primal infeasibility
    1168   double columnPrimalInfeasibility_;
    1169   /// Worst row primal infeasibility
    1170   double rowPrimalInfeasibility_;
     1179  /** Best possible improvement using djs (primal) or
     1180      obj change by flipping bounds to make dual feasible (dual) */
     1181  double bestPossibleImprovement_;
     1182  /// Zero tolerance
     1183  double zeroTolerance_;
    11711184  /// Sequence of worst (-1 if feasible)
    11721185  int columnPrimalSequence_;
     
    13591372  /// Automatic scaling of objective and rhs and bounds
    13601373  int automaticScale_;
     1374  /// Maximum perturbation array size (take out when code rewritten)
     1375  int maximumPerturbationSize_;
     1376  /// Perturbation array (maximumPerturbationSize_)
     1377  double * perturbationArray_;
    13611378  /// A copy of model with certain state - normally without cuts
    13621379  ClpSimplex * baseModel_;
  • trunk/Clp/src/ClpSimplexDual.cpp

    r1317 r1321  
    102102#include "CoinPackedMatrix.hpp"
    103103#include "CoinIndexedVector.hpp"
     104#include "CoinFloatEqual.hpp"
    104105#include "ClpDualRowDantzig.hpp"
    105106#include "ClpMessage.hpp"
     
    128129#ifndef CLP_AUXILIARY_MODEL
    129130#define auxiliaryModel_ false
     131#endif
     132#ifdef NDEBUG
     133#define NDEBUG_CLP
     134#endif
     135#ifndef CLP_INVESTIGATE
     136#define NDEBUG_CLP
    130137#endif
    131138// dual
     
    311318      // Can't get here if values pass
    312319      gutsOfSolution(NULL,NULL);
    313 #ifdef COIN_DEVELOP
     320#ifdef CLP_INVESTIGATE
    314321      if (numberDualInfeasibilities_)
    315322        printf("ZZZ %d primal %d dual - cost %g\n",
     
    332339        if (numberPrimalInfeasibilities_) {
    333340          usePrimal=perturb();
    334           if (perturbation_>=101)
     341          if (perturbation_>=101) {
    335342            computeDuals(NULL);
    336343          //gutsOfSolution(NULL,NULL);
     344            checkDualSolution(); // recompute objective
     345          }
    337346        } else if (numberDualInfeasibilities_) {
    338347          problemStatus_=10;
     
    368377  finish(startFinishOptions);
    369378}
    370 #ifdef CLP_INVESTIGATE
     379//#define CLP_REPORT_PROGRESS
     380#ifdef CLP_REPORT_PROGRESS
     381static int ixxxxxx=0;
     382static int ixxyyyy=90;
     383#endif
     384#ifdef CLP_INVESTIGATE_SERIAL
    371385static int z_reason[7]={0,0,0,0,0,0,0};
    372386static int z_thinks=-1;
     
    376390                           ClpDataSave & data)
    377391{
    378 #ifdef CLP_INVESTIGATE
     392#ifdef CLP_INVESTIGATE_SERIAL
    379393  z_reason[0]++;
    380394  z_thinks=-1;
     
    390404  // Say change made on first iteration
    391405  changeMade_=1;
     406  // Say last objective infinite
     407  //lastObjectiveValue_=-COIN_DBL_MAX;
     408  progressFlag_ = 0;
    392409  /*
    393410    Status of problem:
     
    507524    // Do iterations
    508525    int returnCode=whileIterating(saveDuals,ifValuesPass);
    509 #ifdef CLP_INVESTIGATE
     526#ifdef CLP_INVESTIGATE_SERIAL
    510527    nPivots=factorization_->pivots();
    511528#endif
     
    515532      factorType=3;
    516533  }
    517 #ifdef CLP_INVESTIGATE
     534#ifdef CLP_INVESTIGATE_SERIAL
    518535  // NOTE - can fail if parallel
    519536  if (z_thinks!=-1) {
     
    812829ClpSimplexDual::whileIterating(double * & givenDuals,int ifValuesPass)
    813830{
    814 #ifdef CLP_INVESTIGATE
     831#ifdef CLP_INVESTIGATE_SERIAL
    815832  z_thinks=-1;
    816833#endif
     
    843860    }   
    844861  }     
     862#ifdef CLP_REPORT_PROGRESS
     863  double * savePSol = new double [numberRows_+numberColumns_];
     864  double * saveDj = new double [numberRows_+numberColumns_];
     865  double * saveCost = new double [numberRows_+numberColumns_];
     866  unsigned char * saveStat = new unsigned char [numberRows_+numberColumns_];
     867#endif
    845868  // if can't trust much and long way from optimal then relax
    846869  if (largestPrimalError_>10.0)
     
    934957#endif
    935958  while (problemStatus_==-1) {
     959    //if (numberIterations_>=101624)
     960    //resetFakeBounds(-1);
    936961#ifdef CLP_DEBUG
    937962    if (givenDuals) {
     
    11441169          columnScale_=saveC;
    11451170        }
     1171#ifdef CLP_REPORT_PROGRESS
     1172        memcpy(savePSol,solution_,(numberColumns_+numberRows_)*sizeof(double));
     1173        memcpy(saveDj,dj_,(numberColumns_+numberRows_)*sizeof(double));
     1174        memcpy(saveCost,cost_,(numberColumns_+numberRows_)*sizeof(double));
     1175        memcpy(saveStat,status_,(numberColumns_+numberRows_)*sizeof(char));
     1176#endif
    11461177        // do ratio test for normal iteration
    11471178        bestPossiblePivot = dualColumn(rowArray_[0],columnArray_[0],rowArray_[3],
     
    14901521        solution_[sequenceOut_]=valueOut_;
    14911522        int whatNext=housekeeping(objectiveChange);
     1523#ifdef CLP_REPORT_PROGRESS
     1524        if (ixxxxxx>ixxyyyy-5) {
     1525          handler_->setLogLevel(63);
     1526          int nTotal = numberColumns_+numberRows_;
     1527          double oldObj=0.0;
     1528          double newObj=0.0;
     1529          for (int i=0;i<nTotal;i++) {
     1530            if (savePSol[i])
     1531              oldObj += savePSol[i]*saveCost[i];
     1532            if (solution_[i])
     1533              newObj += solution_[i]*cost_[i];
     1534            bool printIt=false;
     1535            if (cost_[i]!=saveCost[i])
     1536              printIt=true;
     1537            if (status_[i]!=saveStat[i])
     1538              printIt=true;
     1539            if (printIt)
     1540              printf("%d old %d cost %g sol %g, new %d cost %g sol %g\n",
     1541                     i,saveStat[i],saveCost[i],savePSol[i],
     1542                     status_[i],cost_[i],solution_[i]);
     1543            // difference
     1544            savePSol[i] = solution_[i]-savePSol[i];
     1545          }
     1546          printf("pivots %d, old obj %g new %g\n",
     1547                 factorization_->pivots(),
     1548                 oldObj,newObj);
     1549          memset(saveDj,0,numberRows_*sizeof(double));
     1550          times(1.0,savePSol,saveDj);
     1551          double largest=1.0e-6;
     1552          int k=-1;
     1553          for (int i=0;i<numberRows_;i++) {
     1554            saveDj[i] -= savePSol[i+numberColumns_];
     1555            if (fabs(saveDj[i])>largest) {
     1556              largest = fabs(saveDj[i]);
     1557              k=i;
     1558            }
     1559          }
     1560          if (k>=0)
     1561            printf("Not null %d %g\n",k,largest);
     1562        }
     1563#endif
    14921564#ifdef VUB
    14931565        {
     
    15931665        }
    15941666      } else {
    1595 #ifdef CLP_INVESTIGATE
     1667#ifdef CLP_INVESTIGATE_SERIAL
    15961668        z_thinks=1;
    15971669#endif
     
    17131785      }
    17141786    } else {
    1715 #ifdef CLP_INVESTIGATE
     1787#ifdef CLP_INVESTIGATE_SERIAL
    17161788      z_thinks=0;
    17171789#endif
     
    17791851          if ((specialOptions_&1024)==0)
    17801852            problemStatus_=-5;
     1853          else if (!useNumberFake&&numberPrimalInfeasibilities_
     1854                   &&!numberPivots)
     1855            problemStatus_=1;
    17811856        } else {
    17821857          if (iRow<numberRows_) {
     
    18001875#if CLP_CHECK_NUMBER_PIVOTS < 20
    18011876            if (numberPivots>CLP_CHECK_NUMBER_PIVOTS) {
    1802 #ifndef NDEBUG
     1877#ifndef NDEBUG_CLP
    18031878              int nTotal = numberRows_+numberColumns_;
    18041879              double * comp = CoinCopyOfArray(solution_,nTotal);
    18051880#endif
    18061881              computePrimals(rowActivityWork_,columnActivityWork_);
    1807 #ifndef NDEBUG
     1882#ifndef NDEBUG_CLP
    18081883              double largest=1.0e-5;
    18091884              int bad=-1;
     
    18231898              checkPrimalSolution(rowActivityWork_,columnActivityWork_);
    18241899              if (numberPrimalInfeasibilities_) {
    1825 #ifdef COIN_DEVELOP
     1900#ifdef CLP_INVESTIGATE
    18261901                printf("XXX Infeas ? %d inf summing to %g\n",numberPrimalInfeasibilities_,
    18271902                       sumPrimalInfeasibilities_);
     
    18301905                returnCode=-2;
    18311906              }
    1832 #ifndef NDEBUG
     1907#ifndef NDEBUG_CLP
    18331908              memcpy(solution_,comp,nTotal*sizeof(double));
    18341909              delete [] comp;
     
    18441919              // May be perturbed
    18451920              if (perturbation_==101||numberChanged_) {
     1921                numberChanged_ =0; // Number of variables with changed costs
    18461922                perturbation_=102; // stop any perturbations
    18471923                //double changeCost;
     
    18511927                computeDuals(givenDuals);
    18521928                checkDualSolution();
     1929                progress_.modifyObjective(-COIN_DBL_MAX);
    18531930                if (numberDualInfeasibilities_) {
    18541931                  problemStatus_=10; // was -3;
     
    19612038  }
    19622039  delete [] dubiousWeights;
     2040#ifdef CLP_REPORT_PROGRESS
     2041  if (ixxxxxx>ixxyyyy-5) {
     2042    int nTotal = numberColumns_+numberRows_;
     2043    double oldObj=0.0;
     2044    double newObj=0.0;
     2045    for (int i=0;i<nTotal;i++) {
     2046      if (savePSol[i])
     2047        oldObj += savePSol[i]*saveCost[i];
     2048      if (solution_[i])
     2049        newObj += solution_[i]*cost_[i];
     2050      bool printIt=false;
     2051      if (cost_[i]!=saveCost[i])
     2052        printIt=true;
     2053      if (status_[i]!=saveStat[i])
     2054        printIt=true;
     2055      if (printIt)
     2056        printf("%d old %d cost %g sol %g, new %d cost %g sol %g\n",
     2057               i,saveStat[i],saveCost[i],savePSol[i],
     2058               status_[i],cost_[i],solution_[i]);
     2059      // difference
     2060      savePSol[i] = solution_[i]-savePSol[i];
     2061    }
     2062    printf("exit pivots %d, old obj %g new %g\n",
     2063           factorization_->pivots(),
     2064           oldObj,newObj);
     2065    memset(saveDj,0,numberRows_*sizeof(double));
     2066    times(1.0,savePSol,saveDj);
     2067    double largest=1.0e-6;
     2068    int k=-1;
     2069    for (int i=0;i<numberRows_;i++) {
     2070      saveDj[i] -= savePSol[i+numberColumns_];
     2071      if (fabs(saveDj[i])>largest) {
     2072        largest = fabs(saveDj[i]);
     2073        k=i;
     2074      }
     2075    }
     2076    if (k>=0)
     2077      printf("Not null %d %g\n",k,largest);
     2078  }
     2079  delete [] savePSol ;
     2080  delete [] saveDj ;
     2081  delete [] saveCost ;
     2082  delete [] saveStat ;
     2083#endif
    19632084  return returnCode;
    19642085}
     
    20672188      if (status==atUpperBound) {
    20682189        double movement=0.0;
    2069 
     2190        //#define NO_SWAP7
    20702191        if (value>tolerance) {
    20712192          // to lower bound (if swap)
     
    20762197          outputArray->quickAdd(iSequence,-movement);
    20772198          assert (fabs(movement)<1.0e30);
     2199#ifndef NO_SWAP7
    20782200        } else if (value>-tolerance) {
    20792201          // at correct bound but may swap
     
    20852207            solution[iSequence] = lower[iSequence];
    20862208            changeObj += movement*cost[iSequence];
    2087             numberFake_--;
    2088             setFakeBound(iSequence+numberColumns_,noFake);
    2089           }
     2209            //numberFake_--;
     2210            //setFakeBound(iSequence+numberColumns_,noFake);
     2211          }
     2212#endif
    20902213        }
    20912214      } else if (status==atLowerBound) {
     
    21002223          changeObj += movement*cost[iSequence];
    21012224          outputArray->quickAdd(iSequence,-movement);
     2225#ifndef NO_SWAP7
    21022226        } else if (value<tolerance) {
    21032227          // at correct bound but may swap
     
    21092233            solution[iSequence] = upper[iSequence];
    21102234            changeObj += movement*cost[iSequence];
    2111             numberFake_--;
    2112             setFakeBound(iSequence+numberColumns_,noFake);
    2113           }
     2235            //numberFake_--;
     2236            //setFakeBound(iSequence+numberColumns_,noFake);
     2237          }
     2238#endif
    21142239        }
    21152240      }
     
    22102335          changeObj += movement*cost[iSequence];
    22112336          matrix_->add(this,outputArray,iSequence,movement);
     2337#ifndef NO_SWAP7
    22122338        } else if (value<tolerance) {
    22132339          // at correct bound but may swap
     
    22192345            solution[iSequence] = upper[iSequence];
    22202346            changeObj += movement*cost[iSequence];
    2221             numberFake_--;
    2222             setFakeBound(iSequence,noFake);
    2223           }
     2347            //numberFake_--;
     2348            //setFakeBound(iSequence,noFake);
     2349          }
     2350#endif
    22242351        }
    22252352      } else if (status==atUpperBound) {
     
    22342361          changeObj += movement*cost[iSequence];
    22352362          matrix_->add(this,outputArray,iSequence,movement);
     2363#ifndef NO_SWAP7
    22362364        } else if (value>-tolerance) {
    22372365          // at correct bound but may swap
     
    22432371            solution[iSequence] = lower[iSequence];
    22442372            changeObj += movement*cost[iSequence];
    2245             numberFake_--;
    2246             setFakeBound(iSequence,noFake);
    2247           }
     2373            //numberFake_--;
     2374            //setFakeBound(iSequence,noFake);
     2375          }
     2376#endif
    22482377        }
    22492378      }
     
    25962725            if (newUpperValue < upperValue) {
    25972726              setFakeBound(iSequence,ClpSimplexDual::bothFake);
     2727              abort();
    25982728              numberFake_++;
    25992729            } else {
     
    26282758    }
    26292759    return numberInfeasibilities;
    2630   } else if (initialize==1) {
     2760  } else if (initialize==1||initialize==3) {
    26312761    int iSequence;
    2632      
     2762    if (initialize==3) {
     2763      for (iSequence=0;iSequence<numberRows_+numberColumns_;iSequence++) {
     2764        setFakeBound(iSequence,ClpSimplexDual::noFake);
     2765      }
     2766    }
     2767    double testBound = 0.999999*dualBound_;
    26332768    for (iSequence=0;iSequence<numberRows_+numberColumns_;iSequence++) {
    26342769      Status status = getStatus(iSequence);
     
    26392774        double value = solution_[iSequence];
    26402775        if (lowerValue>-largeValue_||upperValue<largeValue_) {
    2641           if (lowerValue-value>-0.5*dualBound_||
     2776          if (true||lowerValue-value>-0.5*dualBound_||
    26422777              upperValue-value<0.5*dualBound_) {
    26432778            if (fabs(lowerValue-value)<=fabs(upperValue-value)) {
    2644               if (upperValue > lowerValue + dualBound_) {
     2779              if (upperValue > lowerValue + testBound) {
     2780                if (getFakeBound(iSequence)==ClpSimplexDual::noFake)
     2781                  numberFake_++;
    26452782                upper_[iSequence]=lowerValue+dualBound_;
    26462783                setFakeBound(iSequence,ClpSimplexDual::upperFake);
    2647                 numberFake_++;
    26482784              }
    26492785            } else {
    2650               if (lowerValue < upperValue - dualBound_) {
     2786              if (lowerValue < upperValue - testBound) {
     2787                if (getFakeBound(iSequence)==ClpSimplexDual::noFake)
     2788                  numberFake_++;
    26512789                lower_[iSequence]=upperValue-dualBound_;
    26522790                setFakeBound(iSequence,ClpSimplexDual::lowerFake);
    2653                 numberFake_++;
    26542791              }
    26552792            }
    26562793          } else {
     2794            if (getFakeBound(iSequence)==ClpSimplexDual::noFake)
     2795              numberFake_++;
    26572796            lower_[iSequence]=-0.5*dualBound_;
    26582797            upper_[iSequence]= 0.5*dualBound_;
    26592798            setFakeBound(iSequence,ClpSimplexDual::bothFake);
    2660             numberFake_++;
     2799            abort();
    26612800          }
    26622801          if (status==atUpperBound)
     
    26712810          upper_[iSequence]= 0.5*dualBound_;
    26722811          setFakeBound(iSequence,ClpSimplexDual::bothFake);
     2812          abort();
    26732813          numberFake_++;
    26742814          setStatus(iSequence,atUpperBound);
     
    26862826        FakeBound fakeStatus = getFakeBound(iSequence);
    26872827        if (fakeStatus!=noFake) {
    2688           if (((int) fakeStatus&1)!=0) {
     2828          if ((static_cast<int> (fakeStatus)&1)!=0) {
    26892829            // lower
    26902830            double value = columnLower_[iSequence];
     
    26952835            columnLowerWork_[iSequence]=value;
    26962836          }
    2697           if (((int) fakeStatus&2)!=0) {
     2837          if ((static_cast<int> (fakeStatus)&2)!=0) {
    26982838            // upper
    26992839            double value = columnUpper_[iSequence];
     
    27092849        FakeBound fakeStatus = getFakeBound(iSequence+numberColumns_);
    27102850        if (fakeStatus!=noFake) {
    2711           if (((int) fakeStatus&1)!=0) {
     2851          if ((static_cast<int> (fakeStatus)&1)!=0) {
    27122852            // lower
    27132853            double value = rowLower_[iSequence];
     
    27182858            rowLowerWork_[iSequence]=value;
    27192859          }
    2720           if (((int) fakeStatus&2)!=0) {
     2860          if ((static_cast<int> (fakeStatus)&2)!=0) {
    27212861            // upper
    27222862            double value = rowUpper_[iSequence];
     
    27332873      for (iSequence=0;iSequence<numberColumns_;iSequence++) {
    27342874        FakeBound fakeStatus = getFakeBound(iSequence);
    2735         if (((int) fakeStatus&1)!=0) {
     2875        if ((static_cast<int> (fakeStatus)&1)!=0) {
    27362876          // lower
    27372877          columnLowerWork_[iSequence]=columnLower_[iSequence];
    27382878        }
    2739         if (((int) fakeStatus&2)!=0) {
     2879        if ((static_cast<int> (fakeStatus)&2)!=0) {
    27402880          // upper
    27412881          columnUpperWork_[iSequence]=columnUpper_[iSequence];
     
    27442884      for (iSequence=0;iSequence<numberRows_;iSequence++) {
    27452885        FakeBound fakeStatus = getFakeBound(iSequence+numberColumns_);
    2746         if (((int) fakeStatus&1)!=0) {
     2886        if ((static_cast<int> (fakeStatus)&1)!=0) {
    27472887          // lower
    27482888          rowLowerWork_[iSequence]=rowLower_[iSequence];
    27492889        }
    2750         if (((int) fakeStatus&2)!=0) {
     2890        if ((static_cast<int> (fakeStatus)&2)!=0) {
    27512891          // upper
    27522892          rowUpperWork_[iSequence]=rowUpper_[iSequence];
     
    32743414            }
    32753415          }
     3416          marker[1-iFlip][0]= CoinMax(marker[1-iFlip][0],numberRemaining);
     3417          marker[1-iFlip][1]= CoinMin(marker[1-iFlip][1],numberPossiblySwapped);
    32763418#ifdef MORE_CAREFUL
    32773419          // If we have done pivots and things look bad set alpha_ 0.0 to force factorization
     
    32803422            printf("maybe forcing re-factorization - sum %g  %d pivots\n",sumBadPivots,
    32813423                   factorization_->pivots());
    3282             badSumPivots=true;
     3424            if(factorization_->pivots()>3) {
     3425              badSumPivots=true;
     3426              break;
     3427            }
    32833428          }
    32843429#endif
    32853430          swapped[1-iFlip]=numberPossiblySwapped;
    32863431          interesting[1-iFlip]=numberRemaining;
    3287           marker[1-iFlip][0]= CoinMax(marker[1-iFlip][0],numberRemaining);
    3288           marker[1-iFlip][1]= CoinMin(marker[1-iFlip][1],numberPossiblySwapped);
    32893432          // If we stop now this will be increase in objective (I think)
    32903433          double increase = (fabs(dualOut_)-totalThru)*theta_;
     
    34003543      // may need to adjust costs so all dual feasible AND pivoted is exactly 0
    34013544      //int costOffset = numberRows_+numberColumns_;
    3402       if (modifyCosts) {
     3545      if (modifyCosts&&!badSumPivots) {
    34033546        int i;
    34043547        for (i=numberColumns_-1;i>=swapped[iFlip];i--) {
     
    34723615#ifdef MORE_CAREFUL
    34733616    // If we have done pivots and things look bad set alpha_ 0.0 to force factorization
    3474     if (badSumPivots&&factorization_->pivots()) {
     3617    if (badSumPivots) {
    34753618      if (handler_->logLevel()>1)
    34763619        printf("forcing re-factorization\n");
     
    34963639    // so (dualIn_+modification)==theta_*alpha_
    34973640    double modification = theta_*alpha_-dualIn_;
    3498     // But should not move objectivetoo much ??
     3641    // But should not move objective too much ??
    34993642#define DONT_MOVE_OBJECTIVE
    35003643#ifdef DONT_MOVE_OBJECTIVE
     
    35083651    }
    35093652#endif
     3653    if (badSumPivots)
     3654      modification=0.0;
    35103655    if ((specialOptions_&(2048+4096))!=0) {
    35113656      if ((specialOptions_&16384)!=0) {
     
    36293774                                      int ifValuesPass)
    36303775{
    3631 #ifdef CLP_INVESTIGATE
     3776#ifdef CLP_INVESTIGATE_SERIAL
    36323777  if (z_thinks>0&&z_thinks<2)
    36333778    z_thinks+=2;
     
    36633808    changeMade_++; // say something changed
    36643809    // get correct bounds on all variables
    3665     resetFakeBounds();
     3810    resetFakeBounds(0);
    36663811  }
    36673812  int tentativeStatus = problemStatus_;
     
    37043849          matrix_->generalExpanded(this,6,dummy);
    37053850          // get correct bounds on all variables
    3706           resetFakeBounds();
     3851          resetFakeBounds(1);
    37073852          // need to reject something
    37083853          char x = isColumn(sequenceOut_) ? 'C' :'R';
     
    37453890            }
    37463891            // get correct bounds on all variables
    3747             resetFakeBounds();
     3892            resetFakeBounds(1);
    37483893          }
    37493894        }
     
    38443989    matrix_->generalExpanded(this,6,dummy);
    38453990    // get correct bounds on all variables
    3846     resetFakeBounds();
     3991    resetFakeBounds(1);
    38473992    // need to reject something
    38483993    char x = isColumn(sequenceOut_) ? 'C' :'R';
     
    38884033      }
    38894034      // get correct bounds on all variables
    3890       resetFakeBounds();
     4035      resetFakeBounds(1);
    38914036    }
    38924037    // get primal and dual solutions
     
    38964041    double newTolerance = CoinMax(0.99*factorization_->pivotTolerance(),saveData.pivotTolerance_);
    38974042    factorization_->pivotTolerance(newTolerance);
    3898   }
     4043  }
     4044  bool reallyBadProblems=false;
    38994045  // Double check infeasibility if no action
    39004046  if (progress_.lastIterationNumber(0)==numberIterations_) {
     
    39054051#if 1
    39064052  } else {
    3907     double thisObj = objectiveValue_;
     4053    double thisObj = objectiveValue_-bestPossibleImprovement_;
     4054#ifdef CLP_INVESTIGATE
     4055    if (bestPossibleImprovement_)
     4056      printf("obj %g add in %g -> %g\n",objectiveValue_,bestPossibleImprovement_,
     4057             thisObj);
     4058#endif
    39084059    double lastObj = progress_.lastObjective(0);
     4060#ifndef NDEBUG
     4061#ifdef COIN_DEVELOP
     4062    resetFakeBounds(-1);
     4063#endif
     4064#endif
     4065#ifdef CLP_REPORT_PROGRESS
     4066    ixxxxxx++;
     4067    if (ixxxxxx>=ixxyyyy-4&&ixxxxxx<=ixxyyyy) {
     4068      char temp[20];
     4069      sprintf(temp,"sol%d.out",ixxxxxx);
     4070      printf("sol%d.out\n",ixxxxxx);
     4071      FILE * fp = fopen(temp,"w");
     4072      int nTotal=numberRows_+numberColumns_;
     4073      for (int i=0;i<nTotal;i++)
     4074        fprintf(fp,"%d %d %g %g %g %g %g\n",
     4075                i,status_[i],lower_[i],solution_[i],upper_[i],cost_[i],dj_[i]);
     4076      fclose(fp);
     4077    }
     4078#endif
    39094079    if(!ifValuesPass&&firstFree_<0) {
    3910       if (lastObj>thisObj+1.0e-3*CoinMax(fabs(thisObj),fabs(lastObj))+1.0) {
     4080      double testTol = 5.0e-3;
     4081      if (progress_.timesFlagged()>10) {
     4082        testTol *= pow(2.0,progress_.timesFlagged()-8);
     4083      } else if (progress_.timesFlagged()>5) {
     4084        testTol *=5.0;
     4085      }
     4086      if (lastObj>thisObj+
     4087          testTol*(fabs(thisObj)+fabs(lastObj))+testTol) {
    39114088        int maxFactor = factorization_->maximumPivots();
    3912         if (maxFactor>10&&numberPivots>1) {
    3913           //printf("lastobj %g thisobj %g\n",lastObj,thisObj);
    3914           //if (forceFactorization_<0)
    3915           //forceFactorization_= maxFactor;
    3916           //forceFactorization_ = CoinMax(1,(forceFactorization_>>1));
    3917           forceFactorization_=1;
    3918           //printf("Reducing factorization frequency - bad backwards\n");
    3919           unflagVariables = false;
    3920           changeMade_++; // say something changed
    3921           CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
    3922           CoinMemcpyN(savedSolution_+numberColumns_ ,
    3923                       numberRows_,rowActivityWork_);
    3924           CoinMemcpyN(savedSolution_ ,
    3925                       numberColumns_,columnActivityWork_);
    3926           // restore extra stuff
    3927           int dummy;
    3928           matrix_->generalExpanded(this,6,dummy);
    3929           // get correct bounds on all variables
    3930           resetFakeBounds();
    3931           if(factorization_->pivotTolerance()<0.2)
    3932             factorization_->pivotTolerance(0.2);
    3933           if (alphaAccuracy_!=-1.0)
    3934             alphaAccuracy_=-2.0;
    3935           if (internalFactorize(1)) {
    3936             CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
    3937             CoinMemcpyN(savedSolution_+numberColumns_ ,
    3938                         numberRows_,rowActivityWork_);
    3939             CoinMemcpyN(savedSolution_ ,
    3940                         numberColumns_,columnActivityWork_);
    3941             // restore extra stuff
    3942             int dummy;
    3943             matrix_->generalExpanded(this,6,dummy);
    3944             // debug
    3945             int returnCode = internalFactorize(1);
    3946             while (returnCode) {
    3947               // ouch
    3948               // switch off dense
    3949               int saveDense = factorization_->denseThreshold();
    3950               factorization_->setDenseThreshold(0);
    3951               // Go to safe
    3952               factorization_->pivotTolerance(0.99);
    3953               // make sure will do safe factorization
    3954               pivotVariable_[0]=-1;
    3955               returnCode=internalFactorize(2);
    3956               factorization_->setDenseThreshold(saveDense);
     4089        if ((specialOptions_&16384)==0) {
     4090          if (progress_.timesFlagged()>10)
     4091            progress_.incrementReallyBadTimes();
     4092          if (maxFactor>10-9) {
     4093#ifdef COIN_DEVELOP
     4094            printf("lastobj %g thisobj %g\n",lastObj,thisObj);
     4095#endif
     4096            //if (forceFactorization_<0)
     4097            //forceFactorization_= maxFactor;
     4098            //forceFactorization_ = CoinMax(1,(forceFactorization_>>1));
     4099            if ((progressFlag_&4)==0&&lastObj<thisObj+1.0e4&&
     4100                largestPrimalError_<1.0e2) {
     4101              // Just save costs
     4102              // save extra copy of cost_
     4103              int nTotal=numberRows_+numberColumns_;
     4104              double * temp = new double [2*nTotal];
     4105              memcpy(temp,cost_,nTotal*sizeof(double));
     4106              memcpy(temp+nTotal,cost_,nTotal*sizeof(double));
     4107              delete [] cost_;
     4108              cost_=temp;
     4109              objectiveWork_ = cost_;
     4110              rowObjectiveWork_ = cost_+numberColumns_;
     4111              progressFlag_ |= 4;
     4112            } else {
     4113              forceFactorization_=1;
     4114#ifdef COIN_DEVELOP
     4115              printf("Reducing factorization frequency - bad backwards\n");
     4116#endif
     4117#if 1
     4118              unflagVariables = false;
     4119              changeMade_++; // say something changed
     4120              int nTotal = numberRows_+numberColumns_;
     4121              CoinMemcpyN(saveStatus_,nTotal,status_);
     4122              CoinMemcpyN(savedSolution_+numberColumns_ ,
     4123                          numberRows_,rowActivityWork_);
     4124              CoinMemcpyN(savedSolution_ ,
     4125                          numberColumns_,columnActivityWork_);
     4126              if ((progressFlag_&4)==0) {
     4127                // save extra copy of cost_
     4128                double * temp = new double [2*nTotal];
     4129                memcpy(temp,cost_,nTotal*sizeof(double));
     4130                memcpy(temp+nTotal,cost_,nTotal*sizeof(double));
     4131                delete [] cost_;
     4132                cost_=temp;
     4133                objectiveWork_ = cost_;
     4134                rowObjectiveWork_ = cost_+numberColumns_;
     4135                progressFlag_ |= 4;
     4136              } else {
     4137                memcpy(cost_,cost_+nTotal,nTotal*sizeof(double));
     4138              }
     4139              // restore extra stuff
     4140              int dummy;
     4141              matrix_->generalExpanded(this,6,dummy);
     4142              double pivotTolerance = factorization_->pivotTolerance();
     4143              if(pivotTolerance<0.2)
     4144                factorization_->pivotTolerance(0.2);
     4145              else if(progress_.timesFlagged()>2)
     4146                factorization_->pivotTolerance(CoinMin(pivotTolerance*1.1,0.99));
     4147              if (alphaAccuracy_!=-1.0)
     4148                alphaAccuracy_=-2.0;
     4149              if (internalFactorize(1)) {
     4150                CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
     4151                CoinMemcpyN(savedSolution_+numberColumns_ ,
     4152                            numberRows_,rowActivityWork_);
     4153                CoinMemcpyN(savedSolution_ ,
     4154                            numberColumns_,columnActivityWork_);
     4155                // restore extra stuff
     4156                int dummy;
     4157                matrix_->generalExpanded(this,6,dummy);
     4158                // debug
     4159                int returnCode = internalFactorize(1);
     4160                while (returnCode) {
     4161                  // ouch
     4162                  // switch off dense
     4163                  int saveDense = factorization_->denseThreshold();
     4164                  factorization_->setDenseThreshold(0);
     4165                  // Go to safe
     4166                  factorization_->pivotTolerance(0.99);
     4167                  // make sure will do safe factorization
     4168                  pivotVariable_[0]=-1;
     4169                  returnCode=internalFactorize(2);
     4170                  factorization_->setDenseThreshold(saveDense);
     4171                }
     4172              }
     4173              resetFakeBounds(0);
     4174              type = 2; // so will restore weights
     4175              // get primal and dual solutions
     4176              gutsOfSolution(givenDuals,NULL);
     4177              if (numberPivots<2) {
     4178                // need to reject something
     4179                char x = isColumn(sequenceOut_) ? 'C' :'R';
     4180                handler_->message(CLP_SIMPLEX_FLAG,messages_)
     4181                  <<x<<sequenceWithin(sequenceOut_)
     4182                  <<CoinMessageEol;
     4183#ifdef COIN_DEVELOP
     4184                printf("flag d\n");
     4185#endif
     4186                setFlagged(sequenceOut_);
     4187                progress_.clearBadTimes();
     4188                progress_.incrementTimesFlagged();
     4189              }
     4190              if (numberPivots<10)
     4191                reallyBadProblems=true;
     4192#ifdef COIN_DEVELOP
     4193              printf("obj now %g\n",objectiveValue_);
     4194#endif
     4195              progress_.modifyObjective(objectiveValue_
     4196                                        -bestPossibleImprovement_);
     4197#endif
    39574198            }
    3958             resetFakeBounds();
    3959           }
    3960           type = 2; // so will restore weights
    3961           // get primal and dual solutions
    3962           gutsOfSolution(givenDuals,NULL);
     4199          }
     4200        } else {
     4201          // in fast dual give up
     4202#ifdef COIN_DEVELOP
     4203          printf("In fast dual?\n");
     4204#endif
     4205          problemStatus_=3;
    39634206        }
    39644207      } else if (lastObj<thisObj-1.0e-5*CoinMax(fabs(thisObj),fabs(lastObj))-1.0e-3) {
     
    39884231  else
    39894232    loop=-1;
     4233  if (progress_.reallyBadTimes()>10) {
     4234    problemStatus_ = 10; // instead - try other algorithm
     4235#if COIN_DEVELOP>2
     4236    printf("returning at %d\n",__LINE__);
     4237#endif
     4238  }
    39904239  int situationChanged=0;
    39914240  if (loop>=0) {
     
    40114260    situationChanged=2;
    40124261  }
    4013   progressFlag_ = 0; //reset progress flag
     4262  progressFlag_ &= (~3); //reset progress flag
     4263  if ((progressFlag_&4)!=0) {
     4264    // save copy of cost_
     4265    int nTotal = numberRows_+numberColumns_;
     4266    memcpy(cost_+nTotal,cost_,nTotal*sizeof(double));
     4267  }
    40144268  /*if (!numberIterations_&&sumDualInfeasibilities_)
    40154269    printf("OBJ %g sumPinf %g sumDinf %g\n",
     
    40284282    handler_->message()<<CoinMessageEol;
    40294283  }
     4284#ifdef CLP_REPORT_PROGRESS
     4285    if (ixxxxxx>=ixxyyyy-4&&ixxxxxx<=ixxyyyy) {
     4286      char temp[20];
     4287      sprintf(temp,"x_sol%d.out",ixxxxxx);
     4288      FILE * fp = fopen(temp,"w");
     4289      int nTotal=numberRows_+numberColumns_;
     4290      for (int i=0;i<nTotal;i++)
     4291        fprintf(fp,"%d %d %g %g %g %g %g\n",
     4292                i,status_[i],lower_[i],solution_[i],upper_[i],cost_[i],dj_[i]);
     4293      fclose(fp);
     4294      if (ixxxxxx==ixxyyyy)
     4295        exit(6);
     4296    }
     4297#endif
    40304298  realDualInfeasibilities=sumDualInfeasibilities_;
    40314299  double saveTolerance =dualTolerance_;
     
    40504318  // dual bound coming in
    40514319  //double saveDualBound = dualBound_;
     4320  bool needCleanFake=false;
    40524321  while (problemStatus_<=-3) {
    40534322    int cleanDuals=0;
     
    40714340    if (dualFeasible()||problemStatus_==-4) {
    40724341      progress_.modifyObjective(objectiveValue_
    4073                                -sumDualInfeasibilities_*dualBound_);
     4342                                -bestPossibleImprovement_);
     4343#ifdef COIN_DEVELOP
     4344      if (sumDualInfeasibilities_||bestPossibleImprovement_)
     4345        printf("improve %g dualinf %g -> %g\n",
     4346               bestPossibleImprovement_,sumDualInfeasibilities_,
     4347               sumDualInfeasibilities_*dualBound_);
     4348#endif
    40744349      // see if cutoff reached
    40754350      double limit = 0.0;
    40764351      getDblParam(ClpDualObjectiveLimit, limit);
     4352#if 0
    40774353      if(fabs(limit)<1.0e30&&objectiveValue()*optimizationDirection_>
    40784354         limit+1.0e-7+1.0e-8*fabs(limit)&&!numberAtFakeBound()) {
    40794355        //looks infeasible on objective
    40804356        if (perturbation_==101) {
    4081           perturbation_=102; // stop any perturbations
    40824357          cleanDuals=1;
     4358          // Save costs
     4359          int numberTotal = numberRows_+numberColumns_;
     4360          double * saveCost = CoinCopyOfArray(cost_,numberTotal);
    40834361          // make sure fake bounds are back
    40844362          changeBounds(1,NULL,changeCost);
     
    40874365          computeDuals(givenDuals);
    40884366          checkDualSolution();
    4089         }
    4090       }
     4367          if(objectiveValue()*optimizationDirection_>
     4368             limit+1.0e-7+1.0e-8*fabs(limit)&&!numberDualInfeasibilities_) {
     4369            perturbation_=102; // stop any perturbations
     4370            printf("cutoff test succeeded\n");
     4371          } else {
     4372            printf("cutoff test failed\n");
     4373            // put back
     4374            memcpy(cost_,saveCost,numberTotal*sizeof(double));
     4375            // make sure duals are current
     4376            computeDuals(givenDuals);
     4377            checkDualSolution();
     4378            progress_.modifyObjective(-COIN_DBL_MAX);
     4379            problemStatus_=-1;
     4380          }
     4381          delete [] saveCost;
     4382        }
     4383      }
     4384#endif
    40914385      if (primalFeasible()&&!givenDuals) {
    40924386        // may be optimal - or may be bounds are wrong
     
    41164410            computeDuals(givenDuals);
    41174411            checkDualSolution();
     4412            progress_.modifyObjective(-COIN_DBL_MAX);
    41184413#define DUAL_TRY_FASTER
    41194414#ifdef DUAL_TRY_FASTER
     
    41414436              if (numberTimesOptimal_==2) {
    41424437                // better to have small tolerance even if slower
    4143                 factorization_->zeroTolerance(1.0e-15);
     4438                factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(),1.0e-15));
    41444439              }
    41454440              dualTolerance_ = dblParam_[ClpDualTolerance];
     
    42064501              cleanDuals=1;
    42074502              createRim4(false);
     4503              progress_.modifyObjective(-COIN_DBL_MAX);
    42084504              problemStatus_=-1;
    42094505            }
     
    42334529        // may be infeasible - or may be bounds are wrong
    42344530        numberChangedBounds=changeBounds(0,NULL,changeCost);
     4531        needCleanFake=true;
    42354532        /* Should this be here as makes no difference to being feasible.
    42364533           But seems to make a difference to run times. */
     
    42414538          // make sure fake bounds are back
    42424539          changeBounds(1,NULL,changeCost);
     4540          needCleanFake=true;
    42434541          createRim4(false);
     4542          progress_.modifyObjective(-COIN_DBL_MAX);
    42444543        }
    42454544        if ((numberChangedBounds<=0||dualBound_>1.0e20||
     
    42884587#endif
    42894588        createRim4(false);
     4589        progress_.modifyObjective(-COIN_DBL_MAX);
    42904590        // make sure duals are current
    42914591        computeDuals(givenDuals);
     
    43244624             Worst that can happen is that we waste a bit of time  - but it must be finite.
    43254625          */
    4326           int saveNumberFake = numberFake_;
    4327           changeBounds(1,NULL,changeCost);
    4328           numberFake_ += saveNumberFake;
     4626          //int saveNumberFake = numberFake_;
     4627          //resetFakeBounds(-1);
     4628          changeBounds(3,NULL,changeCost);
     4629          needCleanFake=true;
     4630          //numberFake_ += saveNumberFake;
     4631          //resetFakeBounds(-1);
    43294632          cleanDuals=2;
    43304633          //cleanDuals=1;
     
    44784781  }
    44794782  if (problemStatus_<0) {
     4783    if (needCleanFake) {
     4784      double dummyChangeCost=0.0;
     4785      changeBounds(3,NULL,dummyChangeCost);
     4786    }
     4787#if 0
     4788    if (objectiveValue_<lastObjectiveValue_-1.0e-8*
     4789        CoinMax(fabs(objectivevalue_),fabs(lastObjectiveValue_))) {
     4790    } else {
     4791      lastObjectiveValue_=objectiveValue_;
     4792    }
     4793#endif
    44804794    if (type==0||type==1) {
    44814795      if (!type) {
     
    44974811    if (weightsSaved) {
    44984812      // restore weights (if saved) - also recompute infeasibility list
    4499       if (tentativeStatus>-3)
    4500         dualRowPivot_->saveWeights(this,(type <2) ? 2 : 4);
    4501       else
    4502         dualRowPivot_->saveWeights(this,3);
     4813      if (!reallyBadProblems&&(largestPrimalError_<100.0||numberPivots>10)) {
     4814        if (tentativeStatus>-3)
     4815          dualRowPivot_->saveWeights(this,(type <2) ? 2 : 4);
     4816        else
     4817          dualRowPivot_->saveWeights(this,3);
     4818      } else {
     4819        // reset weights or scale back
     4820        dualRowPivot_->saveWeights(this,6);
     4821      }
    45034822    }
    45044823  }
     
    45224841      // Even if not perturbed internal costs may have changed
    45234842      // be careful
    4524       if (numberIterations_) {
     4843      if (true||numberIterations_) {
    45254844        if(computeInternalObjectiveValue()>limit) {
    45264845          problemStatus_=1;
     
    45994918      numberDualInfeasibilities_=1;
    46004919  }
     4920#ifdef CLP_REPORT_PROGRESS
     4921  if (ixxxxxx>ixxyyyy-3) {
     4922    printf("objectiveValue_ %g\n",objectiveValue_);
     4923    handler_->setLogLevel(63);
     4924    int nTotal = numberColumns_+numberRows_;
     4925    double newObj=0.0;
     4926    for (int i=0;i<nTotal;i++) {
     4927      if (solution_[i])
     4928        newObj += solution_[i]*cost_[i];
     4929    }
     4930    printf("xxx obj %g\n",newObj);
     4931    // for now - recompute all
     4932    gutsOfSolution(NULL,NULL);
     4933    newObj=0.0;
     4934    for (int i=0;i<nTotal;i++) {
     4935      if (solution_[i])
     4936        newObj += solution_[i]*cost_[i];
     4937    }
     4938    printf("yyy obj %g %g\n",newObj,objectiveValue_);
     4939    progress_.modifyObjective(objectiveValue_
     4940                              -bestPossibleImprovement_);
     4941  }
     4942#endif
    46014943#if 1
    46024944  double thisObj = progress_.lastObjective(0);
     
    48105152    }
    48115153    if (numberNonZero)
    4812       averageCost /= (double) numberNonZero;
     5154      averageCost /= static_cast<double> (numberNonZero);
    48135155    else
    48145156      averageCost = 1.0;
     
    49805322  bool printOut=(handler_->logLevel()==63);
    49815323  printOut=false;
     5324  //assert (!modifyRowCosts);
     5325  modifyRowCosts=false;
    49825326  if (modifyRowCosts) {
    49835327    for (iRow=0;iRow<numberRows_;iRow++) {
     
    50245368  double factor=1.0;
    50255369  if (maxLength) {
    5026     factor = 3.0/(double) minLength;
     5370    factor = 3.0/static_cast<double> (minLength);
    50275371  }
    50285372  // Make variables with more elements more expensive
    50295373  const double m1 = 0.5;
    50305374  double smallestAllowed = CoinMin(1.0e-2*dualTolerance_,maximumFraction);
    5031   //double largestAllowed = CoinMax(1.0e3*dualTolerance_,maximumFraction*10.0*averageCost);
    50325375  double largestAllowed = CoinMax(1.0e3*dualTolerance_,maximumFraction*averageCost);
     5376  // smaller if in BAB
     5377  //if (inCbcOrOther)
     5378  //largestAllowed=CoinMin(largestAllowed,1.0e-5);
     5379  //smallestAllowed = CoinMin(smallestAllowed,0.1*largestAllowed);
     5380#define SAVE_PERT
     5381#ifdef SAVE_PERT
     5382  if (2*numberColumns_>maximumPerturbationSize_) {
     5383    delete [] perturbationArray_;
     5384    maximumPerturbationSize_ = 2* numberColumns_;
     5385    perturbationArray_ = new double [maximumPerturbationSize_];
     5386    for (iColumn=0;iColumn<maximumPerturbationSize_;iColumn++) {
     5387      perturbationArray_[iColumn] = randomNumberGenerator_.randomDouble();
     5388    }
     5389  }
     5390#endif
    50335391  for (iColumn=0;iColumn<numberColumns_;iColumn++) {
    50345392    if (columnLowerWork_[iColumn]<columnUpperWork_[iColumn]&&getStatus(iColumn)!=basic) {
     
    50455403        if (fabs(columnLowerWork_[iColumn])<
    50465404            fabs(columnUpperWork_[iColumn])) {
     5405#ifndef SAVE_PERT
    50475406          value *= (1.0-m1 +m1*randomNumberGenerator_.randomDouble());
    50485407          value2 *= (1.0-m1 +m1*randomNumberGenerator_.randomDouble());
     5408#else
     5409          value *= (1.0-m1 +m1*perturbationArray_[2*iColumn]);
     5410          value2 *= (1.0-m1 +m1*perturbationArray_[2*iColumn+1]);
     5411#endif
    50495412        } else {
    50505413          //value *= -(1.0-m1+m1*randomNumberGenerator_.randomDouble());
     
    50535416        }
    50545417      } else if (columnUpperWork_[iColumn]<largeValue_) {
     5418#ifndef SAVE_PERT
    50555419        value *= -(1.0-m1+m1*randomNumberGenerator_.randomDouble());
    50565420        value2 *= -(1.0-m1+m1*randomNumberGenerator_.randomDouble());
     5421#else
     5422        value *= -(1.0-m1+m1*perturbationArray_[2*iColumn]);
     5423        value2 *= -(1.0-m1+m1*perturbationArray_[2*iColumn+1]);
     5424#endif
    50575425      } else {
    50585426        value=0.0;
     
    50615429        int length = columnLength[iColumn];
    50625430        if (length>3) {
    5063           length = (int) ((double) length * factor);
     5431          length = static_cast<int> (static_cast<double> (length) * factor);
    50645432          length = CoinMax(3,length);
    50655433        }
     
    52155583    else
    52165584      upper_[iColumn] = (newUpper[i]/columnScale_[iColumn])*rhsScale_; // scale
     5585    // Get fake bounds correctly
     5586    double changeCost;
     5587    changeBounds(3,NULL,changeCost);
    52175588    // Start of fast iterations
    52185589    int status = fastDual(alwaysFinish);
     
    52795650    else
    52805651      lower_[iColumn] = (newLower[i]/columnScale_[iColumn])*rhsScale_; // scale
     5652    // Get fake bounds correctly
     5653    resetFakeBounds(1);
    52815654    // Start of fast iterations
    52825655    status = fastDual(alwaysFinish);
     
    54035776  if (alphaAccuracy_!=-1.0)
    54045777    alphaAccuracy_ = 1.0;
    5405   double objectiveChange;
    54065778  // for dual we will change bounds using dualBound_
    54075779  // for this we need clean basis so it is after factorize
     
    54515823           sumPrimalInfeasibilities_,numberPrimalInfeasibilities_);
    54525824#endif
    5453   numberFake_ =0; // Number of variables at fake bounds
     5825#ifndef NDEBUG
     5826#ifdef COIN_DEVELOP
     5827  resetFakeBounds(-1);
     5828#endif
     5829#endif
     5830  //numberFake_ =0; // Number of variables at fake bounds
    54545831  numberChanged_ =0; // Number of variables with changed costs
    5455   changeBounds(1,NULL,objectiveChange);
     5832  //changeBounds(1,NULL,objectiveChange);
    54565833
    54575834  problemStatus_ = -1;
     
    55805957  assert(!numberFake_||((specialOptions_&(2048|4096))!=0&&dualBound_>=1.0e8)
    55815958         ||returnCode||problemStatus_); // all bounds should be okay
    5582   if (numberFake_>0) {
     5959  if (numberFake_>0&&false) {
    55835960    // Set back
    55845961    double dummy;
     
    56376014    }
    56386015  }
    5639   double * arrayD = (double *) arrays;
     6016  // Get fake bounds correctly
     6017  double dummyChangeCost;
     6018  changeBounds(1,NULL,dummyChangeCost);
     6019  double * arrayD = reinterpret_cast<double *> (arrays);
    56406020  arrayD[0]=objectiveValue()*optimizationDirection_;
    56416021  double * saveSolution = arrayD+1;
     
    56466026  double * saveUpperOriginal = saveLowerOriginal + numberColumns;
    56476027  arrayD = saveUpperOriginal + numberColumns;
    5648   int * savePivot = (int *) arrayD;
     6028  int * savePivot = reinterpret_cast<int *> (arrayD);
    56496029  int * whichRow = savePivot+numberRows;
    56506030  int * whichColumn = whichRow + 3*numberRows;
    56516031  int * arrayI = whichColumn + 2*numberColumns;
    5652   unsigned char * saveStatus = (unsigned char *) (arrayI+1);
     6032  unsigned char * saveStatus = reinterpret_cast<unsigned char *> (arrayI+1);
    56536033  // save stuff
    56546034  // save basis and solution
     
    57206100    }
    57216101  }
    5722   numberFake_ = numberFake;
     6102  //numberFake_ = numberFake;
    57236103  return numberFake;
    57246104}
     
    63136693}
    63146694void
    6315 ClpSimplexDual::resetFakeBounds()
     6695ClpSimplexDual::resetFakeBounds(int type)
    63166696{
    6317   // put back original bounds and then check
    6318   createRim1(false);
    6319   double dummyChangeCost=0.0;
    6320   changeBounds(1,rowArray_[2],dummyChangeCost);
    6321   // throw away change
    6322   for (int i=0;i<4;i++)
    6323     rowArray_[i]->clear();
     6697  if (type==0) {
     6698    // put back original bounds and then check
     6699    createRim1(false);
     6700    double dummyChangeCost=0.0;
     6701    changeBounds(3,NULL,dummyChangeCost);
     6702  } else if (type<0) {
     6703#ifndef NDEBUG
     6704    // just check
     6705    int nTotal = numberRows_+numberColumns_;
     6706    double * tempLower = CoinCopyOfArray(lower_,nTotal);
     6707    double * tempUpper = CoinCopyOfArray(upper_,nTotal);
     6708    int iSequence;
     6709    if (columnScale_) {
     6710      for (iSequence=0;iSequence<numberColumns_;iSequence++) {
     6711        FakeBound fakeStatus = getFakeBound(iSequence);
     6712        if (fakeStatus!=noFake) {
     6713          if ((static_cast<int> (fakeStatus)&1)!=0) {
     6714            // lower
     6715            double value = columnLower_[iSequence];
     6716            if (value>-1.0e30) {
     6717              double multiplier = rhsScale_/columnScale_[iSequence];
     6718              value *= multiplier;
     6719            }
     6720            tempLower[iSequence]=value;
     6721          }
     6722          if ((static_cast<int> (fakeStatus)&2)!=0) {
     6723            // upper
     6724            double value = columnUpper_[iSequence];
     6725            if (value<1.0e30) {
     6726              double multiplier = rhsScale_/columnScale_[iSequence];
     6727              value *= multiplier;
     6728            }
     6729            tempUpper[iSequence]=value;
     6730          }
     6731        }
     6732      }
     6733      for (iSequence=0;iSequence<numberRows_;iSequence++) {
     6734        FakeBound fakeStatus = getFakeBound(iSequence+numberColumns_);
     6735        if (fakeStatus!=noFake) {
     6736          if ((static_cast<int> (fakeStatus)&1)!=0) {
     6737            // lower
     6738            double value = rowLower_[iSequence];
     6739            if (value>-1.0e30) {
     6740              double multiplier = rhsScale_*rowScale_[iSequence];
     6741              value *= multiplier;
     6742            }
     6743            tempLower[iSequence+numberColumns_]=value;
     6744          }
     6745          if ((static_cast<int> (fakeStatus)&2)!=0) {
     6746            // upper
     6747            double value = rowUpper_[iSequence];
     6748            if (value<1.0e30) {
     6749              double multiplier = rhsScale_*rowScale_[iSequence];
     6750              value *= multiplier;
     6751            }
     6752            tempUpper[iSequence+numberColumns_]=value;
     6753          }
     6754        }
     6755      }
     6756    } else {
     6757      for (iSequence=0;iSequence<numberColumns_;iSequence++) {
     6758        FakeBound fakeStatus = getFakeBound(iSequence);
     6759        if ((static_cast<int> (fakeStatus)&1)!=0) {
     6760          // lower
     6761          tempLower[iSequence]=columnLower_[iSequence];
     6762        }
     6763        if ((static_cast<int> (fakeStatus)&2)!=0) {
     6764          // upper
     6765          tempUpper[iSequence]=columnUpper_[iSequence];
     6766        }
     6767      }
     6768      for (iSequence=0;iSequence<numberRows_;iSequence++) {
     6769        FakeBound fakeStatus = getFakeBound(iSequence+numberColumns_);
     6770        if ((static_cast<int> (fakeStatus)&1)!=0) {
     6771          // lower
     6772          tempLower[iSequence+numberColumns_]=rowLower_[iSequence];
     6773        }
     6774        if ((static_cast<int> (fakeStatus)&2)!=0) {
     6775          // upper
     6776          tempUpper[iSequence+numberColumns_]=rowUpper_[iSequence];
     6777        }
     6778      }
     6779    }
     6780    int nFake=0;
     6781    for (iSequence=0;iSequence<nTotal;iSequence++) {
     6782      FakeBound fakeStatus = getFakeBound(iSequence);
     6783      Status status = getStatus(iSequence);
     6784      bool isFake=false;
     6785      if (status==atUpperBound||
     6786          status==atLowerBound) {
     6787        double lowerValue=tempLower[iSequence];
     6788        double upperValue=tempUpper[iSequence];
     6789        double value = solution_[iSequence];
     6790#ifndef NDEBUG
     6791        CoinRelFltEq equal;
     6792#endif
     6793        if (fakeStatus==ClpSimplexDual::upperFake) {
     6794          assert(equal(upper_[iSequence],(lowerValue+dualBound_)));
     6795          assert(equal(upper_[iSequence],value)||
     6796                 equal(lower_[iSequence],value));
     6797          isFake=true;;
     6798        } else if (fakeStatus==ClpSimplexDual::lowerFake) {
     6799          assert(equal(lower_[iSequence],(upperValue-dualBound_)));
     6800          assert(equal(upper_[iSequence],value)||
     6801                 equal(lower_[iSequence],value));
     6802          isFake=true;;
     6803        }
     6804      }
     6805      if (isFake) {
     6806        nFake++;
     6807      } else {
     6808        assert (fakeStatus==ClpSimplexDual::noFake);
     6809      }
     6810    }
     6811    //printf("nfake %d numberFake %d\n",nFake,numberFake_);
     6812    assert (nFake==numberFake_);
     6813    delete [] tempLower;
     6814    delete [] tempUpper;
     6815#endif
     6816  } else if (lower_) {
     6817    // reset using status
     6818    int nTotal = numberRows_+numberColumns_;
     6819    int iSequence;
     6820    if (columnScale_) {
     6821      for (iSequence=0;iSequence<numberColumns_;iSequence++) {
     6822        double multiplier = rhsScale_/columnScale_[iSequence];
     6823        // lower
     6824        double value = columnLower_[iSequence];
     6825        if (value>-1.0e30) {
     6826          value *= multiplier;
     6827        }
     6828        lower_[iSequence]=value;
     6829        // upper
     6830        value = columnUpper_[iSequence];
     6831        if (value<1.0e30) {
     6832          value *= multiplier;
     6833        }
     6834        upper_[iSequence]=value;
     6835      }
     6836      for (iSequence=0;iSequence<numberRows_;iSequence++) {
     6837        // lower
     6838        double multiplier = rhsScale_*rowScale_[iSequence];
     6839        double value = rowLower_[iSequence];
     6840        if (value>-1.0e30) {
     6841          value *= multiplier;
     6842        }
     6843        lower_[iSequence+numberColumns_]=value;
     6844        // upper
     6845        value = rowUpper_[iSequence];
     6846        if (value<1.0e30) {
     6847          value *= multiplier;
     6848        }
     6849        upper_[iSequence+numberColumns_]=value;
     6850      }
     6851    } else {
     6852      memcpy(lower_,columnLower_,numberColumns_*sizeof(double));
     6853      memcpy(upper_,columnUpper_,numberColumns_*sizeof(double));
     6854      memcpy(lower_+numberColumns_,rowLower_,numberRows_*sizeof(double));
     6855      memcpy(upper_+numberColumns_,rowUpper_,numberRows_*sizeof(double));
     6856    }
     6857    numberFake_=0;
     6858    for (iSequence=0;iSequence<nTotal;iSequence++) {
     6859      FakeBound fakeStatus = getFakeBound(iSequence);
     6860      if (fakeStatus!=ClpSimplexDual::noFake) {
     6861        Status status = getStatus(iSequence);
     6862        if (status==basic) {
     6863          setFakeBound(iSequence,ClpSimplexDual::noFake);
     6864          continue;
     6865        }
     6866        double lowerValue=lower_[iSequence];
     6867        double upperValue=upper_[iSequence];
     6868        double value = solution_[iSequence];
     6869        numberFake_++;
     6870        if (fakeStatus==ClpSimplexDual::upperFake) {
     6871          if (fabs(lowerValue-value)<1.0e-5||
     6872              fabs(lowerValue+dualBound_-value)<1.0e-5) {
     6873            upper_[iSequence] = lowerValue+dualBound_;
     6874          } else {
     6875            // wrong way
     6876            if (fabs(upperValue-value)<1.0e-5||
     6877              fabs(upperValue-dualBound_-value)<1.0e-5) {
     6878              lower_[iSequence] = upperValue-dualBound_;
     6879              setFakeBound(iSequence,ClpSimplexDual::lowerFake);
     6880            } else {
     6881              printf("bad1\n");
     6882            }
     6883          }
     6884          assert(fabs(upper_[iSequence]-value)<1.0e-5||
     6885                 fabs(lower_[iSequence]-value)<1.0e-5);
     6886        } else if (fakeStatus==ClpSimplexDual::lowerFake) {
     6887          if (fabs(upperValue-value)<1.0e-5||
     6888              fabs(upperValue-dualBound_-value)<1.0e-5) {
     6889            lower_[iSequence] = upperValue-dualBound_;
     6890          } else {
     6891            // wrong way
     6892            if (fabs(lowerValue-value)<1.0e-5||
     6893              fabs(lowerValue+dualBound_-value)<1.0e-5) {
     6894              upper_[iSequence] = lowerValue+dualBound_;
     6895              setFakeBound(iSequence,ClpSimplexDual::upperFake);
     6896            } else {
     6897              printf("bad1\n");
     6898            }
     6899          }
     6900          assert(fabs(upper_[iSequence]-value)<1.0e-5||
     6901                 fabs(lower_[iSequence]-value)<1.0e-5);
     6902        } else if (fakeStatus==ClpSimplexDual::bothFake) {
     6903          if (status==ClpSimplex::atLowerBound) {
     6904            lower_[iSequence] = value;
     6905            upper_[iSequence] = value + dualBound_;
     6906          } else if (status==ClpSimplex::atUpperBound) {
     6907            upper_[iSequence] = value;
     6908            lower_[iSequence] = value - dualBound_;
     6909          } else if (status==ClpSimplex::isFree||
     6910                     status==ClpSimplex::superBasic) {
     6911            lower_[iSequence] = value-0.5*dualBound_;
     6912            upper_[iSequence] = value + 0.5*dualBound_;
     6913          } else if (status==ClpSimplex::isFixed) {
     6914            abort();
     6915          } else {
     6916            // basic
     6917            abort();numberFake_--;
     6918            // lower_[iSequence] = value;
     6919            //upper_[iSequence] = value + dualBound_;
     6920          }
     6921        }
     6922      }
     6923    }
     6924#ifndef NDEBUG
     6925  } else {
     6926    printf("NULL lower\n");
     6927#endif
     6928  }
    63246929}
  • trunk/Clp/src/ClpSimplexDual.hpp

    r1266 r1321  
    295295                  ClpDataSave & saveData);
    296296  //int dual2(int ifValuesPass,int startFinishOptions=0);
    297   void resetFakeBounds();
     297  void resetFakeBounds(int type);
    298298 
    299299  //@}
  • trunk/Clp/src/ClpSimplexNonlinear.cpp

    r1276 r1321  
    482482          if (numberTimesOptimal_==1) {
    483483            // better to have small tolerance even if slower
    484             factorization_->zeroTolerance(1.0e-15);
     484            factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(),1.0e-15));
    485485          }
    486486          lastCleaned=numberIterations_;
     
    24912491    // major error
    24922492    // better to have small tolerance even if slower
    2493     factorization_->zeroTolerance(1.0e-15);
     2493    factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(),1.0e-15));
    24942494    int maxFactor = factorization_->maximumPivots();
    24952495    if (maxFactor>10) {
     
    38843884        CoinMemcpyN(saveSolution+numberColumns2,
    38853885                    numberRows,newModel.primalRowSolution());
    3886         CoinMemcpyN((unsigned char *) saveStatus,
     3886        CoinMemcpyN(reinterpret_cast<unsigned char *> (saveStatus),
    38873887                    numberColumns2+numberRows,newModel.statusArray());
    38883888        for (jNon=0;jNon<numberNonLinearColumns;jNon++)
     
    40034003                numberRows,saveSolution+numberColumns2);
    40044004    CoinMemcpyN(newModel.statusArray(),
    4005                 numberColumns2+numberRows,(unsigned char *) saveStatus);
     4005                numberColumns2+numberRows,
     4006                reinterpret_cast<unsigned char *> (saveStatus));
    40064007   
    40074008    targetDrop=infPenalty+infPenalty2;
  • trunk/Clp/src/ClpSimplexOther.cpp

    r1286 r1321  
    746746ClpSimplexOther::dualOfModel(double fractionRowRanges,double fractionColumnRanges) const
    747747{
    748   const ClpSimplex * model2 = (const ClpSimplex *) this;
     748  const ClpSimplex * model2 = static_cast<const ClpSimplex *> (this);
    749749  bool changed=false;
    750750  int numberChanged=0;
     
    17631763    // save data
    17641764    ClpDataSave data = saveData();
    1765     int returnCode = ((ClpSimplexDual *) this)->startupSolve(0,NULL,0);
     1765    int returnCode = reinterpret_cast<ClpSimplexDual *> (this)->startupSolve(0,NULL,0);
    17661766    int iRow,iColumn;
    17671767    double * chgUpper=NULL;
     
    18571857      }
    18581858      double * saveDuals=NULL;
    1859       ((ClpSimplexDual *) this)->gutsOfDual(0,saveDuals,-1,data);
     1859      reinterpret_cast<ClpSimplexDual *> (this)->gutsOfDual(0,saveDuals,-1,data);
    18601860      assert (!problemStatus_);
    18611861      // Now do parametrics
     
    18881888      }
    18891889    }
    1890     ((ClpSimplexDual *) this)->finishSolve(0);
     1890    reinterpret_cast<ClpSimplexDual *> (this)->finishSolve(0);
    18911891   
    18921892    delete dualRowPivot_;
     
    20532053    if (canTryQuick) {
    20542054      double * saveDuals=NULL;
    2055       ((ClpSimplexDual *)this)->whileIterating(saveDuals,0);
     2055      reinterpret_cast<ClpSimplexDual *> (this)->whileIterating(saveDuals,0);
    20562056    } else {
    20572057      whileIterating(startingTheta,  endingTheta, reportIncrement,
     
    22462246    // choose row to go out
    22472247    // dualRow will go to virtual row pivot choice algorithm
    2248     ((ClpSimplexDual *) this)->dualRow(-1);
     2248    reinterpret_cast<ClpSimplexDual *> ( this)->dualRow(-1);
    22492249    if (pivotRow_>=0) {
    22502250      // we found a pivot row
     
    22792279                              rowArray_[0],rowArray_[3],columnArray_[0]);
    22802280      // do ratio test for normal iteration
    2281       bestPossiblePivot = ((ClpSimplexDual *) this)->dualColumn(rowArray_[0],
     2281      bestPossiblePivot = reinterpret_cast<ClpSimplexDual *> ( this)->dualColumn(rowArray_[0],
    22822282                                                                columnArray_[0],columnArray_[1],
    22832283                                                                rowArray_[3],acceptablePivot,NULL);
     
    23552355        //rowArray_[0]->cleanAndPackSafe(1.0e-60);
    23562356        //columnArray_[0]->cleanAndPackSafe(1.0e-60);
    2357         nswapped = ((ClpSimplexDual *) this)->updateDualsInDual(rowArray_[0],columnArray_[0],
     2357        nswapped = reinterpret_cast<ClpSimplexDual *> ( this)->updateDualsInDual(rowArray_[0],columnArray_[0],
    23582358                                     rowArray_[2],theta_,
    23592359                                     objectiveChange,false);
     
    24312431            // look at all rows and columns
    24322432            double objectiveChange=0.0;
    2433             ((ClpSimplexDual *) this)->updateDualsInDual(rowArray_[0],columnArray_[0],rowArray_[1],
     2433            reinterpret_cast<ClpSimplexDual *> ( this)->updateDualsInDual(rowArray_[0],columnArray_[0],rowArray_[1],
    24342434                              0.0,objectiveChange,true);
    24352435            continue;
     
    24562456        }
    24572457        // do actual flips
    2458         ((ClpSimplexDual *) this)->flipBounds(rowArray_[0],columnArray_[0],theta_);
     2458        reinterpret_cast<ClpSimplexDual *> ( this)->flipBounds(rowArray_[0],columnArray_[0],theta_);
    24592459        //rowArray_[1]->expand();
    24602460        dualRowPivot_->updatePrimalSolution(rowArray_[1],
     
    24872487        int whatNext=housekeeping(objectiveChange);
    24882488        // and set bounds correctly
    2489         ((ClpSimplexDual *) this)->originalBound(sequenceIn_);
    2490         ((ClpSimplexDual *) this)->changeBound(sequenceOut_);
     2489        reinterpret_cast<ClpSimplexDual *> ( this)->originalBound(sequenceIn_);
     2490        reinterpret_cast<ClpSimplexDual *> ( this)->changeBound(sequenceOut_);
    24912491        if (whatNext==1) {
    24922492          problemStatus_ =-2; // refactorize
     
    29892989    assert (fabs(floor(gap+0.5)-gap)<1.0e-5);
    29902990    whichColumn[numJ]=iColumn;
    2991     bound[numJ]=(int) gap;
     2991    bound[numJ]=static_cast<int> (gap);
    29922992    if (elementByRow[j]>0.0) {
    29932993      flip[numJ]=1;
  • trunk/Clp/src/ClpSimplexPrimal.cpp

    r1303 r1321  
    469469    infeasibilityCost_=0.0;
    470470    createRim(1+4);
     471    delete nonLinearCost_;
     472    nonLinearCost_ = new ClpNonLinearCost(this);
    471473    nonLinearCost_->checkInfeasibilities(0.0);
    472474    sumPrimalInfeasibilities_=nonLinearCost_->sumInfeasibilities();
     
    853855  // If in primal and small dj give up
    854856  if ((specialOptions_&1024)!=0&&!numberPrimalInfeasibilities_&&numberDualInfeasibilities_) {
    855     double average = sumDualInfeasibilities_/((double) numberDualInfeasibilities_);
     857    double average = sumDualInfeasibilities_/(static_cast<double> (numberDualInfeasibilities_));
    856858    if (numberIterations_>300&&average<1.0e-4) {
    857859      numberDualInfeasibilities_ = 0;
     
    9991001      double most = 0.95;
    10001002      std::sort(dj_,dj_+n);
    1001       int which = (int) ((1.0-most)*((double) n));
     1003      int which = static_cast<int> ((1.0-most)*static_cast<double> (n));
    10021004      double take = -dj_[which]*infeasibilityCost_;
    10031005      //printf("XXXXZ inf cost %g take %g (range %g %g)\n",infeasibilityCost_,take,-dj_[0]*infeasibilityCost_,-dj_[n-1]*infeasibilityCost_);
     
    10971099      int ninfeas = nonLinearCost_->numberInfeasibilities();
    10981100      double sum = nonLinearCost_->sumInfeasibilities();
    1099       double average = sum/ ((double) ninfeas);
     1101      double average = sum/ static_cast<double> (ninfeas);
    11001102#ifdef COIN_DEVELOP
    11011103      if (handler_->logLevel()>0)
     
    11641166          numberDualInfeasibilities_=1; // carry on
    11651167          problemStatus_=-1;
    1166         }
    1167         if (infeasibilityCost_>=1.0e20||
    1168             numberDualInfeasibilities_==0) {
    1169           // we are infeasible - use as ray
    1170           delete [] ray_;
    1171           ray_ = new double [numberRows_];
    1172           CoinMemcpyN(dual_,numberRows_,ray_);
    1173           // and get feasible duals
    1174           infeasibilityCost_=0.0;
    1175           createRim(4);
    1176           nonLinearCost_->checkInfeasibilities(primalTolerance_);
    1177           gutsOfSolution(NULL,NULL,ifValuesPass!=0);
    1178           // so will exit
    1179           infeasibilityCost_=1.0e30;
    1180           // reset infeasibilities
    1181           sumPrimalInfeasibilities_=nonLinearCost_->sumInfeasibilities();;
    1182           numberPrimalInfeasibilities_=
    1183             nonLinearCost_->numberInfeasibilities();
    1184         }
    1185         if (infeasibilityCost_<1.0e20) {
    1186           infeasibilityCost_ *= 5.0;
    1187           // reset looping criterion
    1188           progress->reset();
    1189           changeMade_++; // say change made
    1190           handler_->message(CLP_PRIMAL_WEIGHT,messages_)
    1191             <<infeasibilityCost_
    1192             <<CoinMessageEol;
    1193           // put back original costs and then check
    1194           createRim(4);
    1195           nonLinearCost_->checkInfeasibilities(0.0);
    1196           gutsOfSolution(NULL,NULL,ifValuesPass!=0);
    1197           problemStatus_=-1; //continue
    1198           goToDual=false;
    1199         } else {
    1200           // say infeasible
    1201           problemStatus_ = 1;
     1168        } else if (numberDualInfeasibilities_==0&&largestDualError_>1.0e-2) {
     1169          goToDual=true;
     1170          factorization_->pivotTolerance(CoinMax(0.9,factorization_->pivotTolerance()));
     1171        }
     1172        if (!goToDual) {
     1173          if (infeasibilityCost_>=1.0e20||
     1174              numberDualInfeasibilities_==0) {
     1175            // we are infeasible - use as ray
     1176            delete [] ray_;
     1177            ray_ = new double [numberRows_];
     1178            CoinMemcpyN(dual_,numberRows_,ray_);
     1179            // and get feasible duals
     1180            infeasibilityCost_=0.0;
     1181            createRim(4);
     1182            nonLinearCost_->checkInfeasibilities(primalTolerance_);
     1183            gutsOfSolution(NULL,NULL,ifValuesPass!=0);
     1184            // so will exit
     1185            infeasibilityCost_=1.0e30;
     1186            // reset infeasibilities
     1187            sumPrimalInfeasibilities_=nonLinearCost_->sumInfeasibilities();;
     1188            numberPrimalInfeasibilities_=
     1189              nonLinearCost_->numberInfeasibilities();
     1190          }
     1191          if (infeasibilityCost_<1.0e20) {
     1192            infeasibilityCost_ *= 5.0;
     1193            // reset looping criterion
     1194            progress->reset();
     1195            changeMade_++; // say change made
     1196            handler_->message(CLP_PRIMAL_WEIGHT,messages_)
     1197              <<infeasibilityCost_
     1198              <<CoinMessageEol;
     1199            // put back original costs and then check
     1200            createRim(4);
     1201            nonLinearCost_->checkInfeasibilities(0.0);
     1202            gutsOfSolution(NULL,NULL,ifValuesPass!=0);
     1203            problemStatus_=-1; //continue
     1204            goToDual=false;
     1205          } else {
     1206            // say infeasible
     1207            problemStatus_ = 1;
     1208          }
    12021209        }
    12031210      }
     
    12201227          if (numberTimesOptimal_==1) {
    12211228            // better to have small tolerance even if slower
    1222             factorization_->zeroTolerance(1.0e-15);
     1229            factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(),1.0e-15));
    12231230          }
    12241231          lastCleaned=numberIterations_;
     
    13381345        unflag();
    13391346        if (sumDualInfeasibilities_<1.0e-3||
    1340             (sumDualInfeasibilities_/(double) numberDualInfeasibilities_)<1.0e-5||
     1347            (sumDualInfeasibilities_/static_cast<double> (numberDualInfeasibilities_))<1.0e-5||
    13411348            progress->lastIterationNumber(0)==numberIterations_) {
    13421349          if (!numberPrimalInfeasibilities_) {
     
    18721879  double theta2 = numberIterations_*nonLinearCost_->averageTheta();
    18731880  // Set average theta
    1874   nonLinearCost_->setAverageTheta((theta1+theta2)/((double) (numberIterations_+1)));
     1881  nonLinearCost_->setAverageTheta((theta1+theta2)/(static_cast<double> (numberIterations_+1)));
    18751882  //if (numberIterations_%1000==0)
    18761883  //printf("average theta is %g\n",nonLinearCost_->averageTheta());
     
    22142221    }
    22152222    if (numberNonZero)
    2216       perturbation /= (double) numberNonZero;
     2223      perturbation /= static_cast<double> (numberNonZero);
    22172224    else
    22182225      perturbation = 1.0e-1;
     
    22442251  // For now just no more than 0.1
    22452252  // printf("Pert type %d perturbation %g, maxF %g\n",type,perturbation,maximumFraction);
     2253  // seems much slower???#define SAVE_PERT
     2254#ifdef SAVE_PERT
     2255  if (2*numberColumns_>maximumPerturbationSize_) {
     2256    delete [] perturbationArray_;
     2257    maximumPerturbationSize_ = 2* numberColumns_;
     2258    perturbationArray_ = new double [maximumPerturbationSize_];
     2259    for (int iColumn=0;iColumn<maximumPerturbationSize_;iColumn++) {
     2260      perturbationArray_[iColumn] = randomNumberGenerator_.randomDouble();
     2261    }
     2262  }
     2263#endif
    22462264  if (type==1) {
    22472265    double tolerance = 100.0*primalTolerance_;
     
    22582276          double value = maximumFraction*(difference+1.0);
    22592277          value = CoinMin(value,0.1);
     2278#ifndef SAVE_PERT
    22602279          value *= randomNumberGenerator_.randomDouble();
     2280#else
     2281          value *= perturbationArray_[2*iSequence];
     2282#endif
    22612283          if (solutionValue-lowerValue<=primalTolerance_) {
    22622284            lower_[iSequence] -= value;
     
    23002322        double value = perturbation*maximumFraction;
    23012323        value = CoinMin(value,0.1);
     2324#ifndef SAVE_PERT
     2325        value *= randomNumberGenerator_.randomDouble();
     2326#else
     2327        value *= perturbationArray_[2*i+1];
     2328#endif
    23022329        value *= randomNumberGenerator_.randomDouble();
    23032330        if (savePerturbation!=50) {
     
    27422769        // major error
    27432770        // better to have small tolerance even if slower
    2744         factorization_->zeroTolerance(1.0e-15);
     2771        factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(),1.0e-15));
    27452772        int maxFactor = factorization_->maximumPivots();
    27462773        if (maxFactor>10) {
  • trunk/Clp/src/ClpSolve.cpp

    r1311 r1321  
    1515#include "ClpSimplex.hpp"
    1616#include "ClpSimplexOther.hpp"
     17#include "ClpSimplexDual.hpp"
    1718#ifndef SLIM_CLP
    1819#include "ClpQuadraticObjective.hpp"
     
    414415  ClpSimplex * model2 = this;
    415416  bool interrupt = (options.getSpecialOption(2)==0);
    416   CoinSighandler_t saveSignal=SIG_DFL;
     417  CoinSighandler_t saveSignal=static_cast<CoinSighandler_t> (0);
    417418  if (interrupt) {
    418419    currentModel = model2;
     
    937938      Idiot info(*model2);
    938939      // Get average number of elements per column
    939       double ratio  = ((double) numberElements/(double) numberColumns);
     940      double ratio  = static_cast<double> (numberElements)/static_cast<double> (numberColumns);
    940941      // look at rhs
    941942      int iRow;
     
    11051106      Idiot info(*model2);
    11061107      // Get average number of elements per column
    1107       double ratio  = ((double) numberElements/(double) numberColumns);
     1108      double ratio  = static_cast<double> (numberElements)/static_cast<double> (numberColumns);
    11081109      // look at rhs
    11091110      int iRow;
     
    12111212          }
    12121213          if (ratio<3.0) {
    1213             nPasses=(int) ((ratio*(double) nPasses)/4.0); // probably not worh it
     1214            nPasses=static_cast<int> (ratio*static_cast<double> (nPasses)/4.0); // probably not worth it
    12141215          } else {
    12151216            nPasses = CoinMax(nPasses,5);
     
    12221223            nPasses=CoinMin(nPasses,71);
    12231224          } else if (nPasses==5&&ratio>5.0) {
    1224             nPasses = (int) (((double) nPasses)*(ratio/5.0)); // increase if lots of elements per column
     1225            nPasses = static_cast<int> (static_cast<double> (nPasses)*(ratio/5.0)); // increase if lots of elements per column
    12251226          }
    12261227          if (nPasses<=5&&!plusMinus)
     
    15711572    double ratio=3;
    15721573    if (maxSprintPass>1000) {
    1573       ratio = ((double) maxSprintPass)*0.0001;
     1574      ratio = static_cast<double> (maxSprintPass)*0.0001;
    15741575      ratio = CoinMax(ratio,1.1);
    15751576      maxSprintPass= maxSprintPass %1000;
     
    15791580    }
    15801581    // Just take this number of columns in small problem
    1581     int smallNumberColumns = (int) CoinMin(ratio*numberRows,(double) numberColumns);
     1582    int smallNumberColumns = static_cast<int> (CoinMin(ratio*numberRows,static_cast<double> (numberColumns)));
    15821583    smallNumberColumns = CoinMax(smallNumberColumns,3000);
    15831584    smallNumberColumns = CoinMin(smallNumberColumns,numberColumns);
     
    17791780        lastObjective = small.objectiveValue()*optimizationDirection_;
    17801781        double tolerance;
    1781         double averageNegDj = sumNegative/((double) (numberNegative+1));
     1782        double averageNegDj = sumNegative/static_cast<double> (numberNegative+1);
    17821783        if (numberNegative+numberSort>smallNumberColumns)
    17831784          tolerance = -dualTolerance_;
     
    21572158        }
    21582159        // model2->allSlackBasis();
    2159         if (gap<1.0e-3*((double) (numberRows+numberColumns))) {
     2160        if (gap<1.0e-3*static_cast<double> (numberRows+numberColumns)) {
    21602161          if (saveUpper) {
    21612162            int numberRows = model2->numberRows();
     
    26582659  numberTimes_ = 0;
    26592660  numberBadTimes_ = 0;
     2661  numberReallyBadTimes_ = 0;
     2662  numberTimesFlagged_ = 0;
    26602663  model_ = NULL;
    26612664  oddState_=0;
     
    26992702  numberTimes_ = rhs.numberTimes_;
    27002703  numberBadTimes_ = rhs.numberBadTimes_;
     2704  numberReallyBadTimes_ = rhs.numberReallyBadTimes_;
     2705  numberTimesFlagged_ = rhs.numberTimesFlagged_;
    27012706  model_ = rhs.model_;
    27022707  oddState_=rhs.oddState_;
     
    27502755    numberTimes_ = rhs.numberTimes_;
    27512756    numberBadTimes_ = rhs.numberBadTimes_;
     2757    numberReallyBadTimes_ = rhs.numberReallyBadTimes_;
     2758    numberTimesFlagged_ = rhs.numberTimesFlagged_;
    27522759    model_ = rhs.model_;
    27532760    oddState_=rhs.oddState_;
     
    27772784  int numberInfeasibilities;
    27782785  int iterationNumber = model_->numberIterations();
     2786  numberTimesFlagged_=0;
    27792787  if (model_->algorithm()<0) {
    27802788    // dual
     
    28532861          if (model_->dualBound()<1.0e17) {
    28542862            model_->setDualBound(model_->dualBound()*1.1);
     2863            static_cast<ClpSimplexDual *>(model_)->resetFakeBounds(0);
    28552864          }
    28562865        } else {
     
    29522961  numberTimes_ = 0;
    29532962  numberBadTimes_ = 0;
     2963  numberReallyBadTimes_ = 0;
     2964  numberTimesFlagged_ = 0;
    29542965  oddState_=0;
    29552966}
     
    31143125ClpSimplex::solve(CoinStructuredModel * model)
    31153126{
     3127  double time1 = CoinCpuTime();
    31163128  // analyze structure
    31173129  int numberColumns = model->numberColumns();
     
    31193131  int numberColumnBlocks = model->numberColumnBlocks();
    31203132  int numberElementBlocks = model->numberElementBlocks();
     3133  if (numberElementBlocks==1) {
     3134    loadProblem(*model,false);
     3135    return dual();
     3136  }
     3137  // For now just get top level structure
     3138  CoinModelBlockInfo * blockInfo = new CoinModelBlockInfo [numberElementBlocks];
     3139  for (int i=0;i<numberElementBlocks;i++) {
     3140    CoinStructuredModel * subModel =
     3141      dynamic_cast<CoinStructuredModel *>(model->block(i));
     3142    CoinModel * thisBlock;
     3143    if (subModel) {
     3144      thisBlock=subModel->coinModelBlock(blockInfo[i]);
     3145      model->setCoinModel(thisBlock,i);
     3146    } else {
     3147      thisBlock = dynamic_cast<CoinModel *>(model->block(i));
     3148      assert (thisBlock);
     3149    }
     3150  }
    31213151  if (numberRowBlocks==numberColumnBlocks||numberRowBlocks==numberColumnBlocks+1) {
    31223152    // looks like Dantzig-Wolfe
     
    31333163      int iBlock;
    31343164      for (iBlock = 0;iBlock<numberElementBlocks;iBlock++) {
    3135         int iRowBlock = model->blockType(iBlock).rowBlock;
     3165        int iRowBlock = blockInfo[iBlock].rowBlock;
    31363166        rowCounts[iRowBlock]++;
    3137         int iColumnBlock =model->blockType(iBlock).columnBlock;
     3167        int iColumnBlock =blockInfo[iBlock].columnBlock;
    31383168        columnCounts[iColumnBlock]++;
    31393169      }
     
    31593189      }
    31603190      for (iBlock = 0;iBlock<numberElementBlocks;iBlock++) {
    3161         int iColumnBlock = model->blockType(iBlock).columnBlock;
     3191        int iColumnBlock = blockInfo[iBlock].columnBlock;
    31623192        whichBlock[columnCounts[iColumnBlock]]=iBlock;
    31633193        columnCounts[iColumnBlock]++;
     
    31703200        if (count==1) {
    31713201          int kBlock = whichBlock[columnCounts[iBlock]];
    3172           int iRowBlock = model->blockType(kBlock).rowBlock;
     3202          int iRowBlock = blockInfo[kBlock].rowBlock;
    31733203          if (iRowBlock==masterRowBlock) {
    31743204            if (masterColumnBlock==-1) {
     
    31913221      ClpSimplex * sub = new ClpSimplex [numberBlocks];
    31923222      ClpSimplex master;
     3223      // Set offset
     3224      master.setObjectiveOffset(model->objectiveOffset());
    31933225      kBlock=0;
    31943226      int masterBlock=-1;
     
    32003232        for (int j=start;j<end;j++) {
    32013233          int jBlock = whichBlock[j];
    3202           int iRowBlock = model->blockType(jBlock).rowBlock;
    3203           int iColumnBlock =model->blockType(jBlock).columnBlock;
     3234          int iRowBlock = blockInfo[jBlock].rowBlock;
     3235          int iColumnBlock =blockInfo[jBlock].columnBlock;
    32043236          assert (iColumnBlock==iBlock);
    32053237          if (iColumnBlock!=masterColumnBlock&&iRowBlock==masterRowBlock) {
    32063238            // top matrix
    3207             top[kBlock]=model->block(jBlock)->packedMatrix();
     3239            top[kBlock]=model->coinBlock(jBlock)->packedMatrix();
    32083240          } else {
    32093241            const CoinPackedMatrix * matrix
    3210               = model->block(jBlock)->packedMatrix();
     3242              = model->coinBlock(jBlock)->packedMatrix();
    32113243            // Get pointers to arrays
    32123244            const double * rowLower;
     
    32213253              sub[kBlock].loadProblem(*matrix,columnLower,columnUpper,
    32223254                                objective,rowLower,rowUpper);
     3255              if (true) {
     3256                double * lower = sub[kBlock].columnLower();
     3257                double * upper = sub[kBlock].columnUpper();
     3258                int n = sub[kBlock].numberColumns();
     3259                for (int i=0;i<n;i++) {
     3260                  lower[i]=CoinMax(-1.0e8,lower[i]);
     3261                  upper[i]=CoinMin(1.0e8,upper[i]);
     3262                }
     3263              }
     3264              if (optimizationDirection_<0.0) {
     3265                double * obj = sub[kBlock].objective();
     3266                int n = sub[kBlock].numberColumns();
     3267                for (int i=0;i<n;i++)
     3268                  obj[i] = - obj[i];
     3269              }
     3270              if (this->factorizationFrequency()==200) {
     3271                // User did not touch preset
     3272                sub[kBlock].defaultFactorizationFrequency();
     3273              } else {
     3274                // make sure model has correct value
     3275                sub[kBlock].setFactorizationFrequency(this->factorizationFrequency());
     3276              }
     3277              sub[kBlock].setPerturbation(50);
    32233278              // Set columnCounts to be diagonal block index for cleanup
    32243279              columnCounts[kBlock]=jBlock;
     
    32283283              master.loadProblem(*matrix,columnLower,columnUpper,
    32293284                                objective,rowLower,rowUpper);
     3285              if (optimizationDirection_<0.0) {
     3286                double * obj = master.objective();
     3287                int n = master.numberColumns();
     3288                for (int i=0;i<n;i++)
     3289                  obj[i] = - obj[i];
     3290              }
    32303291            }
    32313292          }
     
    32353296      }
    32363297      delete [] whichBlock;
     3298      delete [] blockInfo;
    32373299      // For now master must have been defined (does not have to have columns)
    32383300      assert (master.numberRows());
    32393301      assert (masterBlock>=0);
     3302      int numberMasterRows = master.numberRows();
    32403303      // Overkill in terms of space
    3241       int numberMasterRows = master.numberRows();
    3242       int * columnAdd = new int[numberBlocks+1];
    3243       int * rowAdd = new int[numberBlocks*(numberMasterRows+1)];
    3244       double * elementAdd = new double[numberBlocks*(numberMasterRows+1)];
    3245       double * objective = new double[numberBlocks];
     3304      int spaceNeeded = CoinMax(numberBlocks*(numberMasterRows+1),
     3305                                2*numberMasterRows);
     3306      int * rowAdd = new int[spaceNeeded];
     3307      double * elementAdd = new double[spaceNeeded];
     3308      spaceNeeded = numberBlocks;
     3309      int * columnAdd = new int[spaceNeeded+1];
     3310      double * objective = new double[spaceNeeded];
     3311      // Add in costed slacks
     3312      int firstArtificial = master.numberColumns();
     3313      int lastArtificial = firstArtificial;
     3314      if (true) {
     3315        const double * lower = master.rowLower();
     3316        const double * upper = master.rowUpper();
     3317        int kCol=0;
     3318        for (int iRow=0;iRow<numberMasterRows;iRow++) {
     3319          if (lower[iRow]>-1.0e10) {
     3320            rowAdd[kCol]=iRow;
     3321            elementAdd[kCol++]=1.0;
     3322          }
     3323          if (upper[iRow]<1.0e10) {
     3324            rowAdd[kCol]=iRow;
     3325            elementAdd[kCol++]=-1.0;
     3326          }
     3327