Changeset 1087


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

try and make faster

Location:
trunk/Cbc/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcBranchActual.cpp

    r1067 r1087  
    37883788(const CbcBranchingObject* brObj, const bool replaceIfOverlap)
    37893789{
     3790#ifndef NDEBUG
    37903791  const CbcFixingBranchingObject* br =
    37913792    dynamic_cast<const CbcFixingBranchingObject*>(brObj);
    37923793  assert(br);
     3794#endif
    37933795  // If two FixingBranchingObject's have the same base object then it's pretty
    37943796  // much guaranteed
     
    44614463CbcGeneralDepth::CbcGeneralDepth ()
    44624464  : CbcGeneral(),
    4463     maximumDepth_(-1),
     4465    maximumDepth_(0),
    44644466    whichSolution_(-1),
    44654467    numberNodes_(0),
     
    44764478    nodeInfo_(NULL)
    44774479{
    4478   if (maximumDepth_>=0) {
     4480  int nNodes = maximumNodes();
     4481  if (nNodes) {
    44794482    nodeInfo_ = new ClpNodeStuff();
    44804483    ClpNodeStuff * info = nodeInfo_;
    4481     info->nDepth_=maximumDepth_;
    4482     int n = (1<<maximumDepth_)+1+maximumDepth_;
    4483     ClpNode ** nodeInfo = new ClpNode * [n];
    4484     for (int i=0;i<n;i++)
     4484    // for reduced costs and duals
     4485    info->solverOptions_ |= 7;
     4486    if (maximumDepth_>0) {
     4487      info->nDepth_ = maximumDepth_;
     4488    } else {
     4489      info->nDepth_ = - maximumDepth_;
     4490      info->solverOptions_ |= 32;
     4491    }
     4492    ClpNode ** nodeInfo = new ClpNode * [nNodes];
     4493    for (int i=0;i<nNodes;i++)
    44854494      nodeInfo[i]=NULL;
    44864495    info->nodeInfo_ = nodeInfo;
     
    44974506  whichSolution_ = -1;
    44984507  numberNodes_ = 0;
    4499   if (maximumDepth_>=0) {
     4508  int nNodes = maximumNodes();
     4509  if (nNodes) {
    45004510    assert (rhs.nodeInfo_);
    45014511    nodeInfo_ = new ClpNodeStuff(*rhs.nodeInfo_);
    45024512    ClpNodeStuff * info = nodeInfo_;
    4503     info->nDepth_=maximumDepth_;
     4513    if (maximumDepth_>0) {
     4514      info->nDepth_ = maximumDepth_;
     4515    } else {
     4516      info->nDepth_ = - maximumDepth_;
     4517      info->solverOptions_ |= 32;
     4518    }
    45044519    if (!info->nodeInfo_) {
    4505       int n = (1<<maximumDepth_)+1+maximumDepth_;
    4506       ClpNode ** nodeInfo = new ClpNode * [n];
    4507       for (int i=0;i<n;i++)
     4520      ClpNode ** nodeInfo = new ClpNode * [nNodes];
     4521      for (int i=0;i<nNodes;i++)
    45084522        nodeInfo[i]=NULL;
    45094523      info->nodeInfo_ = nodeInfo;
     
    45314545    whichSolution_ = -1;
    45324546    numberNodes_ = 0;
    4533     if (maximumDepth_>=0) {
     4547    if (maximumDepth_) {
    45344548      assert (rhs.nodeInfo_);
    45354549      nodeInfo_ = new ClpNodeStuff(*rhs.nodeInfo_);
     
    45454559{
    45464560  delete nodeInfo_;
     4561}
     4562// Return maximum number of nodes
     4563int
     4564CbcGeneralDepth::maximumNodes() const
     4565{
     4566  int n;
     4567  if (maximumDepth_>0)
     4568    n = (1<<maximumDepth_)+1+maximumDepth_;
     4569  else if (maximumDepth_<0)
     4570    n = 1+1-maximumDepth_;
     4571  else
     4572    n = 0;
     4573  return n;
    45474574}
    45484575
     
    45764603                            numberDownInfeasible,
    45774604                            numberUpInfeasible,numberIntegers);
    4578       info->presolveType_= 1; //1 later
     4605      info->presolveType_= 1;
    45794606      delete [] down;
    45804607      delete [] up;
     
    46734700  // skip solution
    46744701  branch->numberSubProblems_ = numberDo;
     4702  // If parentBranch_ back in then will have to be 2*
     4703  branch->numberSubLeft_ = numberDo;
    46754704  branch->setNumberBranches(numberDo);
    46764705  CbcSubProblem * sub = new CbcSubProblem[numberDo];
     
    47244753    // create subproblem
    47254754    sub[iProb]=CbcSubProblem(clpSolver,lowerBefore,upperBefore,
    4726                              node->statusArray());
     4755                             node->statusArray(),node->depth());
    47274756    sub[iProb].objectiveValue_ = node->objectiveValue();
    47284757    sub[iProb].sumInfeasibilities_ = node->sumInfeasibilities();
     
    47714800   node_(NULL),
    47724801   numberSubProblems_(0),
     4802   numberSubLeft_(0),
     4803   whichNode_(-1),
    47734804   numberRows_(0)
    47744805{
     4806  //  printf("CbcGeneral %x default constructor\n",this);
    47754807}
    47764808
     
    47814813   node_(NULL),
    47824814   numberSubProblems_(0),
     4815   numberSubLeft_(0),
     4816   whichNode_(-1),
    47834817   numberRows_(0)
    47844818{
     4819  //printf("CbcGeneral %x useful constructor\n",this);
    47854820}
    47864821
     
    47914826   node_(rhs.node_),
    47924827   numberSubProblems_(rhs.numberSubProblems_),
     4828   numberSubLeft_(rhs.numberSubLeft_),
     4829   whichNode_(rhs.whichNode_),
    47934830   numberRows_(rhs.numberRows_)
    47944831{
     4832  abort();
    47954833  if (numberSubProblems_) {
    47964834    subProblems_ = new CbcSubProblem[numberSubProblems_];
     
    48054843{
    48064844  if (this != &rhs) {
     4845    abort();
    48074846    CbcBranchingObject::operator=(rhs);
    48084847    delete [] subProblems_;
    48094848    numberSubProblems_ = rhs.numberSubProblems_;
     4849    numberSubLeft_ = rhs.numberSubLeft_;
     4850    whichNode_ = rhs.whichNode_;
    48104851    numberRows_ = rhs.numberRows_;
    48114852    if (numberSubProblems_) {
     
    48304871CbcGeneralBranchingObject::~CbcGeneralBranchingObject ()
    48314872{
     4873  //printf("CbcGeneral %x destructor\n",this);
    48324874  delete [] subProblems_;
    48334875}
     
    48364878CbcGeneralBranchingObject::branch()
    48374879{
    4838   assert (node_);
    48394880  double cutoff=model_->getCutoff();
    4840   bool applied=false;
    4841   while (numberBranchesLeft()) {
    4842     int which = branchIndex();
     4881  if (whichNode_<0) {
     4882    assert (node_);
     4883    bool applied=false;
     4884    while (numberBranchesLeft()) {
     4885      int which = branchIndex();
     4886      decrementNumberBranchesLeft();
     4887      CbcSubProblem * thisProb = subProblems_+which;
     4888      if (thisProb->objectiveValue_<cutoff) {
     4889        //printf("branch %x (sub %x) which now %d\n",this,
     4890        //     subProblems_,which);
     4891        OsiSolverInterface * solver = model_->solver();
     4892        thisProb->apply(solver);
     4893        OsiClpSolverInterface * clpSolver
     4894          = dynamic_cast<OsiClpSolverInterface *> (solver);
     4895        assert (clpSolver);
     4896        // Move status to basis
     4897        clpSolver->setWarmStart(NULL);
     4898        //ClpSimplex * simplex = clpSolver->getModelPtr();
     4899        node_->setObjectiveValue(thisProb->objectiveValue_);
     4900        node_->setSumInfeasibilities(thisProb->sumInfeasibilities_);
     4901        node_->setNumberUnsatisfied(thisProb->numberInfeasibilities_);
     4902        applied=true;
     4903        doingDoneBranch=true;
     4904        break;
     4905      } else if (numberBranchesLeft()) {
     4906        node_->nodeInfo()->branchedOn() ;
     4907      }
     4908    }
     4909    if (!applied) {
     4910      // no good one
     4911      node_->setObjectiveValue(cutoff+1.0e20);
     4912      node_->setSumInfeasibilities(1.0);
     4913      node_->setNumberUnsatisfied(1);
     4914      assert (whichNode_<0);
     4915    }
     4916  } else {
    48434917    decrementNumberBranchesLeft();
    4844     CbcSubProblem * thisProb = subProblems_+which;
    4845     if (thisProb->objectiveValue_<cutoff) {
    4846       //printf("branch %x (sub %x) which now %d\n",this,
    4847       //     subProblems_,which);
    4848       OsiSolverInterface * solver = model_->solver();
    4849       thisProb->apply(solver);
    4850       OsiClpSolverInterface * clpSolver
    4851         = dynamic_cast<OsiClpSolverInterface *> (solver);
    4852       assert (clpSolver);
    4853       // Move status to basis
    4854       clpSolver->setWarmStart(NULL);
    4855       //ClpSimplex * simplex = clpSolver->getModelPtr();
    4856       node_->setObjectiveValue(thisProb->objectiveValue_);
    4857       node_->setSumInfeasibilities(thisProb->sumInfeasibilities_);
    4858       node_->setNumberUnsatisfied(thisProb->numberInfeasibilities_);
    4859       applied=true;
    4860       doingDoneBranch=true;
    4861       break;
    4862     } else if (numberBranchesLeft()) {
    4863       node_->nodeInfo()->branchedOn() ;
    4864     }
    4865   }
    4866   if (!applied) {
    4867     // no good one
    4868     node_->setObjectiveValue(cutoff+1.0e20);
    4869     node_->setSumInfeasibilities(1.0);
    4870     node_->setNumberUnsatisfied(1);
     4918    CbcSubProblem * thisProb = subProblems_+whichNode_;
     4919    assert (thisProb->objectiveValue_<cutoff);
     4920    OsiSolverInterface * solver = model_->solver();
     4921    thisProb->apply(solver);
     4922    OsiClpSolverInterface * clpSolver
     4923      = dynamic_cast<OsiClpSolverInterface *> (solver);
     4924    assert (clpSolver);
     4925    // Move status to basis
     4926    clpSolver->setWarmStart(NULL);
    48714927  }
    48724928  return 0.0;
     
    48944950CbcGeneralBranchingObject::print()
    48954951{
    4896   printf("CbcGeneralObject has %d subproblems\n",numberSubProblems_);
     4952  //printf("CbcGeneralObject has %d subproblems\n",numberSubProblems_);
    48974953}
    48984954// Fill in current objective etc
     
    49364992  throw("must implement");
    49374993}
     4994
     4995// Default Constructor
     4996CbcOneGeneralBranchingObject::CbcOneGeneralBranchingObject()
     4997  :CbcBranchingObject(),
     4998   object_(NULL),
     4999   whichOne_(-1)
     5000{
     5001  //printf("CbcOneGeneral %x default constructor\n",this);
     5002}
     5003
     5004// Useful constructor
     5005CbcOneGeneralBranchingObject::CbcOneGeneralBranchingObject (CbcModel * model,
     5006                                 CbcGeneralBranchingObject * object,
     5007                                 int whichOne)
     5008  :CbcBranchingObject(model,-1,-1,0.5),
     5009   object_(object),
     5010   whichOne_(whichOne)
     5011{
     5012  //printf("CbcOneGeneral %x useful constructor object %x %d left\n",this,
     5013  //     object_,object_->numberSubLeft_);
     5014  numberBranches_=1;
     5015}
     5016
     5017// Copy constructor
     5018CbcOneGeneralBranchingObject::CbcOneGeneralBranchingObject ( const CbcOneGeneralBranchingObject & rhs)
     5019  :CbcBranchingObject(rhs),
     5020   object_(rhs.object_),
     5021   whichOne_(rhs.whichOne_)
     5022{
     5023}
     5024
     5025// Assignment operator
     5026CbcOneGeneralBranchingObject &
     5027CbcOneGeneralBranchingObject::operator=( const CbcOneGeneralBranchingObject& rhs)
     5028{
     5029  if (this != &rhs) {
     5030    CbcBranchingObject::operator=(rhs);
     5031    object_ = rhs.object_;
     5032    whichOne_ = rhs.whichOne_;
     5033  }
     5034  return *this;
     5035}
     5036CbcBranchingObject *
     5037CbcOneGeneralBranchingObject::clone() const
     5038{
     5039  return (new CbcOneGeneralBranchingObject(*this));
     5040}
     5041
     5042
     5043// Destructor
     5044CbcOneGeneralBranchingObject::~CbcOneGeneralBranchingObject ()
     5045{
     5046  //printf("CbcOneGeneral %x destructor object %x %d left\n",this,
     5047  // object_,object_->numberSubLeft_);
     5048  assert (object_->numberSubLeft_>0&&
     5049          object_->numberSubLeft_<1000000);
     5050  if (!object_->decrementNumberLeft()) {
     5051    // printf("CbcGeneral %x yy destructor\n",object_);
     5052    delete object_;
     5053  }
     5054}
     5055double
     5056CbcOneGeneralBranchingObject::branch()
     5057{
     5058  assert (numberBranchesLeft());
     5059  decrementNumberBranchesLeft();
     5060  assert (!numberBranchesLeft());
     5061  object_->setWhichNode(whichOne_);
     5062  object_->branch();
     5063  return 0.0;
     5064}
     5065/* Double checks in case node can change its mind!
     5066   Can change objective etc */
     5067void
     5068CbcOneGeneralBranchingObject::checkIsCutoff(double cutoff)
     5069{
     5070  assert (numberBranchesLeft());
     5071}
     5072// Print what would happen 
     5073void
     5074CbcOneGeneralBranchingObject::print()
     5075{
     5076  //printf("CbcOneGeneralObject has 1 subproblem\n");
     5077}
     5078/** Compare the original object of \c this with the original object of \c
     5079    brObj. Assumes that there is an ordering of the original objects.
     5080    This method should be invoked only if \c this and brObj are of the same
     5081    type.
     5082    Return negative/0/positive depending on whether \c this is
     5083    smaller/same/larger than the argument.
     5084*/
     5085int
     5086CbcOneGeneralBranchingObject::compareOriginalObject
     5087(const CbcBranchingObject* brObj) const
     5088{
     5089  throw("must implement");
     5090}
     5091
     5092/** Compare the \c this with \c brObj. \c this and \c brObj must be os the
     5093    same type and must have the same original object, but they may have
     5094    different feasible regions.
     5095    Return the appropriate CbcRangeCompare value (first argument being the
     5096    sub/superset if that's the case). In case of overlap (and if \c
     5097    replaceIfOverlap is true) replace the current branching object with one
     5098    whose feasible region is the overlap.
     5099*/
     5100CbcRangeCompare
     5101CbcOneGeneralBranchingObject::compareBranchingObject
     5102(const CbcBranchingObject* brObj, const bool replaceIfOverlap)
     5103{
     5104  throw("must implement");
     5105}
    49385106// Default Constructor
    49395107CbcSubProblem::CbcSubProblem()
     
    49425110    variables_(NULL),
    49435111    newBounds_(NULL),
    4944     statusDifference_(NULL),
     5112    status_(NULL),
     5113    depth_(0),
    49455114    numberChangedBounds_(0),
    49465115    numberInfeasibilities_(0)
     
    49525121                              const double * lastLower,
    49535122                              const double * lastUpper,
    4954                               const unsigned char * status)
     5123                              const unsigned char * status,
     5124                              int depth)
    49555125  : objectiveValue_(0.0),
    49565126    sumInfeasibilities_(0.0),
    49575127    variables_(NULL),
    49585128    newBounds_(NULL),
    4959     statusDifference_(NULL),
     5129    status_(NULL),
     5130    depth_(depth),
    49605131    numberChangedBounds_(0),
    49615132    numberInfeasibilities_(0)
     
    50075178  assert (clpSolver);
    50085179  // Do difference
    5009   statusDifference_ = clpSolver->getBasisDiff(status);
     5180  // Current basis
     5181  status_ = clpSolver->getBasis(status);
    50105182}
    50115183
     
    50165188    variables_(NULL),
    50175189    newBounds_(NULL),
    5018     statusDifference_(NULL),
     5190    status_(NULL),
     5191    depth_(rhs.depth_),
    50195192    numberChangedBounds_(rhs.numberChangedBounds_),
    50205193    numberInfeasibilities_(rhs.numberInfeasibilities_)
     
    50245197    newBounds_ = CoinCopyOfArray(rhs.newBounds_,numberChangedBounds_);
    50255198  }
    5026   if (rhs.statusDifference_) {
    5027     statusDifference_ = rhs.statusDifference_->clone();
     5199  if (rhs.status_) {
     5200    status_ = new CoinWarmStartBasis(*rhs.status_);
    50285201  }
    50295202}
     
    50365209    delete [] variables_;
    50375210    delete [] newBounds_;
    5038     delete statusDifference_;
     5211    delete status_;
    50395212    objectiveValue_ = rhs.objectiveValue_;
    50405213    sumInfeasibilities_ = rhs.sumInfeasibilities_;
     5214    depth_ = rhs.depth_;
    50415215    numberChangedBounds_ = rhs.numberChangedBounds_;
    50425216    numberInfeasibilities_ = rhs.numberInfeasibilities_;
     
    50485222      newBounds_ = NULL;
    50495223    }
    5050     if (rhs.statusDifference_) {
    5051       statusDifference_ = rhs.statusDifference_->clone();
     5224    if (rhs.status_) {
     5225      status_ = new CoinWarmStartBasis(*rhs.status_);
    50525226    } else {
    5053       statusDifference_ = NULL;
     5227      status_ = NULL;
    50545228    }
    50555229  }
     
    50625236  delete [] variables_;
    50635237  delete [] newBounds_;
    5064   delete statusDifference_;
     5238  delete status_;
    50655239}
    50665240// Apply subproblem
    50675241void
    5068 CbcSubProblem::apply(OsiSolverInterface * solver)
     5242CbcSubProblem::apply(OsiSolverInterface * solver, int what) const
    50695243{
    50705244  int i;
    5071   for (i=0;i<numberChangedBounds_;i++) {
    5072     int variable = variables_[i];
    5073     int k = variable&0x3fffffff;
    5074     if ((variable&0x80000000)==0) {
    5075       // lower bound changing
    5076       //#define CBC_PRINT2
     5245  if ((what&1)!=0) {
     5246    int nSame=0;
     5247    for (i=0;i<numberChangedBounds_;i++) {
     5248      int variable = variables_[i];
     5249      int k = variable&0x3fffffff;
     5250      if ((variable&0x80000000)==0) {
     5251        // lower bound changing
     5252        //#define CBC_PRINT2
    50775253#ifdef CBC_PRINT2
    5078       if(solver->getColLower()[k]!=newBounds_[i])
    5079         printf("lower change for column %d - from %g to %g\n",k,solver->getColLower()[k],newBounds_[i]);
     5254        if(solver->getColLower()[k]!=newBounds_[i])
     5255          printf("lower change for column %d - from %g to %g\n",k,solver->getColLower()[k],newBounds_[i]);
    50805256#endif
    50815257#ifndef NDEBUG
    5082       if ((variable&0x40000000)==0&&true) {
    5083         double oldValue = solver->getColLower()[k];
    5084         assert (newBounds_[i]>oldValue-1.0e-8);
    5085         if (newBounds_[i]<oldValue+1.0e-8)
    5086           printf("bad null lower change for column %d - bound %g\n",k,oldValue);
    5087       }
    5088 #endif
    5089       solver->setColLower(k,newBounds_[i]);
    5090     } else {
    5091       // upper bound changing
     5258        if ((variable&0x40000000)==0&&true) {
     5259          double oldValue = solver->getColLower()[k];
     5260          assert (newBounds_[i]>oldValue-1.0e-8);
     5261          if (newBounds_[i]<oldValue+1.0e-8) {
    50925262#ifdef CBC_PRINT2
    5093       if(solver->getColUpper()[k]!=newBounds_[i])
    5094         printf("upper change for column %d - from %g to %g\n",k,solver->getColUpper()[k],newBounds_[i]);
     5263            printf("bad null lower change for column %d - bound %g\n",k,oldValue);
     5264#endif
     5265            if (newBounds_[i]==oldValue)
     5266              nSame++;
     5267          }
     5268        }
     5269#endif
     5270        solver->setColLower(k,newBounds_[i]);
     5271      } else {
     5272        // upper bound changing
     5273#ifdef CBC_PRINT2
     5274        if(solver->getColUpper()[k]!=newBounds_[i])
     5275          printf("upper change for column %d - from %g to %g\n",k,solver->getColUpper()[k],newBounds_[i]);
    50955276#endif
    50965277#ifndef NDEBUG
    5097       if ((variable&0x40000000)==0&&true) {
    5098         double oldValue = solver->getColUpper()[k];
    5099         assert (newBounds_[i]<oldValue+1.0e-8);
    5100         if (newBounds_[i]>oldValue-1.0e-8)
    5101           printf("bad null upper change for column %d - bound %g\n",k,oldValue);
    5102       }
    5103 #endif
    5104       solver->setColUpper(k,newBounds_[i]);
    5105     }
    5106   }
    5107   OsiClpSolverInterface * clpSolver
    5108     = dynamic_cast<OsiClpSolverInterface *> (solver);
    5109   assert (clpSolver);
    5110   // Current basis
    5111   CoinWarmStartBasis * basis=clpSolver->getPointerToWarmStart();
    5112   basis->applyDiff(statusDifference_);
    5113   clpSolver->setBasis(*basis);
     5278        if ((variable&0x40000000)==0&&true) {
     5279          double oldValue = solver->getColUpper()[k];
     5280          assert (newBounds_[i]<oldValue+1.0e-8);
     5281          if (newBounds_[i]>oldValue-1.0e-8) {
     5282#ifdef CBC_PRINT2
     5283            printf("bad null upper change for column %d - bound %g\n",k,oldValue);
     5284#endif
     5285            if (newBounds_[i]==oldValue)
     5286              nSame++;
     5287          }
     5288        }
     5289#endif
     5290        solver->setColUpper(k,newBounds_[i]);
     5291      }
     5292    }
     5293    if (nSame&&(nSame<numberChangedBounds_||(what&3)!=3))
     5294      printf("%d changes out of %d redundant %d\n",
     5295             nSame,numberChangedBounds_,what);
     5296    else if (numberChangedBounds_&&what==7&&!nSame)
     5297      printf("%d good changes %d\n",
     5298             numberChangedBounds_,what);
     5299  }
     5300#if 0
     5301  if ((what&2)!=0) {
     5302    OsiClpSolverInterface * clpSolver
     5303      = dynamic_cast<OsiClpSolverInterface *> (solver);
     5304    assert (clpSolver);
     5305    //assert (clpSolver->getNumRows()==numberRows_);
     5306    //clpSolver->setBasis(*status_);
     5307    // Current basis
     5308    CoinWarmStartBasis * basis=clpSolver->getPointerToWarmStart();
     5309    printf("BBBB\n");
     5310    basis->print();
     5311    assert (basis->fullBasis());
     5312    basis->applyDiff(status_);
     5313    printf("diff applied %x\n",status_);
     5314    printf("CCCC\n");
     5315    basis->print();
     5316    assert (basis->fullBasis());
     5317#ifndef NDEBUG
     5318    if (!basis->fullBasis())
     5319      printf("Debug this basis!!\n");
     5320#endif
     5321    clpSolver->setBasis(*basis);
     5322  }
     5323#endif
     5324  if ((what&8)!=0) {
     5325    OsiClpSolverInterface * clpSolver
     5326      = dynamic_cast<OsiClpSolverInterface *> (solver);
     5327    assert (clpSolver);
     5328    clpSolver->setBasis(*status_);
     5329    delete status_;
     5330    status_=NULL;
     5331  }
    51145332}
    51155333#endif
  • trunk/Cbc/src/CbcBranchActual.hpp

    r1067 r1087  
    15131513  /// Creates a branching object
    15141514  virtual CbcBranchingObject * createBranch(int way) ;
     1515  /// Return maximum number of nodes
     1516  int maximumNodes() const;
    15151517  /// Get maximum depth
    15161518  inline int maximumDepth() const
     
    15561558                 const double * lowerBefore,
    15571559                 const double * upperBefore,
    1558                  const unsigned char * status);
     1560                 const unsigned char * status,
     1561                 int depth);
    15591562
    15601563  /// Copy constructor
     
    15671570  virtual ~CbcSubProblem ();
    15681571
    1569   /// Apply subproblem
    1570   void apply(OsiSolverInterface * model);
     1572  /// Apply subproblem (1=bounds, 2=basis, 3=both)
     1573  void apply(OsiSolverInterface * model, int what=3) const;
    15711574
    15721575public:
     
    15801583  /// New bound
    15811584  double * newBounds_;
    1582   /// Status as diff
    1583   CoinWarmStartDiff * statusDifference_;
     1585  /// Status
     1586  mutable CoinWarmStartBasis * status_;
     1587  /// Depth
     1588  int depth_;
    15841589  /// Number of Extra bound changes
    15851590  int numberChangedBounds_;
     
    16531658  virtual CbcRangeCompare compareBranchingObject
    16541659  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
     1660  /// Number of subproblems
     1661  inline int numberSubProblems() const
     1662  { return numberSubProblems_;}
     1663  /// Decrement number left and return number
     1664  inline int decrementNumberLeft()
     1665  { numberSubLeft_--; return numberSubLeft_;}
     1666  /// Which node we want to use
     1667  inline int whichNode() const
     1668  { return whichNode_;}
     1669  /// Set which node we want to use
     1670  inline void setWhichNode(int value)
     1671  { whichNode_ = value;}
     1672  // Sub problem
     1673  const CbcSubProblem * subProblem(int which) const
     1674  { return subProblems_+which;}
    16551675
    16561676public:
     
    16621682  /// Number of subproblems
    16631683  int numberSubProblems_;
     1684  /// Number of subproblems left
     1685  int numberSubLeft_;
     1686  /// Which node we want to use (-1 for default)
     1687  int whichNode_;
    16641688  /// Number of rows
    16651689  int numberRows_;
    16661690};
     1691
     1692/** Branching object for general objects - just one
     1693
     1694 */
     1695class CbcOneGeneralBranchingObject : public CbcBranchingObject {
     1696
     1697public:
     1698
     1699  // Default Constructor
     1700  CbcOneGeneralBranchingObject ();
     1701
     1702  // Useful constructor
     1703  CbcOneGeneralBranchingObject (CbcModel * model,
     1704                                 CbcGeneralBranchingObject * object,
     1705                                 int whichOne);
     1706 
     1707  // Copy constructor
     1708  CbcOneGeneralBranchingObject ( const CbcOneGeneralBranchingObject &);
     1709   
     1710  // Assignment operator
     1711  CbcOneGeneralBranchingObject & operator=( const CbcOneGeneralBranchingObject& rhs);
     1712
     1713  /// Clone
     1714  virtual CbcBranchingObject * clone() const;
     1715
     1716  // Destructor
     1717  virtual ~CbcOneGeneralBranchingObject ();
     1718 
     1719  using CbcBranchingObject::branch ;
     1720  /// Does next branch and updates state
     1721  virtual double branch();
     1722  /** Double checks in case node can change its mind!
     1723      Can change objective etc */
     1724  virtual void checkIsCutoff(double cutoff);
     1725
     1726  using CbcBranchingObject::print ;
     1727  /** \brief Print something about branch - only if log level high
     1728  */
     1729  virtual void print();
     1730  /** Return the type (an integer identifier) of \c this */
     1731  virtual int type() const { return 110; }
     1732
     1733  /** Compare the original object of \c this with the original object of \c
     1734      brObj. Assumes that there is an ordering of the original objects.
     1735      This method should be invoked only if \c this and brObj are of the same
     1736      type.
     1737      Return negative/0/positive depending on whether \c this is
     1738      smaller/same/larger than the argument.
     1739  */
     1740  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
     1741
     1742  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
     1743      same type and must have the same original object, but they may have
     1744      different feasible regions.
     1745      Return the appropriate CbcRangeCompare value (first argument being the
     1746      sub/superset if that's the case). In case of overlap (and if \c
     1747      replaceIfOverlap is true) replace the current branching object with one
     1748      whose feasible region is the overlap.
     1749   */
     1750  virtual CbcRangeCompare compareBranchingObject
     1751  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
     1752
     1753public:
     1754  /// data
     1755  /// Object
     1756  CbcGeneralBranchingObject * object_;
     1757  /// Which one
     1758  int whichOne_;
     1759};
    16671760#endif
    16681761#endif
  • trunk/Cbc/src/CbcBranchDynamic.cpp

    r1053 r1087  
    14581458    info.numItersDown = 0;
    14591459    info.fix =0;
    1460   if (object_->numberTimesUp()<object_->numberBeforeTrust()||
    1461       object_->numberTimesDown()<object_->numberBeforeTrust()) {
     1460  if (object_->numberTimesUp()<object_->numberBeforeTrust()+
     1461      object_->numberTimesUpInfeasible()||
     1462      object_->numberTimesDown()<object_->numberBeforeTrust()+
     1463      object_->numberTimesDownInfeasible()) {
    14621464    return 0;
    14631465  } else {
  • trunk/Cbc/src/CbcBranchDynamic.hpp

    r931 r1087  
    223223  inline void setNumberBeforeTrust(int value)
    224224  { numberBeforeTrust_=value;}
     225  /// Increment number of times before trusted
     226  inline void incrementNumberBeforeTrust()
     227  { numberBeforeTrust_++;}
    225228
    226229  /// Return "up" estimate
  • trunk/Cbc/src/CbcHeuristic.cpp

    r1085 r1087  
    276276  const int depth = currentNode->depth();
    277277#else
    278   int depth = 0;
    279   const CbcNode* currentNode = model_->currentNode();
    280   if (currentNode != NULL) {
    281     depth = currentNode->depth();
    282 #ifdef PRINT_DEBUG
    283     debugNodes();
    284 #endif
    285   }
     278  int depth = model_->currentDepth();
    286279#endif
    287280
     
    357350  if (!when_)
    358351    return false;
    359   int depth = 0;
    360   const CbcNode* currentNode = model_->currentNode();
    361   if (currentNode != NULL) {
    362     depth = currentNode->depth();
    363   }
     352  int depth = model_->currentDepth();
    364353  // when_ -999 is special marker to force to run
    365354  if(depth != 0&&when_!=-999) {
     
    10661055    for (int i = 1; i < cnt; ++i) {
    10671056      if (compare3BranchingObjects(brObj_[numObjects_], brObj_[i]) == 0) {
    1068         int comp = brObj_[numObjects_]->compareBranchingObject(brObj_[i], &br);
     1057        int comp = brObj_[numObjects_]->compareBranchingObject(brObj_[i], br);
    10691058        switch (comp) {
    10701059        case CbcRangeSame: // the same range
  • trunk/Cbc/src/CbcModel.cpp

    r1086 r1087  
    16971697    feasible=false;
    16981698  if(fastNodeDepth_>=0&&!parentModel_) {
    1699     // add in a general depth object
     1699    // add in a general depth object doClp
     1700    int type = (fastNodeDepth_ <=100) ? fastNodeDepth_ : -(fastNodeDepth_-100);
    17001701    CbcObject * obj =
    1701       new CbcGeneralDepth(this,fastNodeDepth_);
     1702      new CbcGeneralDepth(this,type);
    17021703    addObjects(1,&obj);
    17031704    // mark as done
     
    35713572          }
    35723573        }
    3573         printf("Tree sizes %d %d %d - affected %d\n",saveTreeSize,saveTreeSize2,tree_->size(),nAffected);
     3574        //printf("Tree sizes %d %d %d - affected %d\n",saveTreeSize,saveTreeSize2,tree_->size(),nAffected);
    35743575        // later remember random may not be thread neutral
    35753576#endif
     
    58205821                                   addedCuts_,currentNumberCuts);
    58215822  }
     5823#ifndef NDEBUG
    58225824  if (!lastws->fullBasis()) {
    58235825#ifdef COIN_DEVELOP
     
    58755877#endif
    58765878  }
     5879#endif
    58775880  if (0) {
    58785881    int numberDebugValues=18;
     
    60386041        }
    60396042      }
     6043      assert (lastws->fullBasis());
    60406044      int numberRowsNow=numberRowsAtContinuous_+numberToAdd;
    60416045      lastws->compressRows(numberToDrop,cutsToDrop) ;
     
    61256129        }
    61266130      }
    6127 #else
    6128       //solver_->applyRowCuts(numberToAdd,addCuts);
    61296131#endif
    61306132#ifdef NODE_LAST
     
    61556157      } else {
    61566158#ifdef COIN_HAS_CLP
    6157 #ifdef COIN_DEVELOP
     6159#if 0 //def COIN_DEVELOP
    61586160        OsiClpSolverInterface * clpSolver
    61596161          = dynamic_cast<OsiClpSolverInterface *> (solver_);
     
    85308532
    85318533int
    8532 CbcModel::resolve(CbcNodeInfo * parent, int whereFrom)
     8534CbcModel::resolve(CbcNodeInfo * parent, int whereFrom,
     8535                  double * saveSolution,
     8536                  double * saveLower,
     8537                  double * saveUpper)
    85338538{
    85348539  // We may have deliberately added in violated cuts - check to avoid message
     
    86288633        feasible = (solver_->isProvenOptimal() &&
    86298634                    !solver_->isDualObjectiveLimitReached()) ;
     8635        if (feasible) {
     8636          // double check
     8637          double testValue = solver_->getObjSense() *
     8638            solver_->getObjValue();
     8639          //double cutoff = getCutoff();
     8640          if (bestObjective_-getCutoffIncrement()<testValue) {
     8641#if 1 //def CLP_INVESTIGATE
     8642            double value ;
     8643            solver_->getDblParam(OsiDualObjectiveLimit,value) ;
     8644            printf("Should cutoff as obj %.18g, best %.18g, inc %.18g - solver cutoff %.18g model cutoff %.18g\n",
     8645                   testValue,bestObjective_,getCutoffIncrement(),
     8646                   value,getCutoff());
     8647#endif
     8648            feasible=false;
     8649          }
     8650        }
    86308651#ifdef COIN_HAS_CLP
    86318652        OsiClpSolverInterface * clpSolver
     
    88278848
    88288849  setPointers(solver_);
     8850  if (feasible&&saveSolution) {
     8851    // called from CbcNode
     8852    assert (saveLower);
     8853    assert (saveUpper);
     8854    int numberColumns = solver_->getNumCols();
     8855    memcpy(saveSolution,solver_->getColSolution(),numberColumns*sizeof(double));
     8856    reserveCurrentSolution(saveSolution);
     8857    memcpy(saveLower,solver_->getColLower(),numberColumns*sizeof(double));
     8858    memcpy(saveUpper,solver_->getColUpper(),numberColumns*sizeof(double));
     8859  }
    88298860  int returnStatus = feasible ? 1 : 0;
    88308861  if (strategy_) {
     
    1036310394        saveObjectiveValue = CoinMax(saveObjectiveValue,bestObjective_-0.0000001*fabs(bestObjective_));
    1036410395        cutoff = CoinMin(bestObjective_,saveObjectiveValue)-1.0e-5;
     10396        if (fabs(cutoff+1.0e-5-floor(cutoff+0.5))<1.0e-8)
     10397          cutoff -= 2.0e-5;
    1036510398      }
    1036610399      // This is not correct - that way cutoff can go up if maximization
     
    1225112284*/
    1225212285int
    12253 CbcModel::chooseBranch(CbcNode * newNode, int numberPassesLeft,
     12286CbcModel::chooseBranch(CbcNode * &newNode, int numberPassesLeft,
    1225412287                       CbcNode * oldNode, OsiCuts & cuts,
    1225512288                       bool & resolved, CoinWarmStartBasis *lastws,
     
    1231012343    if (!branchingMethod_||!branchingMethod_->chooseMethod()) {
    1231112344#ifdef COIN_HAS_CLP
    12312       if (oldNode&&fastNodeDepth_>=0&&oldNode->depth()>=4&&!parentModel_
    12313           &&(oldNode->depth()%2)==0) {
     12345      bool doClp = oldNode&&(oldNode->depth()%2)==1;
     12346      if (!doCutsNow(1))
     12347        doClp=true;
     12348      doClp = true;
     12349      int testDepth=10;
     12350      // Don't do if many iterations per node
     12351      int totalNodes = numberNodes_+numberExtraNodes_;
     12352      int totalIterations = numberIterations_ + numberExtraIterations_;
     12353      if (totalNodes*40<totalIterations)
     12354        doClp=false;
     12355      if (oldNode&&fastNodeDepth_>=0&&oldNode->depth()>=testDepth&&!parentModel_
     12356          &&doClp&&!cuts.sizeRowCuts()) {
    1231412357        OsiClpSolverInterface * clpSolver
    1231512358          = dynamic_cast<OsiClpSolverInterface *> (solver_);
     
    1245012493#             endif
    1245112494    }
    12452     newNode->createInfo(this,oldNode,lastws,lowerBefore,upperBefore,
    12453                           numberOldActiveCuts_,numberNewCuts_) ;
     12495    {
     12496      OsiBranchingObject * branchingObject =
     12497        newNode->modifiableBranchingObject();
     12498      CbcGeneralBranchingObject * generalBranch =
     12499        dynamic_cast <CbcGeneralBranchingObject *> (branchingObject);
     12500      if (generalBranch&&false) {
     12501        int numberProblems = generalBranch->numberSubProblems();
     12502        for (int i=0;i<numberProblems;i++) {
     12503          double objectiveValue;
     12504          double sumInfeasibilities;
     12505          int numberUnsatisfied;
     12506          generalBranch->state(objectiveValue,sumInfeasibilities,
     12507                               numberUnsatisfied,i);
     12508          printf("node %d obj %g sumI %g numI %i rel depth %d\n",
     12509                 i,objectiveValue,sumInfeasibilities,numberUnsatisfied,
     12510                 generalBranch->subProblem(i)->depth_);
     12511        }
     12512      }
     12513      if (generalBranch) {
     12514        int numberProblems = generalBranch->numberSubProblems();
     12515        newNode->setBranchingObject(NULL);
     12516        CbcNode * newNode2=NULL;
     12517        assert (numberProblems);
     12518        int nProbMinus1 = numberProblems-1;
     12519        for (int i = 0;i < currentNumberCuts_;i++) {
     12520          if (addedCuts_[i])
     12521            addedCuts_[i]->increment(nProbMinus1) ;
     12522        }
     12523        for (int i=0;i<numberProblems;i++) {
     12524          double objectiveValue;
     12525          double sumInfeasibilities;
     12526          int numberUnsatisfied;
     12527          generalBranch->state(objectiveValue,sumInfeasibilities,
     12528                               numberUnsatisfied,i);
     12529          //printf("node %d obj %g sumI %g numI %i rel depth %d\n",
     12530          // i,objectiveValue,sumInfeasibilities,numberUnsatisfied,
     12531          // generalBranch->subProblem(i)->depth_);
     12532          newNode2 = new CbcNode();
     12533          newNode2->setDepth(generalBranch->subProblem(i)->depth_+currentDepth_);
     12534          generalBranch->subProblem(i)->apply(solver_,8); // basis
     12535          newNode2->setNumberUnsatisfied(numberUnsatisfied);
     12536          newNode2->setSumInfeasibilities(sumInfeasibilities);
     12537          newNode2->setGuessedObjectiveValue(objectiveValue);
     12538          newNode2->setObjectiveValue(objectiveValue);
     12539          CbcOneGeneralBranchingObject * object =
     12540            new CbcOneGeneralBranchingObject(this,generalBranch,i);
     12541          newNode2->setBranchingObject(object);
     12542          newNode2->createInfo(this,oldNode,lastws,
     12543                               lowerBefore,upperBefore,
     12544                               numberOldActiveCuts_,numberNewCuts_) ;
     12545          newNode2->nodeInfo()->setNumberBranchesLeft(1);
     12546          //newNode2->nodeInfo()->unsetParentBasedData();
     12547          if (i<nProbMinus1) {
     12548            //OsiBranchingObject * object = oldNode->modifiableBranchingObject();
     12549            CbcNodeInfo * nodeInfo = oldNode->nodeInfo();
     12550            //object->incrementNumberBranchesLeft();
     12551            nodeInfo->incrementNumberPointingToThis();
     12552            newNode2->nodeInfo()->setNodeNumber(numberNodes2_);
     12553            //newNode2->nodeInfo()->setNumberBranchesLeft(1);
     12554            newNode2->initializeInfo();
     12555            numberNodes2_++;
     12556            tree_->push(newNode2);
     12557          }
     12558        }
     12559        delete newNode;
     12560        newNode = newNode2;
     12561      } else {
     12562        newNode->createInfo(this,oldNode,lastws,lowerBefore,upperBefore,
     12563                            numberOldActiveCuts_,numberNewCuts_) ;
     12564      }
     12565    }
    1245412566    if (newNode->numberUnsatisfied()) {
    1245512567      maximumDepthActual_ = CoinMax(maximumDepthActual_,newNode->depth());
     
    1340713519                                numberUpInfeasible,numberIntegers_);
    1340813520          info->presolveType_=1;
     13521          // for reduced costs and duals
     13522          info->solverOptions_ |= 7;
    1340913523          delete [] down;
    1341013524          delete [] up;
     
    1385913973#endif
    1386013974#endif
     13975    if (newNode)
    1386113976      if (newNode&&newNode->active()) {
    1386213977        if (newNode->branchingObject() == NULL&&solverCharacteristics_->solverType()==4) {
     
    1408514200    to this code block also performs this action.
    1408614201  */
     14202#if 1
    1408714203  int numberToDelete = getNumRows()-numberRowsAtContinuous_ ;
    1408814204  if (numberToDelete) {
     
    1409414210    delete [] delRows ;
    1409514211  }
     14212#endif
    1409614213  delete lastws ;
    1409714214  delete [] lowerBefore ;
  • trunk/Cbc/src/CbcModel.hpp

    r1053 r1087  
    328328      returns 1 feasible, 0 infeasible, -1 feasible but skip cuts
    329329    */
    330     int resolve(CbcNodeInfo * parent, int whereFrom);
     330  int resolve(CbcNodeInfo * parent, int whereFrom,
     331              double * saveSolution=NULL,
     332              double * saveLower=NULL,
     333              double * saveUpper=NULL);
    331334    /// Make given rows (L or G) into global cuts and remove from lp
    332335    void makeGlobalCuts(int numberRows,const int * which);
     
    16341637      anyAction -2, infeasible (-1 round again), 0 done
    16351638  */
    1636   int chooseBranch(CbcNode * newNode, int numberPassesLeft,
     1639  int chooseBranch(CbcNode * & newNode, int numberPassesLeft,
    16371640                   CbcNode * oldNode, OsiCuts & cuts,
    16381641                   bool & resolved, CoinWarmStartBasis *lastws,
     
    19651968  */
    19661969  CbcNodeInfo ** walkback_;
     1970  //#define CBC_DETERMINISTIC_THREAD
    19671971#ifndef CBC_DETERMINISTIC_THREAD
    19681972#define NODE_LAST
  • trunk/Cbc/src/CbcNode.cpp

    r1061 r1087  
    7474}
    7575
     76void
     77CbcNodeInfo::unsetParentBasedData()
     78{
     79  if (parent_) {
     80    numberRows_ = 0;
     81    if (parent_->owner()) {
     82      delete parentBranch_;
     83      parentBranch_ = NULL;
     84    }
     85  }
     86}
     87
    7688#if 0
    7789// Constructor given parent
     
    92104  printf("CbcNodeInfo %x Constructor from parent %x\n",this,parent_);
    93105#endif
    94   setParentBasedData();
     106  //setParentBasedData();
    95107}
    96108#endif
     
    148160  printf("CbcNodeInfo %x Constructor from parent %x\n",this,parent_);
    149161#endif
    150   setParentBasedData();
     162  //setParentBasedData();
    151163}
    152164
     
    663675{
    664676  basisDiff_ = basisDiff->clone() ;
     677#ifdef CBC_CHECK_BASIS
     678    std::cout << "Constructor (" <<this<<") "<< std::endl ;
     679#endif   
    665680
    666681  numberChangedBounds_ = numberChangedBounds;
     
    683698{ basisDiff_ = rhs.basisDiff_->clone() ;
    684699
     700#ifdef CBC_CHECK_BASIS
     701  std::cout << "Copy constructor (" <<this<<") from "<<this<< std::endl ;
     702#endif   
    685703  numberChangedBounds_ = rhs.numberChangedBounds_;
    686704  int size = numberChangedBounds_*(sizeof(double)+sizeof(int));
     
    875893
    876894  return parent_ ; }
    877 
    878895CbcNode::CbcNode() :
    879896  nodeInfo_(NULL),
     
    10711088*/
    10721089    CoinWarmStartDiff *basisDiff = expanded->generateDiff(lastws) ;
     1090
    10731091/*
    10741092  Diff the bound vectors. It's assumed the number of structural variables
     
    13231341
    13241342#endif  // CBC_NEW_CREATEINFO
    1325 
    13261343/*
    13271344  The routine scans through the object list of the model looking for objects
     
    24142431  const double * lower = solver->getColLower();
    24152432  const double * upper = solver->getColUpper();
     2433  //const double * objective = solver->getObjCoefficients();
    24162434  // See what user thinks
    24172435  int anyAction=model->problemFeasibility()->feasible(model,0);
     
    24212439  }
    24222440  int i;
    2423   int saveStateOfSearch = model->stateOfSearch();
     2441  int saveStateOfSearch = model->stateOfSearch()%10;
    24242442  int numberStrong=model->numberStrong();
    24252443  //if (!auxiliaryInfo->warmStart())
     
    24482466  memcpy(saveSolution,solver->getColSolution(),numberColumns*sizeof(double));
    24492467  model->reserveCurrentSolution(saveSolution);
     2468  if (false) {
     2469        OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (solver);
     2470        const double * sol = osiclp->getColSolution();
     2471        int n = osiclp->getNumCols();
     2472        for (int i=0;i<n;i++) {
     2473          double sC = sol[i];
     2474          double sS = saveSolution[i];
     2475          double sU = usefulInfo.solution_[i];
     2476          if (fabs(sC-sS)>1.0e-5||fabs(sC-sU)>1.0e-5)
     2477            printf("DiffA %d clp %g saved %g useful %g\n",
     2478                   i,sC,sS,sU);
     2479        }
     2480  }
    24502481  /*
    24512482    Get a branching decision object. Use the default dynamic decision criteria unless
     
    26402671  }
    26412672  choice.possibleBranch=choiceObject;
     2673  int kkPass=0;
     2674  //#define CBC_NODE7 1
     2675#ifdef CBC_NODE7
     2676  double * weightModifier = new double [2*numberColumns];
     2677  CoinZeroN(weightModifier,2*numberColumns);
     2678  if (usefulInfo.columnLength_) {
     2679#if CBC_NODE7>1
     2680    double tolerance=1.0e-6;
     2681    int numberRows = solver->getNumRows();
     2682    double * activeWeight = new double [numberRows];
     2683    for (int iRow = 0;iRow<numberRows;iRow++) {
     2684      // could use pi to see if active or activity
     2685#if 1
     2686      if (usefulInfo.rowActivity_[iRow]>usefulInfo.rowUpper_[iRow]-tolerance
     2687          ||usefulInfo.rowActivity_[iRow]<usefulInfo.rowLower_[iRow]+tolerance) {
     2688        activeWeight[iRow]=0.0;
     2689      } else {
     2690        activeWeight[iRow]=-1.0;
     2691      }
     2692#else
     2693      if (fabs(usefulInfo.pi_[iRow])>1.0e-6) {
     2694        activeWeight[iRow]=0.0;
     2695      } else {
     2696        activeWeight[iRow]=-1.0;
     2697      }
     2698#endif
     2699    }
     2700    for (int iColumn=0;iColumn<numberColumns;iColumn++) {
     2701      if (solver->isInteger(iColumn)) {
     2702        double solValue = usefulInfo.solution_[iColumn];
     2703        if (fabs(solValue-floor(solValue+0.5))>1.0e-6) {
     2704          CoinBigIndex start = usefulInfo.columnStart_[iColumn];
     2705          CoinBigIndex end = start + usefulInfo.columnLength_[iColumn];
     2706#ifndef NDEBUG
     2707          double value = usefulInfo.direction_*usefulInfo.objective_[iColumn];
     2708#endif
     2709          for (CoinBigIndex j=start;j<end;j++) {
     2710            int iRow = usefulInfo.row_[j];
     2711#ifndef NDEBUG
     2712            value -= usefulInfo.pi_[iRow] * usefulInfo.elementByColumn_[j];
     2713#endif
     2714            if (activeWeight[iRow]>=0.0)
     2715              activeWeight[iRow] += 1.0;
     2716          }
     2717          assert (fabs(value)<1.0e-4);
     2718        }
     2719      }
     2720    }
     2721    for (int iRow = 0;iRow<numberRows;iRow++) {
     2722      if (activeWeight[iRow]>0.0) {
     2723        // could use pi
     2724        activeWeight[iRow] = 1.0/activeWeight[iRow];
     2725#if 0
     2726        activeWeight[iRow] *= fabs(usefulInfo.pi_[iRow]);
     2727#endif
     2728      } else {
     2729        activeWeight[iRow]=0.0;
     2730      }
     2731    }
     2732    for (int iColumn=0;iColumn<numberColumns;iColumn++) {
     2733      if (solver->isInteger(iColumn)) {
     2734        double solValue = usefulInfo.solution_[iColumn];
     2735        if (fabs(solValue-floor(solValue+0.5))>1.0e-6) {
     2736          CoinBigIndex start = usefulInfo.columnStart_[iColumn];
     2737          CoinBigIndex end = start + usefulInfo.columnLength_[iColumn];
     2738          solValue -= floor(solValue);
     2739#if CBC_NODE7>=3
     2740          double upValue = 0.0;
     2741          double downValue = 0.0;
     2742          double value = usefulInfo.direction_*usefulInfo.objective_[iColumn];
     2743          // Bias cost
     2744          if (value>0.0)
     2745            upValue += 1.5*value;
     2746          else
     2747            downValue -= 1.5*value;
     2748          for (CoinBigIndex j=start;j<end;j++) {
     2749            int iRow = usefulInfo.row_[j];
     2750#if CBC_NODE7<=3
     2751            value = -usefulInfo.pi_[iRow];
     2752            if (value) {
     2753              value *= usefulInfo.elementByColumn_[j];
     2754#if CBC_NODE7==3
     2755              value *= activeWeight[iRow];
     2756#endif
     2757              if (value>0.0)
     2758                upValue += value;
     2759              else
     2760                downValue -= value;
     2761            }
     2762#else
     2763            value = usefulInfo.elementByColumn_[j];
     2764            double downMove = -solValue*value;
     2765            double upMove = (1.0-solValue)*value;
     2766            if (usefulInfo.rowActivity_[iRow]+downMove>usefulInfo.rowUpper_[iRow]-tolerance
     2767                ||usefulInfo.rowActivity_[iRow]+downMove<usefulInfo.rowLower_[iRow]+tolerance)
     2768              downMove = fabs(value);
     2769            else
     2770              downMove = 0.0;
     2771            if (usefulInfo.rowActivity_[iRow]+upMove>usefulInfo.rowUpper_[iRow]-tolerance
     2772                ||usefulInfo.rowActivity_[iRow]+upMove<usefulInfo.rowLower_[iRow]+tolerance)
     2773              upMove = fabs(value);
     2774            else
     2775              upMove = 0.0;
     2776#if CBC_NODE7==5
     2777            downMove *= activeWeight[iRow];
     2778            upMove *= activeWeight[iRow];
     2779#endif
     2780            upValue += upMove;
     2781            downValue += downMove;
     2782#endif
     2783          }
     2784          downValue = CoinMax(downValue,1.0e-8);
     2785          upValue = CoinMax(upValue,1.0e-8);
     2786          int put = 2*iColumn;
     2787          weightModifier[put]=downValue;
     2788          weightModifier[put+1]=upValue;
     2789#elif CBC_NODE7==2
     2790          double value=1.0e-8;
     2791          for (CoinBigIndex j=start;j<end;j++) {
     2792            int iRow = usefulInfo.row_[j];
     2793            if (activeWeight[iRow])
     2794              value += fabs(usefulInfo.elementByColumn_[j])*activeWeight[iRow];
     2795          }
     2796          //downValue = value*solValue;
     2797          //upValue = value*(1.0-solValue);
     2798          int put = 2*iColumn;
     2799          weightModifier[put]=value;
     2800          weightModifier[put+1]=value;
     2801#endif
     2802        }
     2803      }
     2804    }
     2805#if CBC_NODE7>1
     2806    delete [] activeWeight;
     2807#endif
     2808#else
     2809    for (int iColumn=0;iColumn<numberColumns;iColumn++) {
     2810      if (solver->isInteger(iColumn)) {
     2811        CoinBigIndex start = usefulInfo.columnStart_[iColumn];
     2812        CoinBigIndex end = start + usefulInfo.columnLength_[iColumn];
     2813        double upValue = 0.0;
     2814        double downValue = 0.0;
     2815        double solValue = usefulInfo.solution_[iColumn];
     2816        if (fabs(solValue-floor(solValue+0.5))>1.0e-6) {
     2817          solValue -= floor(solValue);
     2818          double value = usefulInfo.direction_*usefulInfo.objective_[iColumn];
     2819          // Bias cost
     2820          if (value>0.0)
     2821            upValue += 1.5*value;
     2822          else
     2823            downValue -= 1.5*value;
     2824          for (CoinBigIndex j=start;j<end;j++) {
     2825            int iRow = usefulInfo.row_[j];
     2826            value = -usefulInfo.pi_[iRow];
     2827            if (value) {
     2828              value *= usefulInfo.elementByColumn_[j];
     2829              if (value>0.0)
     2830                upValue += value;
     2831              else
     2832                downValue -= value;
     2833            }
     2834          }
     2835          downValue = CoinMax(downValue,1.0e-8);
     2836          upValue = CoinMax(upValue,1.0e-8);
     2837          int put = 2*iColumn;
     2838          weightModifier[put]=downValue;
     2839          weightModifier[put+1]=upValue;
     2840        }
     2841      }
     2842    }
     2843#endif
     2844  } else {
     2845    kkPass=-1000000;
     2846  }
     2847#endif
    26422848  while(!finished) {
     2849    kkPass++;
    26432850    finished=true;
    26442851    decision->initialize(model);
     
    26612868    // We may go round this loop three times (only if we think we have solution)
    26622869    for (int iPass=0;iPass<3;iPass++) {
    2663      
     2870
     2871      if (false) {
     2872        const double * sol = osiclp->getColSolution();
     2873        int n = osiclp->getNumCols();
     2874        for (int i=0;i<n;i++) {
     2875          double sC = sol[i];
     2876          double sS = saveSolution[i];
     2877          double sU = usefulInfo.solution_[i];
     2878          if (fabs(sC-sS)>1.0e-5||fabs(sC-sU)>1.0e-5)
     2879            printf("Diff %d clp %g saved %g useful %g\n",
     2880                   i,sC,sS,sU);
     2881        }
     2882      }
    26642883      // compute current state
    26652884      int numberObjectInfeasibilities; // just odd ones
     
    27082927      iBestGot=-1;
    27092928      best=0.0;
    2710       //#define CBC_NODE7 3
    2711 #if CBC_NODE7>1
    2712       double * activeWeight = NULL;
    2713       if (usefulInfo.columnLength_) {
    2714         double tolerance=1.0e-6;
    2715         int numberRows = solver->getNumRows();
    2716         activeWeight = new double [numberRows];
    2717         for (int iRow = 0;iRow<numberRows;iRow++) {
    2718           // could use pi to see if active or activity
    2719 #if 1
    2720           if (usefulInfo.rowActivity_[iRow]>usefulInfo.rowUpper_[iRow]-tolerance
    2721               ||usefulInfo.rowActivity_[iRow]<usefulInfo.rowLower_[iRow]+tolerance) {
    2722             activeWeight[iRow]=0.0;
    2723           } else {
    2724             activeWeight[iRow]=-1.0;
    2725           }
    2726 #else
    2727           if (fabs(usefulInfo.pi_[iRow])>1.0e-6) {
    2728             activeWeight[iRow]=0.0;
    2729           } else {
    2730             activeWeight[iRow]=-1.0;
    2731           }
    2732 #endif
    2733         }
    2734         for (int iColumn=0;iColumn<numberColumns;iColumn++) {
    2735           if (solver->isInteger(iColumn)) {
    2736             double value = usefulInfo.solution_[iColumn];
    2737             if (fabs(value-floor(value+0.5))>1.0e-6) {
    2738               CoinBigIndex start = usefulInfo.columnStart_[iColumn];
    2739               CoinBigIndex end = start + usefulInfo.columnLength_[iColumn];
    2740               for (CoinBigIndex j=start;j<end;j++) {
    2741                 int iRow = usefulInfo.row_[j];
    2742                 if (activeWeight[iRow]>=0.0)
    2743                   activeWeight[iRow] += 1.0;
    2744               }
    2745             }
    2746           }
    2747         }
    2748         for (int iRow = 0;iRow<numberRows;iRow++) {
    2749           if (activeWeight[iRow]>0.0) {
    2750             // could use pi
    2751             activeWeight[iRow] = 1.0/activeWeight[iRow];
    2752 #if 0
    2753             activeWeight[iRow] *= fabs(usefulInfo.pi_[iRow]);
    2754 #endif
    2755           }
    2756         }
    2757       }
    2758 #endif
    27592929      /* Problem type as set by user or found by analysis.  This will be extended
    27602930         0 - not known
     
    27902960          bool gotUp=false;
    27912961          int numberThisUp = 0;
     2962          double downGuess=object->downEstimate();
     2963          double upGuess=object->upEstimate();
    27922964          // check branching method
    27932965          if (dynamicObject) {
     
    28072979            if (numberThisUp>=numberBeforeTrust)
    28082980              gotUp=true;
     2981            //infeasibility += 10000.0*fabs(objective[iColumn]);
    28092982#ifdef CBC_NODE7
    2810             if (usefulInfo.columnLength_&&iColumn>=0&&iColumn<numberColumns) {
    2811               CoinBigIndex start = usefulInfo.columnStart_[iColumn];
    2812               CoinBigIndex end = start + usefulInfo.columnLength_[iColumn];
    2813               double upValue = 0.0;
    2814               double downValue = 0.0;
    2815 #if CBC_NODE7==1||CBC_NODE7==3
    2816               double value = usefulInfo.direction_*usefulInfo.objective_[iColumn];
    2817               // Bias cost
    2818               if (value>0.0)
    2819                 upValue += 1.5*value;
    2820               else
    2821                 downValue -= 1.5*value;
    2822               for (CoinBigIndex j=start;j<end;j++) {
    2823                 int iRow = usefulInfo.row_[j];
    2824                 value = -usefulInfo.pi_[iRow];
    2825                 if (value) {
    2826                   value *= usefulInfo.elementByColumn_[j];
    2827 #if CBC_NODE7==3
    2828                   value *= activeWeight[iRow];
    2829 #endif
    2830                   if (value>0.0)
    2831                     upValue += value;
    2832                   else
    2833                     downValue -= value;
    2834                 }
    2835               }
    2836               value = usefulInfo.solution_[iColumn];
    2837               value -= floor(value);
    2838               downValue *= value;
    2839               upValue *= (1.0-value);
     2983            /*
     2984              Could do for kkPass>=1
     2985              Could do max just if not fully trusted
     2986            */
     2987            if (weightModifier&&kkPass==1) {
     2988              double solValue = usefulInfo.solution_[iColumn];
     2989              solValue -= floor(solValue);
     2990              int get = 2*iColumn;
     2991              double downValue = weightModifier[get];
     2992              double upValue = weightModifier[get+1];
     2993              assert (downValue>0.0&&upValue>0.0);
     2994              downGuess = downValue * solValue;
     2995              upGuess = upValue * (1.0-solValue);
    28402996#if 0
    28412997              printf("%d inf %g ord %g %g shadow %g %g\n",
    28422998                     iColumn,infeasibility,
    28432999                     object->downEstimate(),object->upEstimate(),
    2844                      downValue,upValue);
    2845 #endif
    2846               //if (!numberThisDown||!numberThisUp)
    2847               //if (!gotDown||!gotUp)
    2848 #if 0
    2849               infeasibility = CoinMax(CoinMax(downValue,upValue),infeasibility);
     3000                     downGuess,upGuess);
     3001#endif
     3002              double useInfeasibility = 0.9*CoinMin(downGuess,upGuess)
     3003                + 0.1*CoinMax(downGuess,upGuess);
     3004#if CBC_NODE7>=3
     3005#if 1
     3006              if (numberThisUp<10||numberThisDown<10)
     3007                //if (!gotUp||!gotDown)
     3008                infeasibility = CoinMax(useInfeasibility,infeasibility);
     3009              else
     3010                infeasibility = CoinMax(0.1*useInfeasibility,infeasibility);
    28503011#else
    2851               infeasibility = CoinMax(downValue,upValue);
    2852 #endif
    2853 #elif CBC_NODE7==2
    2854               double value=0.0;
    2855               for (CoinBigIndex j=start;j<end;j++) {
    2856                 int iRow = usefulInfo.row_[j];
    2857                 if (activeWeight[iRow])
    2858                   value += fabs(usefulInfo.elementByColumn_[j])*activeWeight[iRow];
    2859               }
    2860               double solValue = usefulInfo.solution_[iColumn];
    2861               solValue -= floor(solValue);
    2862               downValue = value*solValue;
    2863               upValue = value*(1.0-solValue);
    2864 #if 0
    2865               printf("%d inf %g ord %g %g shadow %g %g\n",
    2866                      iColumn,infeasibility,
    2867                      object->downEstimate(),object->upEstimate(),
    2868                      downValue,upValue);
    2869 #endif
    2870               //if (!numberThisDown||!numberThisUp)
    2871               //if (!gotDown||!gotUp)
    2872               infeasibility = CoinMax(CoinMax(downValue,upValue),infeasibility);
    2873               infeasibility = CoinMax(downValue,upValue);
    2874               infeasibility = value;
     3012              if (!numberThisUp&&!numberThisDown)
     3013                infeasibility = CoinMax(useInfeasibility,infeasibility);
     3014              else
     3015                infeasibility += 0.1*useInfeasibility;
     3016#endif
     3017#else
     3018
     3019#if 1
     3020              infeasibility = useInfeasibility;
     3021#else
     3022#if 1
     3023              if (numberThisUp<10||numberThisDown<10)
     3024                infeasibility = CoinMax(useInfeasibility,infeasibility);
     3025              else
     3026                infeasibility = CoinMax(0.1*useInfeasibility,infeasibility);
     3027#else
     3028              infeasibility *= weightModifier[2*iColumn];
     3029#endif
     3030#endif
    28753031#endif
    28763032            }
     
    29203076          }
    29213077          // Increase estimated degradation to solution
    2922           estimatedDegradation += CoinMin(object->upEstimate(),object->downEstimate());
    2923           downEstimate[i]=object->downEstimate();
    2924           upEstimate[i]=object->upEstimate();
     3078          estimatedDegradation += CoinMin(downGuess,upGuess);
     3079          downEstimate[i]=downGuess;
     3080          upEstimate[i]=upGuess;
    29253081          numberUnsatisfied_++;
    29263082          sumInfeasibilities_ += infeasibility;
     
    29763132        }
    29773133      }
    2978 #if CBC_NODE7>1
    2979       delete [] activeWeight;
    2980 #endif
    29813134      if (numberUnsatisfied_) {
    29823135        if (probingInfo&&false)
     
    29873140      } else if (!iPass) {
    29883141        // may just need resolve
    2989         solver->resolve();
    2990         memcpy(saveSolution,solver->getColSolution(),numberColumns*sizeof(double));
    2991         model->reserveCurrentSolution(saveSolution);
     3142        model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    29923143        if (!solver->isProvenOptimal()) {
    29933144          // infeasible
     
    30253176          solver->getHintParam(OsiDoDualInResolve,takeHint,strength);
    30263177          solver->setHintParam(OsiDoDualInResolve,false,OsiHintDo) ;
    3027           solver->resolve();
     3178          model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    30283179          solver->setHintParam(OsiDoDualInResolve,takeHint,strength) ;
    3029           memcpy(saveSolution,solver->getColSolution(),numberColumns*sizeof(double));
    3030           model->reserveCurrentSolution(saveSolution);
    30313180          if (!solver->isProvenOptimal()) {
    30323181            // infeasible
     
    36813830                                       solver->getColSolution()) ;
    36823831                if (needHotStartUpdate) {
    3683                   solver->resolve();
     3832                  model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    36843833                  newObjectiveValue = solver->getObjSense()*solver->getObjValue();
    36853834                  objectiveChange = CoinMax(newObjectiveValue  - objectiveValue_,0.0);
     
    37153864          if(needHotStartUpdate) {
    37163865            needHotStartUpdate = false;
    3717             solver->resolve();
     3866            model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    37183867            //we may again have an integer feasible solution
    37193868            int numberIntegerInfeasibilities;
     
    37323881                                     objValue,
    37333882                                     solver->getColSolution()) ;
    3734               solver->resolve();
     3883              model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    37353884              cutoff =model->getCutoff();
    37363885            }
     
    38183967                                       solver->getColSolution()) ;
    38193968                if (needHotStartUpdate) {
    3820                   solver->resolve();
     3969                  model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    38213970                  newObjectiveValue = solver->getObjSense()*solver->getObjValue();
    38223971                  objectiveChange = CoinMax(newObjectiveValue  - objectiveValue_,0.0);
     
    38524001          if(needHotStartUpdate) {
    38534002            needHotStartUpdate = false;
    3854             solver->resolve();
     4003            model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    38554004            //we may again have an integer feasible solution
    38564005            int numberIntegerInfeasibilities;
     
    38634012                                     objValue,
    38644013                                     solver->getColSolution()) ;
    3865               solver->resolve();
     4014              model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    38664015              cutoff =model->getCutoff();
    38674016            }
     
    40584207              assert(doneHotStart);
    40594208              solver->unmarkHotStart();
    4060               solver->resolve();
     4209              model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    40614210              solver->markHotStart();
    40624211              // may be infeasible (if other way stopped on iterations)
     
    41214270              assert(doneHotStart);
    41224271              solver->unmarkHotStart();
    4123               solver->resolve();
     4272              model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    41244273              solver->markHotStart();
    41254274              // may be infeasible (if other way stopped on iterations)
     
    42304379            int easy=2;
    42314380            solver->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo,&easy) ;
    4232             solver->resolve() ;
     4381            model->resolve(NULL,11,saveSolution,saveLower,saveUpper) ;
    42334382            solver->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo,NULL) ;
    42344383            feasible = solver->isProvenOptimal();
     
    42364385              anyAction=0;
    42374386              numberMini=0;
    4238               memcpy(saveSolution,solver->getColSolution(),numberColumns*sizeof(double));
    4239               model->reserveCurrentSolution(saveSolution);
    4240               memcpy(saveLower,solver->getColLower(),numberColumns*sizeof(double));
    4241               memcpy(saveUpper,solver->getColUpper(),numberColumns*sizeof(double));
    4242               model->setPointers(solver);
    42434387              // See if candidate still possible
    42444388              if (branch_) {
     
    42784422    }
    42794423  }
     4424#ifdef CBC_NODE7
     4425  delete [] weightModifier;
     4426#endif
    42804427  if (model->messageHandler()->logLevel()>2)
    42814428    printf("%d strong, %d iters, %d pen, %d mark, %d fixed, action %d nnott %d nt %d, %d dq %s ns %d\n",
     
    42974444    if (((numberUnfinished*4>numberStrongDone&&
    42984445         numberStrongInfeasible*40<numberStrongDone)||
    4299          numberStrongInfeasible<0)&&model->numberStrong()<10&&model->numberBeforeTrust()<20&&model->numberObjects()>1000) {
     4446         numberStrongInfeasible<0)&&model->numberStrong()<10&&model->numberBeforeTrust()<=20&&model->numberObjects()>CoinMax(1000,solver->getNumRows())) {
    43004447      strategy=2;
    43014448#ifdef COIN_DEVELOP
     
    43284475    if (model->searchStrategy()<999)
    43294476      model->setSearchStrategy(strategy);
     4477  } else if (numberStrongDone) {
     4478    //printf("%d strongB, %d iters, %d inf, %d not finished, %d not trusted\n",
     4479    //   numberStrongDone,numberStrongIterations,numberStrongInfeasible,numberUnfinished,
     4480    //   numberNotTrusted);
    43304481  }
    43314482  if (model->searchStrategy()==1&&numberNodes>500&&numberNodes<-510) {
     
    49745125  CbcNodeInfo * parent = nodeInfo_->parent();
    49755126  int parentNodeNumber = -1;
    4976   //CbcBranchingObject * object1 = branch_->object_;
     5127  CbcBranchingObject * object1 =
     5128    dynamic_cast<CbcBranchingObject *>(branch_) ;
    49775129  //OsiObject * object = object1->
    49785130  //int sequence = object->columnNumber);
    49795131  int id=-1;
    49805132  double value=0.0;
    4981   if (branch_) {
    4982     id = branch_->variable();
    4983     value = branch_->value();
     5133  if (object1) {
     5134    id = object1->variable();
     5135    value = object1->value();
    49845136  }
    49855137  printf("id %d value %g objvalue %g\n",id,value,objectiveValue_);
     
    49895141         nodeInfo_->nodeNumber(),(numberLeft==2) ? "leftBranch" : "rightBranch",
    49905142         way(),depth_,parentNodeNumber);
     5143  assert (parentNodeNumber!=nodeInfo_->nodeNumber());
    49915144#endif
    49925145  return nodeInfo_->branchedOn();
     
    51995352    ClpNode * nodeInfo = thisOne->nodeInfo(thisOne->whichSolution());
    52005353    nodeInfo->applyNode(simplex,2);
     5354    int saveLogLevel = simplex->logLevel();
     5355    simplex->setLogLevel(0);
    52015356    simplex->dual();
     5357    simplex->setLogLevel(saveLogLevel);
    52025358    double cutoff = model->getCutoff();
    52035359    bool goodSolution=true;
  • trunk/Cbc/src/CbcNode.hpp

    r940 r1087  
    2121class CbcModel;
    2222class CbcNode;
     23class CbcSubProblem;
     24class CbcGeneralBranchingObject;
    2325
    2426//#############################################################################
     
    144146  {return numberBranchesLeft_;}
    145147
     148  /// Set number of branches left in object
     149  inline void setNumberBranchesLeft(int value)
     150  {numberBranchesLeft_ = value;}
     151
    146152  /// Return number of objects pointing to this
    147153  inline int numberPointingToThis() const
     
    151157  inline void setNumberPointingToThis(int number)
    152158  {numberPointingToThis_=number;}
     159
     160  /// Increment number of objects pointing to this
     161  inline void incrementNumberPointingToThis()
     162  {numberPointingToThis_ ++;}
    153163
    154164  /// Say one branch taken
     
    234244  inline const OsiBranchingObject * parentBranch() const
    235245  { return parentBranch_;}
     246  /// If we need to take off parent based data
     247  void unsetParentBasedData();
    236248protected:
    237249
     
    442454
    443455
    444 
    445456/** Information required while the node is live
    446457
     
    652663  inline int depth() const
    653664  {return depth_;}
     665  /// Set depth in branch-and-cut search tree
     666  inline void setDepth(int value)
     667  {depth_ = value;}
    654668  /// Get the number of objects unsatisfied at this node.
    655669  inline int numberUnsatisfied() const
  • trunk/Cbc/src/CbcSolver.cpp

    r1085 r1087  
    36923692#endif 
    36933693  // Say no resolve after cuts
    3694   //model_.setResolveAfterTakeOffCuts(false);
     3694  model_.setResolveAfterTakeOffCuts(false);
    36953695  // see if log in list
    36963696  for (int i=1;i<argc;i++) {
     
    41294129#ifdef MORE_CUTS
    41304130      gomoryGen.setAwayAtRoot(0.005);
    4131       //gomoryGen.setAway(0.01);
    41324131#else
    41334132      gomoryGen.setAwayAtRoot(0.01);
     
    45284527                  }
    45294528                  // try changing tolerance at root
    4530                   gomoryGen.setAwayAtRoot(0.01);
     4529                  //gomoryGen.setAwayAtRoot(0.01);
    45314530                  int iParam;
    45324531                  iParam = whichParam(DIVEOPT,numberParameters_,parameters_);
     
    63716370                  gomoryGen.setLimitAtRoot(numberColumns);
    63726371                  gomoryGen.setLimit(numberColumns);
     6372                } else if (gomoryAction==6) {
     6373                  gomoryAction=3;
     6374                  gomoryGen.setLimitAtRoot(numberColumns);
     6375                  gomoryGen.setLimit(200);
    63736376                } else if (numberColumns>5000) {
     6377                  //#define MORE_CUTS2
     6378#ifdef MORE_CUTS2
     6379                  // try larger limit
     6380                  gomoryGen.setLimitAtRoot(numberColumns);
     6381                  gomoryGen.setLimit(200);
     6382#else
    63746383                  gomoryGen.setLimitAtRoot(2000);
    63756384                  //gomoryGen.setLimit(200);
     6385#endif
     6386                } else {
     6387#ifdef MORE_CUTS2
     6388                  // try larger limit
     6389                  gomoryGen.setLimitAtRoot(numberColumns);
     6390                  gomoryGen.setLimit(200);
     6391#endif
    63766392                }
    63776393                babModel_->addCutGenerator(&gomoryGen,translate[gomoryAction],"Gomory");
     
    75747590                    babModel_->setFastNodeDepth(-9);
    75757591                }
     7592#ifdef CLP_MULTIPLE_FACTORIZATIONS   
     7593                int denseCode = parameters_[whichParam(DENSE,numberParameters_,parameters_)].intValue();
     7594                int smallCode = parameters_[whichParam(SMALLFACT,numberParameters_,parameters_)].intValue();
    75767595                if (bothFlags>=1) {
    7577 #ifdef CLP_MULTIPLE_FACTORIZATIONS   
    7578                   int goDense=40;
    7579                   //double size=lpSolver->numberColumns()*lpSolver->numberRows();
    7580                   //if (lpSolver->getNumElements()>0.5*size&&
    7581                   //  lpSolver->numberRows()<150)
    7582                   //goDense=lpSolver->numberRows()+5;
    7583                   lpSolver->factorization()->setGoDenseThreshold(goDense);
    7584                   if (lpSolver->numberRows()<=goDense)
    7585                     lpSolver->factorization()->goDense();
    7586 #endif
    7587                 }
    7588                 int denseCode = parameters_[whichParam(DENSE,numberParameters_,parameters_)].intValue();
    7589                 osiclp = dynamic_cast< OsiClpSolverInterface*> (babModel_->solver());
    7590                 lpSolver = osiclp->getModelPtr();
    7591 #ifdef CLP_MULTIPLE_FACTORIZATIONS   
     7596                  if (denseCode<0)
     7597                    denseCode=40;
     7598                  if (smallCode<0)
     7599                    smallCode=40;
     7600                }
    75927601                if (denseCode>0)
    75937602                  lpSolver->factorization()->setGoDenseThreshold(denseCode);
    7594 #endif
    7595                 if (denseCode>=lpSolver->numberRows()) {
    7596                   lpSolver->factorization()->goDense();
    7597                 }
     7603                if (smallCode>0)
     7604                  lpSolver->factorization()->setGoSmallThreshold(smallCode);
     7605                //if (denseCode>=lpSolver->numberRows()) {
     7606                //lpSolver->factorization()->goDense();
     7607                //}
     7608#endif
    75987609#ifdef CLIQUE_ANALYSIS
    75997610                if (!storedAmpl.sizeRowCuts()) {
     
    77237734                */
    77247735                int extra1 = parameters_[whichParam(EXTRA1,numberParameters_,parameters_)].intValue();
    7725                 double stuff[10];
     7736                double stuff[11];
    77267737                stuff[0]=parameters_[whichParam(DEXTRA1,numberParameters_,parameters_)].doubleValue();
    77277738                stuff[1]=parameters_[whichParam(DEXTRA2,numberParameters_,parameters_)].doubleValue();
     
    77357746                stuff[8]=bothFlags;
    77367747                stuff[9]=doVector;
     7748                stuff[10] = parameters_[whichParam(SMALLFACT,numberParameters_,parameters_)].intValue();
    77377749                int returnCode=CbcClpUnitTest(model_, dirMiplib, extra1==1,stuff);
    77387750                babModel_=NULL;
  • trunk/Cbc/src/CbcStrategy.cpp

    r1053 r1087  
    137137  // Probing first as gets tight bounds on continuous
    138138  int genFlags=63;
    139   //#define CBC_GENERATE_TEST
     139  //#define CBC_GENERATE_TEST 
    140140#ifdef CBC_GENERATE_TEST
    141141  int nNodes = model.getMaximumNodes();
  • trunk/Cbc/src/unitTestClp.cpp

    r1067 r1087  
    132132    //PUSH_MPS("seymour_1",4944,1372,410.7637014,404.35152,7);
    133133    //PUSH_MPS("enigma",21,100,0.0,0.0,7);
     134    //PUSH_MPS("misc03",96,160,3360,1910.,7);
     135    //PUSH_MPS("p0201",133,201,7615,6875.0,7);
    134136#define HOWMANY 2
    135137#if HOWMANY
     
    399401      model->solver()->activateRowCutDebugger(problemName.c_str()) ;
    400402    }
     403    if (model->getNumCols()==-201) {
     404      // p201
     405      std::string problemName ;
     406      model->solver()->getStrParam(OsiProbName,problemName) ;
     407      model->solver()->activateRowCutDebugger(problemName.c_str()) ;
     408    }
     409    if (model->getNumCols()==-104) {
     410      // bell5
     411      std::string problemName ;
     412      model->solver()->getStrParam(OsiProbName,problemName) ;
     413      model->solver()->activateRowCutDebugger(problemName.c_str()) ;
     414    }
     415    if (model->getNumCols()==-548&&model->getNumRows()==176) {
     416      // p0548
     417      std::string problemName ;
     418      model->solver()->getStrParam(OsiProbName,problemName) ;
     419      model->solver()->activateRowCutDebugger(problemName.c_str()) ;
     420    }
    401421    if (model->getNumCols()==-160) {
    402422      // misc03
     
    448468      model->solver()->activateRowCutDebugger(problemName.c_str()) ;
    449469    }
     470    if (model->getNumCols()==-240&&model->getNumRows()==136) {
     471      // pp08a
     472      std::string problemName ;
     473      model->solver()->getStrParam(OsiProbName,problemName) ;
     474      model->solver()->activateRowCutDebugger(problemName.c_str()) ;
     475    }
    450476    if (model->getNumCols()==-1372&&model->getNumRows()==4944) {
    451477      // seymour1
     
    455481    }
    456482    setCutAndHeuristicOptions(*model);
     483#ifdef CLP_MULTIPLE_FACTORIZATIONS   
     484    int denseCode = stuff ? (int) stuff[4] : -1;
     485    int smallCode = stuff ? (int) stuff[10] : -1;
    457486    if (stuff&&stuff[8]>=1) {
    458       if (modelC->numberColumns()+modelC->numberRows()<=500)
     487      if (denseCode<0)
     488        denseCode=40;
     489      if (smallCode<0)
     490        smallCode=40;
     491    }
     492    if (denseCode>0)
     493      modelC->factorization()->setGoDenseThreshold(denseCode);
     494    if (smallCode>0)
     495      modelC->factorization()->setGoSmallThreshold(smallCode);
     496    if (denseCode>=modelC->numberRows()) {
     497      printf("problem going dense\n");
     498      //modelC->factorization()->goDenseOrSmall(modelC->numberRows());
     499    }
     500#endif
     501    if (stuff&&stuff[8]>=1) {
     502      if (modelC->numberColumns()+modelC->numberRows()<=500&&
     503          model->fastNodeDepth()==-1)
    459504        model->setFastNodeDepth(-9);
    460 #ifdef CLP_MULTIPLE_FACTORIZATIONS   
    461       modelC->factorization()->setGoDenseThreshold(40);
    462       if (modelC->numberRows()<=40)
    463         modelC->factorization()->goDense();
    464 #endif
    465     }
    466 #ifdef CLP_MULTIPLE_FACTORIZATIONS   
    467     if (stuff&&stuff[4]>0)
    468       modelC->factorization()->setGoDenseThreshold((int) stuff[4]);
    469 #endif
    470     if (stuff&&stuff[4]>=modelC->numberRows()) {
    471       printf("problem going dense\n");
    472       modelC->factorization()->goDense();
    473505    }
    474506    model->branchAndBound();
Note: See TracChangeset for help on using the changeset viewer.