Ignore:
Timestamp:
Oct 3, 2014 7:58:33 AM (5 years ago)
Author:
forrest
Message:

symmetry and diving

File:
1 edited

Legend:

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

    r2051 r2092  
    2323#include "CbcBranchingObject.hpp"
    2424#include "CoinTime.hpp"
     25#define NAUTY_MAX_LEVEL 2000
     26#if NAUTY_MAX_LEVEL
     27extern int nauty_maxalllevel;
     28#endif
    2529/* Deliberately not threadsafe to save effort
    2630   Just for statistics
     
    2933 */
    3034static int nautyBranchCalls_ = 0;
     35static int lastNautyBranchCalls_ = 0;
    3136static int nautyBranchSucceeded_ = 0;
    3237static int nautyFixCalls_ = 0;
     38static int lastNautyFixCalls_ = 0;
    3339static int nautyFixSucceeded_ = 0;
    3440static double nautyTime_ = 0.0;
     
    96102  char general[200];
    97103  int returnCode=0;
     104  bool printSomething=true;
    98105  if (type) {
    99106    double branchSuccess=0.0;
     
    103110    if (nautyFixSucceeded_)
    104111      fixSuccess = nautyFixes_/nautyFixSucceeded_;
    105     sprintf(general,"Orbital branching tried %d times, succeeded %d times - average extra %7.3f, fixing %d times (%d, %7.3f) - %.2f seconds",
    106             nautyBranchCalls_,nautyBranchSucceeded_,branchSuccess,
    107             nautyFixCalls_,nautyFixSucceeded_,fixSuccess,nautyTime_);
     112    if (nautyBranchCalls_>lastNautyBranchCalls_||
     113        nautyFixCalls_>lastNautyFixCalls_) {
     114      sprintf(general,"Orbital branching tried %d times, succeeded %d times - average extra %7.3f, fixing %d times (%d, %7.3f)",
     115              nautyBranchCalls_,nautyBranchSucceeded_,branchSuccess,
     116              nautyFixCalls_,nautyFixSucceeded_,fixSuccess);
     117      lastNautyBranchCalls_=nautyBranchCalls_;
     118      lastNautyFixCalls_=nautyFixCalls_;
     119    } else {
     120      printSomething=false;
     121    }
    108122  } else {
    109123    returnCode = nauty_info_->getNumGenerators();
    110     if (returnCode) {
    111       sprintf (general,"Nauty: %d orbits, %d generators, group size: %g - dense size %d, sparse %d - going %s",
    112                nauty_info_->getNumOrbits(),
    113                nauty_info_ -> getNumGenerators () ,
    114                nauty_info_ -> getGroupSize (),
    115                whichOrbit_[0],whichOrbit_[1],nauty_info_->isSparse() ? "sparse" : "dense");
     124    if (!nauty_info_->errorStatus()) {
     125      if (returnCode && numberUsefulOrbits_) {
     126        sprintf (general,"Nauty: %d orbits (%d useful covering %d variables), %d generators, group size: %g - dense size %d, sparse %d - took %g seconds",
     127                 nauty_info_->getNumOrbits(),numberUsefulOrbits_,numberUsefulObjects_,
     128                 nauty_info_ -> getNumGenerators () ,
     129                 nauty_info_ -> getGroupSize (),
     130                 whichOrbit_[0],whichOrbit_[1],nautyTime_);
     131      } else {
     132        if ((model->moreSpecialOptions2()&(128|256))!=(128|256))
     133          sprintf(general,"Nauty did not find any useful orbits in time %g",nautyTime_);
     134        else
     135          sprintf(general,"Nauty did not find any useful orbits - but keeping Nauty on");
     136      }
    116137    } else {
    117       if ((model->moreSpecialOptions2()&(128|256))!=(128|256))
    118         sprintf(general,"Nauty did not find any useful orbits");
    119       else
    120         sprintf(general,"Nauty did not find any useful orbits - but keeping Nauty on");
    121     }
    122   }
    123   model->messageHandler()->message(CBC_GENERAL,
    124                                    model->messages())
    125     << general << CoinMessageEol ;
     138      // error
     139      sprintf(general,"Nauty failed with error code %d (%g seconds)",
     140              nauty_info_->errorStatus(),nautyTime_);
     141      model->setMoreSpecialOptions2(model->moreSpecialOptions2()&~(128|256));
     142    }
     143  }
     144  if (printSomething)
     145    model->messageHandler()->message(CBC_GENERAL,
     146                                     model->messages())
     147      << general << CoinMessageEol ;
    126148  return returnCode;
    127149}
     
    197219    whichOrbit_[i]=-1;
    198220  numberUsefulOrbits_=0;
     221  numberUsefulObjects_=0;
    199222
    200223  std::vector<std::vector<int> > *orbits = nauty_info_ -> getOrbits ();
     
    213236    if (nUseful>1) {
    214237      numberUsefulOrbits_++;
     238      numberUsefulObjects_ += nUseful;
    215239    } else if (jColumn>=0) {
    216240      assert (nUseful);
     
    292316}
    293317void CbcSymmetry::setupSymmetry (const OsiSolverInterface & solver) {
     318  double startCPU = CoinCpuTime ();
    294319  const double *objective = solver.getObjCoefficients() ;
    295320  const double *columnLower = solver.getColLower() ;
     
    353378  int * e = NULL;
    354379  bool sparse=false;
    355   double spaceDense = ((nc+WORDSIZE-1)*(nc+WORDSIZE-1))/WORDSIZE;
     380  double spaceDense = nc+WORDSIZE-1;
     381  spaceDense *= nc+WORDSIZE-1;
     382  spaceDense /= WORDSIZE;
    356383  int spaceSparse = 0;
    357384  {
     
    581608  nautyOtherBranches_ = 0.0;
    582609  Compute_Symmetry ();
     610  fillOrbits();
     611  //whichOrbit_[2]=numberUsefulOrbits_;
    583612  //Print_Orbits ();
    584613  // stats in array
    585   whichOrbit_[0]=spaceDense;
     614  if (spaceDense<COIN_INT_MAX)
     615    whichOrbit_[0]=spaceDense;
     616  else
     617    whichOrbit_[0]=COIN_INT_MAX;
    586618  whichOrbit_[1]=spaceSparse;
     619  double endCPU = CoinCpuTime ();
     620  nautyTime_ = endCPU-startCPU;
    587621}
    588622// Fixes variables using orbits (returns number fixed)
     
    654688    numberColumns_(0),
    655689    numberUsefulOrbits_(0),
     690    numberUsefulObjects_(0),
    656691    whichOrbit_(NULL)
    657692{
     
    663698  nauty_info_ = new CbcNauty(*rhs.nauty_info_);
    664699  numberUsefulOrbits_ = rhs.numberUsefulOrbits_;
     700  numberUsefulObjects_ = rhs.numberUsefulObjects_;
    665701  numberColumns_ = rhs.numberColumns_;
    666702  if (rhs.whichOrbit_)
     
    681717    numberColumns_ = rhs.numberColumns_;
    682718    numberUsefulOrbits_ = rhs.numberUsefulOrbits_;
     719    numberUsefulObjects_ = rhs.numberUsefulObjects_;
    683720    if (rhs.whichOrbit_)
    684721      whichOrbit_=CoinCopyOfArray(rhs.whichOrbit_,numberColumns_);
     
    9981035  //  if (autoComputed_) return;
    9991036
    1000   double startCPU = CoinCpuTime ();
     1037  //double startCPU = CoinCpuTime ();
    10011038
    10021039  options_->defaultptn = FALSE;
     
    10361073#endif
    10371074  } else {
     1075#if NAUTY_MAX_LEVEL
     1076    nauty_maxalllevel=NAUTY_MAX_LEVEL;
     1077#endif
    10381078#ifndef NTY_TRACES
    10391079    options_->dispatch = &dispatch_sparse;
     
    10481088  autoComputed_ = true;
    10491089
    1050   double endCPU = CoinCpuTime ();
    1051 
    1052   nautyTime_ += endCPU - startCPU;
     1090  //double endCPU = CoinCpuTime ();
     1091
     1092  //nautyTime_ += endCPU - startCPU;
    10531093  // Need to make sure all generators are written
    10541094  if (afp_) fflush(afp_);   
Note: See TracChangeset for help on using the changeset viewer.