source: trunk/CbcStrategy.cpp @ 277

Last change on this file since 277 was 277, checked in by lou, 14 years ago

Revise cbc build process for better control of solvers included in build
(COIN_USE_XXX -> CBC_USE_XXX). Add CbcEventHandler? for independence from
clp.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.5 KB
Line 
1// Copyright (C) 2005, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#if defined(_MSC_VER)
4// Turn off compiler warning about long names
5#  pragma warning(disable:4786)
6#endif
7#include <cassert>
8#include <cmath>
9#include <cfloat>
10
11#include "OsiSolverInterface.hpp"
12#ifdef CBC_USE_CLP
13#include "OsiClpSolverInterface.hpp"
14#endif
15#include "CbcModel.hpp"
16#include "CbcMessage.hpp"
17#include "CbcStrategy.hpp"
18#include "CbcCutGenerator.hpp"
19#include "CbcBranchActual.hpp"
20#include "CbcNode.hpp"
21#include "CoinWarmStart.hpp"
22#include "CglPreProcess.hpp"
23// Cuts
24
25#include "CglGomory.hpp"
26#include "CglProbing.hpp"
27#include "CglKnapsackCover.hpp"
28#include "CglOddHole.hpp"
29#include "CglClique.hpp"
30#include "CglFlowCover.hpp"
31#include "CglMixedIntegerRounding2.hpp"
32
33// Heuristics
34
35#include "CbcHeuristic.hpp"
36
37// Default Constructor
38CbcStrategy::CbcStrategy() 
39  :depth_(0),
40   preProcessState_(0),
41   process_(NULL)
42{
43}
44
45// Destructor
46CbcStrategy::~CbcStrategy ()
47{
48  delete process_;
49}
50// Delete pre-processing object to save memory
51void 
52CbcStrategy::deletePreProcess()
53{ 
54  delete process_;
55  process_=NULL;
56}
57// Return a new Full node information pointer (descendant of CbcFullNodeInfo)
58CbcNodeInfo * 
59CbcStrategy::fullNodeInfo(CbcModel * model,int numberRowsAtContinuous) const
60{
61  return new CbcFullNodeInfo(model,numberRowsAtContinuous);
62}
63// Return a new Partial node information pointer (descendant of CbcPartialNodeInfo)
64CbcNodeInfo * 
65CbcStrategy::partialNodeInfo(CbcModel * model, CbcNodeInfo * parent, CbcNode * owner,
66                             int numberChangedBounds,const int * variables,
67                             const double * boundChanges,
68                             const CoinWarmStartDiff *basisDiff) const
69{
70  return new CbcPartialNodeInfo(parent, owner, numberChangedBounds, variables,
71                            boundChanges,basisDiff);
72}
73/* After a CbcModel::resolve this can return a status
74   -1 no effect
75   0 treat as optimal
76   1 as 0 but do not do any more resolves (i.e. no more cuts)
77   2 treat as infeasible
78*/
79int
80CbcStrategy::status(CbcModel * model, CbcNodeInfo * parent,int whereFrom)
81{
82  return -1;
83}
84
85// Default Constructor
86CbcStrategyDefault::CbcStrategyDefault(bool cutsOnlyAtRoot,
87                                       int numberStrong,
88                                       int numberBeforeTrust,
89                                       int printLevel)
90  :CbcStrategy(),
91   cutsOnlyAtRoot_(cutsOnlyAtRoot),
92   numberStrong_(numberStrong),
93   numberBeforeTrust_(numberBeforeTrust),
94   printLevel_(printLevel),
95   desiredPreProcess_(0),
96   preProcessPasses_(0)
97{
98}
99
100
101// Destructor
102CbcStrategyDefault::~CbcStrategyDefault ()
103{
104}
105
106// Clone
107CbcStrategy *
108CbcStrategyDefault::clone() const
109{
110  return new CbcStrategyDefault(*this);
111}
112
113// Copy constructor
114CbcStrategyDefault::CbcStrategyDefault(const CbcStrategyDefault & rhs)
115:
116  CbcStrategy(rhs),
117  cutsOnlyAtRoot_(rhs.cutsOnlyAtRoot_),
118  numberStrong_(rhs.numberStrong_),
119  numberBeforeTrust_(rhs.numberBeforeTrust_),
120  printLevel_(rhs.printLevel_),
121  desiredPreProcess_(rhs.desiredPreProcess_),
122  preProcessPasses_(rhs.preProcessPasses_)
123{
124  setNested(rhs.getNested());
125}
126
127// Setup cut generators
128void 
129CbcStrategyDefault::setupCutGenerators(CbcModel & model)
130{
131  // Set up some cut generators and defaults
132  // Probing first as gets tight bounds on continuous
133
134  CglProbing generator1;
135  generator1.setUsingObjective(true);
136  generator1.setMaxPass(1);
137  // Number of unsatisfied variables to look at
138  generator1.setMaxProbe(10);
139  // How far to follow the consequences
140  generator1.setMaxLook(10);
141  // Only look at rows with fewer than this number of elements
142  generator1.setMaxElements(200);
143  //generator1.setRowCuts(3);
144
145  CglGomory generator2;
146  // try larger limit
147  generator2.setLimit(300);
148
149  CglKnapsackCover generator3;
150
151  //CglOddHole generator4;
152  //generator4.setMinimumViolation(0.005);
153  //generator4.setMinimumViolationPer(0.00002);
154  // try larger limit
155  //generator4.setMaximumEntries(200);
156
157  CglClique generator5;
158  generator5.setStarCliqueReport(false);
159  generator5.setRowCliqueReport(false);
160
161  CglMixedIntegerRounding2 mixedGen;
162  CglFlowCover flowGen;
163 
164  // Add in generators
165  int setting = cutsOnlyAtRoot_ ? -99 : -1;
166  int numberGenerators = model.numberCutGenerators();
167  int iGenerator;
168  bool found;
169  found=false;
170  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
171    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
172    CglProbing * cgl = dynamic_cast<CglProbing *>(generator);
173    if (cgl) {
174      found=true;
175      break;
176    }
177  }
178  if (!found)
179    model.addCutGenerator(&generator1,setting,"Probing");
180  found=false;
181  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
182    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
183    CglGomory * cgl = dynamic_cast<CglGomory *>(generator);
184    if (cgl) {
185      found=true;
186      break;
187    }
188  }
189  if (!found)
190  model.addCutGenerator(&generator2,setting,"Gomory");
191  found=false;
192  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
193    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
194    CglKnapsackCover * cgl = dynamic_cast<CglKnapsackCover *>(generator);
195    if (cgl) {
196      found=true;
197      break;
198    }
199  }
200  if (!found)
201    model.addCutGenerator(&generator3,setting,"Knapsack");
202  //model.addCutGenerator(&generator4,setting,"OddHole");
203  found=false;
204  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
205    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
206    CglClique * cgl = dynamic_cast<CglClique *>(generator);
207    if (cgl) {
208      found=true;
209      break;
210    }
211  }
212  if (!found)
213    model.addCutGenerator(&generator5,setting,"Clique");
214  found=false;
215  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
216    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
217    CglFlowCover * cgl = dynamic_cast<CglFlowCover *>(generator);
218    if (cgl) {
219      found=true;
220      break;
221    }
222  }
223  if (!found)
224    model.addCutGenerator(&flowGen,setting,"FlowCover");
225  found=false;
226  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
227    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
228    CglMixedIntegerRounding2 * cgl = dynamic_cast<CglMixedIntegerRounding2 *>(generator);
229    if (cgl) {
230      found=true;
231      break;
232    }
233  }
234  if (!found)
235    model.addCutGenerator(&mixedGen,setting,"MixedIntegerRounding2");
236  // Say we want timings
237  int newNumberGenerators = model.numberCutGenerators();
238  for (iGenerator=numberGenerators;iGenerator<newNumberGenerators;iGenerator++) {
239    CbcCutGenerator * generator = model.cutGenerator(iGenerator);
240    generator->setTiming(true);
241  }
242  if (model.getNumCols()<500)
243    model.setMaximumCutPassesAtRoot(-100); // always do 100 if possible
244  else if (model.getNumCols()<5000)
245    model.setMaximumCutPassesAtRoot(100); // use minimum drop
246  else
247    model.setMaximumCutPassesAtRoot(20);
248}
249// Setup heuristics
250void 
251CbcStrategyDefault::setupHeuristics(CbcModel & model)
252{
253  // Allow rounding heuristic
254
255  CbcRounding heuristic1(model);
256  int numberHeuristics = model.numberHeuristics();
257  int iHeuristic;
258  bool found;
259  found=false;
260  for (iHeuristic=0;iHeuristic<numberHeuristics;iHeuristic++) {
261    CbcHeuristic * heuristic = model.heuristic(iHeuristic);
262    CbcRounding * cgl = dynamic_cast<CbcRounding *>(heuristic);
263    if (cgl) {
264      found=true;
265      break;
266    }
267  }
268  if (!found)
269    model.addHeuristic(&heuristic1);
270}
271// Do printing stuff
272void 
273CbcStrategyDefault::setupPrinting(CbcModel & model,int modelLogLevel)
274{
275  if (!modelLogLevel) {
276    model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
277    model.messageHandler()->setLogLevel(0);
278    model.solver()->messageHandler()->setLogLevel(0);
279  } else if (modelLogLevel==1) {
280    model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
281    model.messageHandler()->setLogLevel(1);
282    model.solver()->messageHandler()->setLogLevel(0);
283  } else {
284    model.messageHandler()->setLogLevel(2);
285    model.solver()->messageHandler()->setLogLevel(1);
286    model.setPrintFrequency(50);
287  }
288}
289// Other stuff e.g. strong branching
290void 
291CbcStrategyDefault::setupOther(CbcModel & model)
292{
293  // See if preprocessing wanted
294  if (desiredPreProcess_) {
295    delete process_;
296    // solver_ should have been cloned outside
297    CglPreProcess * process = new CglPreProcess();
298    OsiSolverInterface * solver = model.solver();
299    int logLevel = model.messageHandler()->logLevel();
300#ifdef CBC_USE_CLP
301    OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (solver);
302    ClpSimplex * lpSolver=NULL;
303    if (clpSolver) {
304      if (clpSolver->messageHandler()->logLevel())
305        clpSolver->messageHandler()->setLogLevel(1);
306      if (logLevel>-1)
307        clpSolver->messageHandler()->setLogLevel(CoinMin(logLevel,clpSolver->messageHandler()->logLevel()));
308      lpSolver = clpSolver->getModelPtr();
309      /// If user left factorization frequency then compute
310      lpSolver->defaultFactorizationFrequency();
311    }
312#endif
313    // Tell solver we are in Branch and Cut
314    solver->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo) ;
315    // Default set of cut generators
316    CglProbing generator1;
317    generator1.setUsingObjective(true);
318    generator1.setMaxPass(3);
319    generator1.setMaxProbeRoot(solver->getNumCols());
320    generator1.setMaxElements(100);
321    generator1.setMaxLookRoot(50);
322    generator1.setRowCuts(3);
323    //generator1.messageHandler()->setLogLevel(logLevel);
324    process->messageHandler()->setLogLevel(logLevel);
325    // Add in generators
326    process->addCutGenerator(&generator1);
327    int translate[]={9999,0,2,3};
328    OsiSolverInterface * solver2 = 
329      process->preProcessNonDefault(*solver,
330                                    translate[desiredPreProcess_],preProcessPasses_);
331    // Tell solver we are not in Branch and Cut
332    solver->setHintParam(OsiDoInBranchAndCut,false,OsiHintDo) ;
333    if (solver2)
334      solver2->setHintParam(OsiDoInBranchAndCut,false,OsiHintDo) ;
335    bool feasible=true;
336    if (!solver2) {
337      feasible = false;
338      //printf("Pre-processing says infeasible\n");
339      delete process;
340      preProcessState_=-1;
341      process_=NULL;
342    } else {
343      // now tighten bounds
344#ifdef CBC_USE_CLP
345      if (clpSolver) {
346        // model has changed
347        solver = model.solver();
348        OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (solver);
349        ClpSimplex * lpSolver = clpSolver->getModelPtr();
350        if (lpSolver->tightenPrimalBounds()==0) {
351          lpSolver->dual();
352        } else {
353          feasible = false;
354        }
355      }
356#endif
357      if (feasible) {
358        preProcessState_=1;
359        process_=process;
360        /* Note that original solver will be kept (with false)
361           and that final solver will also be kept.
362           This is for post-processing
363        */
364        OsiSolverInterface * solver3 = solver2->clone();
365        model.assignSolver(solver3,false);
366        if (process_->numberSOS()) {
367          int numberSOS = process_->numberSOS();
368          int numberIntegers = model.numberIntegers();
369          /* model may not have created objects
370             If none then create
371          */
372          if (!numberIntegers||!model.numberObjects()) {
373            model.findIntegers(true);
374            numberIntegers = model.numberIntegers();
375          }
376          CbcObject ** oldObjects = model.objects();
377          // Do sets and priorities
378          CbcObject ** objects = new CbcObject * [numberSOS];
379          // set old objects to have low priority
380          int numberOldObjects = model.numberObjects();
381          int numberColumns = model.getNumCols();
382          for (int iObj = 0;iObj<numberOldObjects;iObj++) {
383            int oldPriority = oldObjects[iObj]->priority();
384            oldObjects[iObj]->setPriority(numberColumns+oldPriority);
385          }
386          const int * starts = process_->startSOS();
387          const int * which = process_->whichSOS();
388          const int * type = process_->typeSOS();
389          const double * weight = process_->weightSOS();
390          int iSOS;
391          for (iSOS =0;iSOS<numberSOS;iSOS++) {
392            int iStart = starts[iSOS];
393            int n=starts[iSOS+1]-iStart;
394            objects[iSOS] = new CbcSOS(&model,n,which+iStart,weight+iStart,
395                                       iSOS,type[iSOS]);
396            // branch on long sets first
397            objects[iSOS]->setPriority(numberColumns-n);
398          }
399          model.addObjects(numberSOS,objects);
400          for (iSOS=0;iSOS<numberSOS;iSOS++)
401            delete objects[iSOS];
402          delete [] objects;
403        }
404      } else {
405        //printf("Pre-processing says infeasible\n");
406        delete process;
407        preProcessState_=-1;
408        process_=NULL;
409      }
410    }
411  }
412  model.setNumberStrong(numberStrong_);
413  model.setNumberBeforeTrust(numberBeforeTrust_);
414}
415// Default Constructor
416CbcStrategyDefaultSubTree::CbcStrategyDefaultSubTree(CbcModel * parent ,
417                                                     bool cutsOnlyAtRoot,
418                                       int numberStrong,
419                                       int numberBeforeTrust,
420                                       int printLevel)
421  :CbcStrategy(),
422   parentModel_(parent),
423   cutsOnlyAtRoot_(cutsOnlyAtRoot),
424   numberStrong_(numberStrong),
425   numberBeforeTrust_(numberBeforeTrust),
426   printLevel_(printLevel)
427{
428}
429
430
431// Destructor
432CbcStrategyDefaultSubTree::~CbcStrategyDefaultSubTree ()
433{
434}
435
436// Clone
437CbcStrategy *
438CbcStrategyDefaultSubTree::clone() const
439{
440  return new CbcStrategyDefaultSubTree(*this);
441}
442
443// Copy constructor
444CbcStrategyDefaultSubTree::CbcStrategyDefaultSubTree(const CbcStrategyDefaultSubTree & rhs)
445:
446  CbcStrategy(rhs),
447  parentModel_(rhs.parentModel_),
448  cutsOnlyAtRoot_(rhs.cutsOnlyAtRoot_),
449  numberStrong_(rhs.numberStrong_),
450  numberBeforeTrust_(rhs.numberBeforeTrust_),
451  printLevel_(rhs.printLevel_)
452{
453  setNested(rhs.getNested());
454}
455
456// Setup cut generators
457void 
458CbcStrategyDefaultSubTree::setupCutGenerators(CbcModel & model)
459{
460  // Set up some cut generators and defaults
461  // Probing first as gets tight bounds on continuous
462
463  CglProbing generator1;
464  generator1.setUsingObjective(true);
465  generator1.setMaxPass(1);
466  // Number of unsatisfied variables to look at
467  generator1.setMaxProbe(10);
468  // How far to follow the consequences
469  generator1.setMaxLook(10);
470  // Only look at rows with fewer than this number of elements
471  generator1.setMaxElements(200);
472  //generator1.setRowCuts(3);
473
474  CglGomory generator2;
475  // try larger limit
476  generator2.setLimit(300);
477
478  CglKnapsackCover generator3;
479
480  //CglOddHole generator4;
481  //generator4.setMinimumViolation(0.005);
482  //generator4.setMinimumViolationPer(0.00002);
483  // try larger limit
484  //generator4.setMaximumEntries(200);
485
486  CglClique generator5;
487  generator5.setStarCliqueReport(false);
488  generator5.setRowCliqueReport(false);
489
490  CglMixedIntegerRounding2 mixedGen;
491  CglFlowCover flowGen;
492 
493  // Add in generators
494  int setting = cutsOnlyAtRoot_ ? -99 : -1;
495  int numberGenerators = model.numberCutGenerators();
496  int numberParentGenerators = parentModel_->numberCutGenerators();
497  int iGenerator;
498  bool found;
499  found=false;
500  int howOften=0;
501  for (iGenerator=0;iGenerator<numberParentGenerators;iGenerator++) {
502    CglCutGenerator * generator = parentModel_->cutGenerator(iGenerator)->generator();
503    CglProbing * cgl = dynamic_cast<CglProbing *>(generator);
504    if (cgl) {
505      found=true;
506      howOften = parentModel_->cutGenerator(iGenerator)->howOften();
507      break;
508    }
509  }
510  if (found&&howOften>=0) {
511    found=false;
512    for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
513      CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
514      CglProbing * cgl = dynamic_cast<CglProbing *>(generator);
515      if (cgl) {
516        found=true;
517        break;
518      }
519    }
520    if (!found)
521      model.addCutGenerator(&generator1,setting,"Probing");
522  }
523  found=false;
524  for (iGenerator=0;iGenerator<numberParentGenerators;iGenerator++) {
525    CglCutGenerator * generator = parentModel_->cutGenerator(iGenerator)->generator();
526    CglGomory * cgl = dynamic_cast<CglGomory *>(generator);
527    if (cgl) {
528      found=true;
529      howOften = parentModel_->cutGenerator(iGenerator)->howOften();
530      break;
531    }
532  }
533  if (found&&howOften>=0) {
534    found=false;
535    for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
536      CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
537      CglGomory * cgl = dynamic_cast<CglGomory *>(generator);
538      if (cgl) {
539        found=true;
540        break;
541      }
542    }
543    if (!found)
544      model.addCutGenerator(&generator2,setting,"Gomory");
545  }
546  found=false;
547  for (iGenerator=0;iGenerator<numberParentGenerators;iGenerator++) {
548    CglCutGenerator * generator = parentModel_->cutGenerator(iGenerator)->generator();
549    CglKnapsackCover * cgl = dynamic_cast<CglKnapsackCover *>(generator);
550    if (cgl) {
551      found=true;
552      howOften = parentModel_->cutGenerator(iGenerator)->howOften();
553      break;
554    }
555  }
556  if (found&&howOften>=0) {
557    found=false;
558    for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
559      CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
560      CglKnapsackCover * cgl = dynamic_cast<CglKnapsackCover *>(generator);
561      if (cgl) {
562        found=true;
563        break;
564      }
565    }
566    if (!found)
567      model.addCutGenerator(&generator3,setting,"Knapsack");
568  }
569  found=false;
570  for (iGenerator=0;iGenerator<numberParentGenerators;iGenerator++) {
571    CglCutGenerator * generator = parentModel_->cutGenerator(iGenerator)->generator();
572    CglClique * cgl = dynamic_cast<CglClique *>(generator);
573    if (cgl) {
574      found=true;
575      howOften = parentModel_->cutGenerator(iGenerator)->howOften();
576      break;
577    }
578  }
579  if (found&&howOften>=0) {
580    found=false;
581    for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
582      CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
583      CglClique * cgl = dynamic_cast<CglClique *>(generator);
584      if (cgl) {
585        found=true;
586        break;
587      }
588    }
589    if (!found)
590      model.addCutGenerator(&generator5,setting,"Clique");
591  }
592  found=false;
593  for (iGenerator=0;iGenerator<numberParentGenerators;iGenerator++) {
594    CglCutGenerator * generator = parentModel_->cutGenerator(iGenerator)->generator();
595    CglFlowCover * cgl = dynamic_cast<CglFlowCover *>(generator);
596    if (cgl) {
597      found=true;
598      howOften = parentModel_->cutGenerator(iGenerator)->howOften();
599      break;
600    }
601  }
602  if (found&&howOften>=0) {
603    found=false;
604    for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
605      CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
606      CglFlowCover * cgl = dynamic_cast<CglFlowCover *>(generator);
607      if (cgl) {
608        found=true;
609        break;
610      }
611    }
612    if (!found)
613      model.addCutGenerator(&flowGen,setting,"FlowCover");
614    found=false;
615  }
616  for (iGenerator=0;iGenerator<numberParentGenerators;iGenerator++) {
617    CglCutGenerator * generator = parentModel_->cutGenerator(iGenerator)->generator();
618    CglMixedIntegerRounding2 * cgl = dynamic_cast<CglMixedIntegerRounding2 *>(generator);
619    if (cgl) {
620      found=true;
621      howOften = parentModel_->cutGenerator(iGenerator)->howOften();
622      break;
623    }
624  }
625  if (found&&howOften>=0) {
626    found=false;
627    for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
628      CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
629      CglMixedIntegerRounding2 * cgl = dynamic_cast<CglMixedIntegerRounding2 *>(generator);
630      if (cgl) {
631        found=true;
632        break;
633      }
634    }
635    if (!found)
636      model.addCutGenerator(&mixedGen,setting,"MixedIntegerRounding2");
637  }
638#if 0
639  // Say we want timings
640  int newNumberGenerators = model.numberCutGenerators();
641  for (iGenerator=numberGenerators;iGenerator<newNumberGenerators;iGenerator++) {
642    CbcCutGenerator * generator = model.cutGenerator(iGenerator);
643    generator->setTiming(true);
644  }
645#endif
646  if (model.getNumCols()<500)
647    model.setMaximumCutPassesAtRoot(-100); // always do 100 if possible
648  else if (model.getNumCols()<5000)
649    model.setMaximumCutPassesAtRoot(100); // use minimum drop
650  else
651    model.setMaximumCutPassesAtRoot(20);
652}
653// Setup heuristics
654void 
655CbcStrategyDefaultSubTree::setupHeuristics(CbcModel & model)
656{
657  // Allow rounding heuristic
658
659  CbcRounding heuristic1(model);
660  int numberHeuristics = model.numberHeuristics();
661  int iHeuristic;
662  bool found;
663  found=false;
664  for (iHeuristic=0;iHeuristic<numberHeuristics;iHeuristic++) {
665    CbcHeuristic * heuristic = model.heuristic(iHeuristic);
666    CbcRounding * cgl = dynamic_cast<CbcRounding *>(heuristic);
667    if (cgl) {
668      found=true;
669      break;
670    }
671  }
672  if (!found)
673    model.addHeuristic(&heuristic1);
674}
675// Do printing stuff
676void 
677CbcStrategyDefaultSubTree::setupPrinting(CbcModel & model,int modelLogLevel)
678{
679  if (!modelLogLevel) {
680    model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
681    model.messageHandler()->setLogLevel(0);
682    model.solver()->messageHandler()->setLogLevel(0);
683  } else if (modelLogLevel==1) {
684    model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
685    model.messageHandler()->setLogLevel(1);
686    model.solver()->messageHandler()->setLogLevel(0);
687  } else {
688    model.messageHandler()->setLogLevel(2);
689    model.solver()->messageHandler()->setLogLevel(1);
690    model.setPrintFrequency(50);
691  }
692}
693// Other stuff e.g. strong branching
694void 
695CbcStrategyDefaultSubTree::setupOther(CbcModel & model)
696{
697  model.setNumberStrong(numberStrong_);
698  model.setNumberBeforeTrust(numberBeforeTrust_);
699}
700
701
702 
Note: See TracBrowser for help on using the repository browser.