Changeset 501


Ignore:
Timestamp:
Feb 14, 2011 12:43:46 PM (9 years ago)
Author:
pbelotti
Message:

added separator management to TwoImpl?. Added timer to disjunctive cuts. Minor changes

Location:
trunk/Couenne/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/convex/generateCuts.cpp

    r490 r501  
    8989                                        const CglTreeInfo info) const {
    9090
    91   if (isWiped (cs))
     91  if (isWiped (cs) ||
     92     (CoinCpuTime () > problem_ -> getMaxCpuTime ()))
    9293    return;
    9394
     
    192193
    193194    for (int i=0; i<nnlc; i++) {
     195
     196      if (CoinCpuTime () > problem_ -> getMaxCpuTime ())
     197        break;
    194198
    195199      // for each constraint
     
    314318
    315319      // if there exists violation, add constraint
    316       CouNumber l = con -> Lb () -> Value (),   
     320      CouNumber
     321        l = con -> Lb () -> Value (),   
    317322        u = con -> Ub () -> Value ();
    318323
  • trunk/Couenne/src/disjunctive/CouenneDisjCuts.cpp

    r490 r501  
    3939  options -> GetNumericValue ("time_limit", cpuTime_,  "couenne.");
    4040
    41   options -> GetNumericValue ("disj_init_perc",   initDisjPercentage_,  "couenne.");
    42   options -> GetIntegerValue ("disj_init_number", initDisjNumber_,      "couenne.");
    43   options -> GetIntegerValue ("disj_depth_level", depthLevelling_,      "couenne.");
    44   options -> GetIntegerValue ("disj_depth_stop",  depthStopSeparate_,   "couenne.");
     41  options -> GetNumericValue ("disj_init_perc",   initDisjPercentage_, "couenne.");
     42  options -> GetIntegerValue ("disj_init_number", initDisjNumber_,     "couenne.");
     43  options -> GetIntegerValue ("disj_depth_level", depthLevelling_,     "couenne.");
     44  options -> GetIntegerValue ("disj_depth_stop",  depthStopSeparate_,  "couenne.");
    4545
    4646  std::string s;
  • trunk/Couenne/src/disjunctive/Makefile.am

    r488 r501  
    3232        -I`$(CYGPATH_W) $(srcdir)/../expression` \
    3333        -I`$(CYGPATH_W) $(srcdir)/../bound_tightening` \
    34         -I`$(CYGPATH_W) $(srcdir)/../branch`\
     34        -I`$(CYGPATH_W) $(srcdir)/../branch` \
    3535        -I`$(CYGPATH_W) $(srcdir)/../problem`
    3636
  • trunk/Couenne/src/disjunctive/generateDisjCuts.cpp

    r490 r501  
    155155      for (std::vector <std::pair <OsiCuts *, OsiCuts *> >::iterator disjI = disjunctions.begin ();
    156156           disjI != disjunctions.end (); ++disjI) {
     157
     158        if (CoinCpuTime () > couenneCG_ -> Problem () -> getMaxCpuTime ()) {
     159          start_over = false;
     160          break;
     161        }
    157162
    158163        // separate on single disjunction
     
    293298                        cs.sizeColCuts () - initColCuts);
    294299  }
     300
    295301  // else {
    296302  //     jnlst_ -> Printf (J_STRONGWARNING, J_COUENNE,
  • trunk/Couenne/src/heuristics/BonNlpHeuristic.cpp

    r488 r501  
    115115  // happen.
    116116
    117   int nodeDepth = -1;
     117  //  int nodeDepth = -1;
     118
     119  const int depth = (model_ -> currentNode ()) ? model_ -> currentNode () -> depth () : 0;
    118120
    119121  try {
     
    137139  // feasibility is low
    138140  bool too_deep = false;
    139 
    140   const int depth = (model_ -> currentNode ()) ? model_ -> currentNode () -> depth () : 0;
    141   nodeDepth = depth;
    142141
    143142  // check depth
     
    375374  delete [] upper;
    376375
    377   if (nodeDepth <= 0) {
     376  if (depth <= 0) {
     377
    378378    if (foundSolution) couenne_ -> Jnlst () -> Printf (J_ERROR, J_COUENNE, "done. Solution: %g\n", objectiveValue);
    379379    else               couenne_ -> Jnlst () -> Printf (J_ERROR, J_COUENNE, "done (no solution).\n");
     
    393393      CoinCopyN       (couenne_ -> getCutOffSol (), couenne_ -> nVars (), newSolution);
    394394
    395       if (nodeDepth <= 0)
     395      if (depth <= 0)
    396396        couenne_ -> Jnlst () -> Printf (J_ERROR, J_COUENNE, "done. Solution: %g\n", objectiveValue);
    397397
     
    400400    } else {
    401401
    402       if (nodeDepth <= 0 && e==noSolution)
     402      if (depth <= 0 && e==noSolution)
    403403        couenne_ -> Jnlst () -> Printf (J_ERROR, J_COUENNE, "done (no solution).\n", objectiveValue);
    404404      return 0;
  • trunk/Couenne/src/two_implied_bt/CouenneTwoImplied.hpp

    r490 r501  
    217217    /// first call indicator
    218218    mutable bool firstCall_;
     219
     220    /// Depth of the BB tree where to start decreasing chance of running this
     221    int depthLevelling_;
     222
     223    /// Depth of the BB tree where stop separation
     224    int depthStopSeparate_;
    219225  };
    220226}
  • trunk/Couenne/src/two_implied_bt/Makefile.am

    r488 r501  
    2525        -I`$(CYGPATH_W) $(srcdir)/..` \
    2626        -I`$(CYGPATH_W) $(srcdir)/../expression` \
    27         -I`$(CYGPATH_W) $(srcdir)/../branch`\
     27        -I`$(CYGPATH_W) $(srcdir)/../branch` \
    2828        -I`$(CYGPATH_W) $(srcdir)/../problem` \
    2929        -I`$(CYGPATH_W) $(srcdir)/../bound_tightening`
  • trunk/Couenne/src/two_implied_bt/TwoImpliedConstructors.cpp

    r490 r501  
    3131  firstCall_ (true) {
    3232
    33   options -> GetIntegerValue ("two_implied_max_trials", nMaxTrials_, "couenne.");
     33  options -> GetIntegerValue ("two_implied_max_trials", nMaxTrials_,        "couenne.");
     34  options -> GetIntegerValue ("twoimpl_depth_level",    depthLevelling_,    "couenne.");
     35  options -> GetIntegerValue ("twoimpl_depth_stop",     depthStopSeparate_, "couenne.");
    3436}
    3537
     
    3840CouenneTwoImplied::CouenneTwoImplied (const CouenneTwoImplied &src):
    3941
    40   CglCutGenerator (src),
    41   problem_        (src.problem_),
    42   jnlst_          (src.jnlst_),
    43   nMaxTrials_     (src.nMaxTrials_),
    44   totalTime_      (src.totalTime_),
    45   totalInitTime_  (src.totalInitTime_),
    46   firstCall_      (src.firstCall_) {}
     42  CglCutGenerator    (src),
     43  problem_           (src.problem_),
     44  jnlst_             (src.jnlst_),
     45  nMaxTrials_        (src.nMaxTrials_),
     46  totalTime_         (src.totalTime_),
     47  totalInitTime_     (src.totalInitTime_),
     48  firstCall_         (src.firstCall_),
     49  depthLevelling_    (src.depthLevelling_),
     50  depthStopSeparate_ (src.depthStopSeparate_) {}
    4751
    4852
     
    7175    ("two_implied_max_trials",
    7276     "The number of iteration at each call to the cut generator.",
    73      1, 3,
     77     1, 2,
    7478     "");
     79
     80  roptions -> AddLowerBoundedIntegerOption
     81    ("twoimpl_depth_level",
     82     "Depth of the B&B tree when to start decreasing the chance of running this algorithm.",
     83     -1, 5, "This has a similar behavior as log_num_obbt_per_level. "
     84     "A value of -1 means that generation can be done at all nodes.");
     85
     86  roptions -> AddLowerBoundedIntegerOption
     87    ("twoimpl_depth_stop",
     88     "Depth of the B&B tree where separation is stopped.",
     89     -1, 20, "A value of -1 means that generation can be done at all nodes");
    7590}
  • trunk/Couenne/src/two_implied_bt/TwoImpliedGenCuts.cpp

    r490 r501  
    1414#include "BonCbc.hpp"
    1515#include "BonBabInfos.hpp"
     16#include "CoinHelperFunctions.hpp"
    1617#include "CoinPackedMatrix.hpp"
    1718#include "CglCutGenerator.hpp"
     
    2526#include "CouenneProblem.hpp"
    2627#include "CouenneInfeasCut.hpp"
     28#include "CouenneJournalist.hpp"
    2729
    2830// necessary to make updateBranchInfo visible
     
    5860
    5961  // don't perform this is cs has been added an infeasible cut (a
    60   // result of some bound tightening procedure returning an infeasible
    61   // node)
     62  // result of some bound tightening procedure discovering an
     63  // infeasible node)
    6264
    6365  if (isWiped (cs))
     
    6567
    6668  double now = CoinCpuTime ();
     69
     70  // a more elaborate scheme to avoid heavy use of this heavy procedure
     71
     72  if ((depthStopSeparate_ >= 0 &&           // if -1, there is no limit on depth
     73       info.level > depthStopSeparate_)     // otherwise, check if too deep for adding these cuts
     74      ||
     75      (depthLevelling_ >= 0 &&              // chance to run this procedure
     76       info.level >= depthLevelling_ &&
     77       CoinDrand48 () > 1. / (2. + info.level - depthLevelling_)))
     78    return;
     79
     80  // printf ("probexecute = %g. Level = %d, depthlevelling = %d, depthStop = %d, cond = %d\n",
     81  //      1. / (2. + info.level - depthLevelling_),
     82  //      info.level,
     83  //      depthLevelling_,
     84  //      depthStopSeparate_,
     85  //      (depthLevelling_ < 0 || info.level < depthLevelling_));
    6786
    6887  // Update CouenneProblem's bounds using si's getCol{Low,Upp}er() and
     
    142161    // copy rA, rInd, rSta into A, ind, sta
    143162
    144     CoinFillN (sta, n+1, 0);
     163    CoinZeroN (sta, n+1);
    145164
    146165    /////////////////////////////////////////////////////////
     
    183202      int rowStart = rSta [i];
    184203
    185       //printf ("[ine] %4d [%g,%g]: ", i, rlb [i], rub [i]);
    186 
    187204      for (int j = rowStart, jj = rSta [i+1] - rowStart; jj--; j++) {
    188 
    189         //printf ("%+g x%d ", rA [j], rInd [j]);
    190205
    191206        int &curSta = sta [rInd [j]];
     
    242257#endif
    243258
    244   /// prepare vector for integrality test. Since many checks are done
     259  /// Prepare vector for integrality test. Since many checks are done
    245260  /// within combine(), it is worth to prepare one here
    246261
     
    252267  // print out
    253268
    254   if (0)
    255   for (int i=0; i<n; i++) {
    256 
    257     printf ("x%04d - %5d -> %5d, %5d elements:", i, sta [i], sta [i+1], sta [i+1] - sta [i]);
    258     fflush (stdout);
    259 
    260     for (int j=0; j<sta [i+1] - sta [i]; j++) {
    261       printf ("(%d,%g) ", ind [sta [i] + j], A [sta [i] + j]);
    262       fflush (stdout);
    263     }
    264     printf ("\n");
    265   }
     269  // for (int i=0; i<n; i++) {
     270
     271  //   printf ("x%04d - %5d -> %5d, %5d elements:", i, sta [i], sta [i+1], sta [i+1] - sta [i]);
     272  //   fflush (stdout);
     273
     274  //   for (int j=0; j<sta [i+1] - sta [i]; j++) {
     275  //     printf ("(%d,%g) ", ind [sta [i] + j], A [sta [i] + j]);
     276  //     fflush (stdout);
     277  //   }
     278  //   printf ("\n");
     279  // }
    266280
    267281  // For every column i, compare pairs of rows j and k with nonzero
     
    287301      for (int kk = jj,              k = j+1;  kk--; k++) {
    288302
     303        if (CoinCpuTime () > problem_ -> getMaxCpuTime ())
     304          break;
     305
    289306        register int
    290307          indj = ind [j],
     
    298315
    299316          if (nBadColMatWarnings++ < 1)
    300             printf ("Couenne: warning, matrix by row has nonsense indices.\n\
    301 This separator will now return without cuts.\n\
    302 NOTE: further such inconsistencies won't be reported.\n");
     317            //      jnlst_ -> Printf (J_STRONGWARNING, J_BOUNDTIGHTENING, "
     318            printf ("\
     319  Couenne: warning, matrix by row has nonsense indices.\n\
     320  This separator will now return without (column) cuts.\n\
     321  NOTE: further such inconsistencies won't be reported.\n");
    303322
    304323          delete [] sa1;
     
    430449    for (std::set <std::pair <int, int> >:: iterator p = pairs.begin (); p != pairs.end (); ++p) {
    431450
     451      if (CoinCpuTime () > problem_ -> getMaxCpuTime ())
     452        break;
     453
    432454      // indices of the two inequalities
    433455
     
    629651        break;
    630652
    631       } else{
     653      } else {
    632654
    633655        // update tightened bounds from problem to clb
Note: See TracChangeset for help on using the changeset viewer.