Changeset 48


Ignore:
Timestamp:
Dec 31, 2004 4:53:27 AM (16 years ago)
Author:
forrest
Message:

skip messages etc

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcMessage.cpp

    r5 r48  
    4141  {CBC_NOTFEAS3,23,2,"Allowing solution, even though largest row infeasibility is %g"},
    4242  {CBC_CUTOFF_WARNING1,23,1,"Cutoff set to %g - equivalent to best solution of %g"},
    43   {CBC_ITERATE_STRONG,24,3,"%d cleanup iterations before strong branching"},
     43  {CBC_ITERATE_STRONG,25,3,"%d cleanup iterations before strong branching"},
     44  {CBC_WARNING_STRONG,3008,1,"Strong branching is fixing too many variables, too expensively!"},
    4445  {CBC_DUMMY_END,999999,0,""}
    4546};
  • trunk/CbcModel.cpp

    r45 r48  
    580580    }
    581581    phase_=3;
     582    // only allow twenty passes
     583    int numberPassesLeft=20;
    582584    while (anyAction == -1)
    583     { anyAction = newNode->chooseBranch(this,NULL) ;
     585    {
     586      anyAction = newNode->chooseBranch(this,NULL,numberPassesLeft) ;
     587      numberPassesLeft--;
    584588      if (anyAction == -1)
    585589      { feasible = resolve() ;
     
    698702     Could use last parameter for subtle differences */
    699703  solver_->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo,NULL) ;
     704  /*
     705    It is possible that strong branching fixes one variable and then the code goes round
     706    again and again.  This can take too long.  So we need to warn user - just once.
     707  */
     708  int numberLongStrong=0;
    700709/*
    701710  At last, the actual branch-and-cut search loop, which will iterate until
     
    897906          if (newNode->objectiveValue() >= getCutoff())
    898907            anyAction=-2;
     908          // only allow twenty passes
     909          int numberPassesLeft=20;
    899910          while (anyAction == -1)
    900           { anyAction = newNode->chooseBranch(this,node) ;
     911          {
     912            anyAction = newNode->chooseBranch(this,node,numberPassesLeft) ;
     913            numberPassesLeft--;
     914            if (numberPassesLeft<=-1) {
     915              if (!numberLongStrong)
     916                messageHandler()->message(CBC_WARNING_STRONG,
     917                                          messages()) << CoinMessageEol ;
     918              numberLongStrong++;
     919            }
    901920            if (anyAction == -1)
    902921            { feasible = resolve() ;
     
    24402459              OsiRowCut thisCut = theseCuts.rowCut(k) ;
    24412460              /* check size of elements.
    2442                  We can allow smaller but this helsp debug generators as it
     2461                 We can allow smaller but this helps debug generators as it
    24432462                 is unsafe to have small elements */
    24442463              int n=thisCut.row().getNumElements();
     
    31023121*/
    31033122  if (feasible)
    3104   { solver_->resolve() ;
     3123  {
     3124    solver_->resolve() ;
    31053125    numberIterations_ += getIterationCount() ;
    31063126    feasible = (solver_->isProvenOptimal() &&
  • trunk/CbcNode.cpp

    r44 r48  
    842842*/
    843843
    844 int CbcNode::chooseBranch (CbcModel *model, CbcNode *lastNode)
     844int CbcNode::chooseBranch (CbcModel *model, CbcNode *lastNode,int numberPassesLeft)
    845845
    846846{ if (lastNode)
     
    855855  const double * lower = solver->getColLower();
    856856  const double * upper = solver->getColUpper();
    857 
    858857  int anyAction=0;
    859858  double integerTolerance =
     
    10931092    }
    10941093  }
     1094  // If we have hit max time don't do strong branching
     1095  bool hitMaxTime = ( CoinCpuTime()-model->getDblParam(CbcModel::CbcStartSeconds) >
     1096                        model->getDblParam(CbcModel::CbcMaximumSeconds));
     1097  // also give up if we are looping round too much
     1098  if (hitMaxTime||numberPassesLeft<=0)
     1099    numberStrong=0;
    10951100/*
    10961101  Is strong branching enabled? If so, set up and do it. Otherwise, we'll
     
    11031108   
    11041109    bool solveAll=false; // set true to say look at all even if some fixed (experiment)
     1110    // worth trying if too many times
    11051111    // Save basis
    11061112    CoinWarmStart * ws = solver->getWarmStart();
     
    12131219        restoring the bounds.
    12141220*/
    1215     // If we have hit max time ignore fixing on one way
    1216     bool hitMaxTime = ( CoinCpuTime()-model->getDblParam(CbcModel::CbcStartSeconds) >
    1217                         model->getDblParam(CbcModel::CbcMaximumSeconds));
    12181221    for (i = 0 ; i < numberStrong ; i++)
    12191222    { double objectiveChange ;
     
    13641367        if(choice[i].downMovement<1.0e100) {
    13651368          // feasible - no action
    1366         } else if (!hitMaxTime) {
     1369        } else {
    13671370          // up feasible, down infeasible
    13681371          anyAction=-1;
     
    13751378      } else {
    13761379        if(choice[i].downMovement<1.0e100) {
    1377           if (!hitMaxTime) {
    1378             // down feasible, up infeasible
    1379             anyAction=-1;
    1380             if (!solveAll) {
    1381               choice[i].possibleBranch->way(-1);
    1382               choice[i].possibleBranch->branch();
    1383               break;
    1384             }
     1380          // down feasible, up infeasible
     1381          anyAction=-1;
     1382          if (!solveAll) {
     1383            choice[i].possibleBranch->way(-1);
     1384            choice[i].possibleBranch->branch();
     1385            break;
    13851386          }
    13861387        } else {
  • trunk/include/CbcMessage.hpp

    r5 r48  
    4747  CBC_CUTOFF_WARNING1,
    4848  CBC_ITERATE_STRONG,
     49  CBC_WARNING_STRONG,
    4950  CBC_DUMMY_END
    5051};
  • trunk/include/CbcNode.hpp

    r5 r48  
    419419    evaluated, and an appropriate branch object is installed.
    420420
     421    The numberPassesLeft is decremented to stop fixing one variable each time
     422    and going on and on (e.g. for stock cutting, air crew scheduling)
     423
    421424    If evaluation determines that an object is monotone or infeasible,
    422425    the routine returns immediately. In the case of a monotone object,
     
    431434  */
    432435  int chooseBranch (CbcModel * model,
    433                     CbcNode * lastNode);
     436                    CbcNode * lastNode,
     437                    int numberPassesLeft);
    434438 
    435439  /// Decrement active cut counts
Note: See TracChangeset for help on using the changeset viewer.