Changeset 715


Ignore:
Timestamp:
Jul 31, 2007 5:57:40 AM (12 years ago)
Author:
forrest
Message:

mostly message handling

Location:
trunk/Cbc/src
Files:
7 edited

Legend:

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

    r700 r715  
    224224    returnCode=2; // infeasible finished
    225225  }
     226  model_->setLogLevel(logLevel);
    226227  return returnCode;
    227228}
  • trunk/Cbc/src/CbcHeuristicFPump.cpp

    r698 r715  
    340340    solver->getHintParam(OsiDoDualInResolve,takeHint,strength);
    341341    solver->setHintParam(OsiDoDualInResolve,false);
    342     solver->messageHandler()->setLogLevel(0);
     342    //solver->messageHandler()->setLogLevel(0);
    343343   
    344344    // 4. Save objective offset so we can see progress
  • trunk/Cbc/src/CbcMessage.cpp

    r702 r715  
    1717static Cbc_message us_english[]=
    1818{
    19   {CBC_END_GOOD,1,1,"Search completed - best objective %g, took %d iterations and %d nodes (%.2f seconds)"},
     19  {CBC_END_GOOD,1,1,"Search completed - best objective %.16g, took %d iterations and %d nodes (%.2f seconds)"},
    2020  {CBC_MAXNODES,3,1,"Exiting on maximum nodes"},
    2121  {CBC_MAXTIME,20,1,"Exiting on maximum time"},
     
    3535  {CBC_TREE_SOL,24,1,"Integer solution of %g found by subtree after %d iterations and %d nodes (%.2f seconds)"},
    3636  {CBC_ROOT,13,1,"At root node, %d cuts changed objective from %g to %g in %d passes"},
    37   {CBC_GENERATOR,14,1,"Cut generator %d (%s) - %d row cuts (%d active), %d column cuts %? in %g seconds - new frequency is %d"},
     37  {CBC_GENERATOR,14,1,"Cut generator %d (%s) - %d row cuts (%d active), %d column cuts %? in %.3f seconds - new frequency is %d"},
    3838  {CBC_BRANCH,15,2,"Node %d Obj %g Unsat %d depth %d"},
    3939  {CBC_STRONGSOL,16,1,"Integer solution of %g found by strong branching after %d iterations and %d nodes (%.2f seconds)"},
  • trunk/Cbc/src/CbcModel.cpp

    r702 r715  
    34003400{
    34013401  if (this!=&rhs) {
     3402    if (ourSolver_) {
     3403      delete solver_;
     3404      solver_=NULL;
     3405    }
    34023406    gutsOfDestructor();
    34033407    if (defaultHandler_)
     
    34123416    messages_ = rhs.messages_;
    34133417    messageHandler()->setLogLevel(rhs.messageHandler()->logLevel());
    3414 
    3415     delete solver_;
    34163418    if (rhs.solver_)
    34173419    { solver_ = rhs.solver_->clone() ; }
     
    34213423    delete continuousSolver_ ;
    34223424    if (rhs.continuousSolver_)
    3423     { solver_ = rhs.continuousSolver_->clone() ; }
     3425    { continuousSolver_ = rhs.continuousSolver_->clone() ; }
    34243426    else
    34253427    { continuousSolver_ = 0 ; }
    3426 
     3428    delete referenceSolver_;
    34273429    if (rhs.referenceSolver_)
    3428     { solver_ = rhs.referenceSolver_->clone() ; }
     3430    { referenceSolver_ = rhs.referenceSolver_->clone() ; }
    34293431    else
    34303432    { referenceSolver_ = NULL ; }
     
    34483450      bestSolution_=NULL;
    34493451    }
    3450     int numberColumns = solver_->getNumCols();
     3452    int numberColumns = rhs.getNumCols();
    34513453    currentSolution_ = CoinCopyOfArray(rhs.currentSolution_,numberColumns);
    34523454    continuousSolution_ = CoinCopyOfArray(rhs.continuousSolution_,numberColumns);
     
    36193621      memcpy(integerVariable_,rhs.integerVariable_,
    36203622             numberIntegers_*sizeof(int));
    3621       integerInfo_ = CoinCopyOfArray(rhs.integerInfo_,solver_->getNumCols());
     3623      integerInfo_ = CoinCopyOfArray(rhs.integerInfo_,rhs.getNumCols());
    36223624    } else {
    36233625      integerVariable_ = NULL;
     
    38263828  dblParam_[CbcCurrentObjectiveValue] = 1.0e100;
    38273829  dblParam_[CbcCurrentMinimizationObjectiveValue] = 1.0e100;
     3830}
     3831// Move status, nodes etc etc across
     3832void
     3833CbcModel::moveInfo(const CbcModel & rhs)
     3834{
     3835  bestObjective_ = rhs.bestObjective_;
     3836  bestPossibleObjective_=rhs.bestPossibleObjective_;
     3837  numberSolutions_=rhs.numberSolutions_;
     3838  numberHeuristicSolutions_=rhs.numberHeuristicSolutions_;
     3839  numberNodes_ = rhs.numberNodes_;
     3840  numberNodes2_ = rhs.numberNodes2_;
     3841  numberIterations_ = rhs.numberIterations_;
     3842  status_ = rhs.status_;
     3843  secondaryStatus_ = rhs.secondaryStatus_;
     3844  numberStoppedSubTrees_ = rhs.numberStoppedSubTrees_;
     3845  numberInfeasibleNodes_ = rhs.numberInfeasibleNodes_;
     3846  continuousObjective_=rhs.continuousObjective_;
     3847  originalContinuousObjective_ = rhs.originalContinuousObjective_;
     3848  continuousInfeasibilities_ = rhs.continuousInfeasibilities_;
     3849  numberFixedAtRoot_ = rhs.numberFixedAtRoot_;
     3850  numberFixedNow_ = rhs.numberFixedNow_;
     3851  stoppedOnGap_ = rhs.stoppedOnGap_;
     3852  eventHappened_ = rhs.eventHappened_;
     3853  numberLongStrong_ = rhs.numberLongStrong_;
     3854  numberStrongIterations_ = rhs.numberStrongIterations_;
     3855  strongInfo_[0]=rhs.strongInfo_[0];
     3856  strongInfo_[1]=rhs.strongInfo_[1];
     3857  strongInfo_[2]=rhs.strongInfo_[2];
     3858  numberRowsAtContinuous_ = rhs.numberRowsAtContinuous_;
     3859  maximumDepth_= rhs.maximumDepth_;
    38283860}
    38293861// Save a copy of the current solver so can be reset to
  • trunk/Cbc/src/CbcModel.hpp

    r708 r715  
    15271527   */
    15281528  void resetModel();
     1529  /// Move status, nodes etc etc across
     1530  void moveInfo(const CbcModel & rhs);
    15291531  //@}
    15301532
  • trunk/Cbc/src/CbcSolver.cpp

    r702 r715  
    148148//#undef NDEBUG
    149149//#endif
    150 //#############################################################################
    151 // To use USERCBC or USERCLP uncomment the following define and add in your fake main program in CoinSolve.cpp
    152 //#define USER_HAS_FAKE_MAIN
    153 //  Start any fake main program
    154 #ifdef USER_HAS_FAKE_MAIN
     150// define (probably dummy fake main programs for UserClp and UserCbc
    155151void fakeMain (ClpSimplex & model,OsiSolverInterface & osiSolver, CbcModel & babSolver);
    156 // Clp stuff to reduce problem
    157152void fakeMain2 (ClpSimplex & model,OsiClpSolverInterface & osiSolver,int options);
    158 #endif
    159 //  End any fake main program
    160 //#############################################################################
    161153
    162154// Allow for interrupts
     
    179171static bool noPrinting=false;
    180172static int * analyze(OsiClpSolverInterface * solverMod, int & numberChanged, double & increment,
    181                      bool changeInt)
     173                     bool changeInt,  CoinMessageHandler * generalMessageHandler)
    182174{
    183175  OsiSolverInterface * solver = solverMod->clone();
     176  char generalPrint[200];
    184177  if (0) {
    185178    // just get increment
     
    422415  delete [] changeRhs;
    423416  delete [] ignore;
    424   if (numberInteger&&!noPrinting)
    425     printf("%d integer variables",numberInteger);
     417  //if (numberInteger&&!noPrinting)
     418  //printf("%d integer variables",numberInteger);
    426419  if (changeInt) {
    427     if (!noPrinting) {
    428       if (numberChanged)
    429         printf(" and %d variables made integer\n",numberChanged);
    430       else
    431         printf("\n");
    432     }
     420    //if (!noPrinting) {
     421    //if (numberChanged)
     422    //  printf(" and %d variables made integer\n",numberChanged);
     423    //else
     424    //  printf("\n");
     425    //}
    433426    delete [] ignore;
    434427    //increment=0.0;
     
    446439    }
    447440  } else {
    448     if (!noPrinting) {
    449       if (numberChanged)
    450         printf(" and %d variables could be made integer\n",numberChanged);
    451       else
    452         printf("\n");
    453     }
     441    //if (!noPrinting) {
     442    //if (numberChanged)
     443    //  printf(" and %d variables could be made integer\n",numberChanged);
     444    //else
     445    //  printf("\n");
     446    //}
    454447    // just get increment
     448    int logLevel=generalMessageHandler->logLevel();
    455449    CbcModel model(*solver);
     450    model.passInMessageHandler(generalMessageHandler);
    456451    if (noPrinting)
    457452      model.setLogLevel(0);
    458453    model.analyzeObjective();
     454    generalMessageHandler->setLogLevel(logLevel);
    459455    double increment2=model.getCutoffIncrement();
    460456    if (increment2>increment&&increment2>0.0) {
    461       if (!noPrinting)
    462         printf("cutoff increment increased from %g to %g\n",increment,increment2);
     457      if (!noPrinting) {
     458        sprintf(generalPrint,"Cutoff increment increased from %g to %g",increment,increment2);
     459        CoinMessages generalMessages = solverMod->getModelPtr()->messages();
     460        generalMessageHandler->message(CLP_GENERAL,generalMessages)
     461          << generalPrint
     462          <<CoinMessageEol;
     463      }
    463464      increment=increment2;
    464465    }
     
    12981299  OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (solver);
    12991300  ClpSimplex * lpSolver = clpSolver->getModelPtr();
    1300   clpSolver->messageHandler()->setLogLevel(0) ;
    1301   model.messageHandler()->setLogLevel(1);
    13021301  lpSolver->setPerturbation(50);
    13031302  lpSolver->messageHandler()->setPrefix(false);
     
    13381337  int slog = whichParam(SOLVERLOGLEVEL,numberParameters,parameters);
    13391338  int log = whichParam(LOGLEVEL,numberParameters,parameters);
    1340   parameters[slog].setIntValue(0);
     1339  parameters[slog].setIntValue(1);
     1340  clpSolver->messageHandler()->setLogLevel(1) ;
     1341  model.messageHandler()->setLogLevel(1);
     1342  lpSolver->setLogLevel(1);
    13411343  parameters[log].setIntValue(1);
    13421344  parameters[whichParam(MAXFACTOR,numberParameters,parameters)].setIntValue(lpSolver->factorizationFrequency());
     
    14051407  OsiClpSolverInterface * originalSolver = dynamic_cast<OsiClpSolverInterface *> (model.solver());
    14061408  assert (originalSolver);
    1407   CoinMessageHandler * generalMessageHandler = originalSolver->messageHandler();
     1409  CoinMessageHandler * generalMessageHandler = model.messageHandler();
     1410  generalMessageHandler->setPrefix(false);
    14081411  CoinMessages generalMessages = originalSolver->getModelPtr()->messages();
    14091412  char generalPrint[10000];
     
    14271430    }
    14281431  }
     1432  CbcModel * babModel = NULL;
    14291433  {
    14301434    double time1 = CoinCpuTime(),time2;
     
    14351439    saveSignal = signal(SIGINT,signal_handler);
    14361440    // Set up all non-standard stuff
    1437     CbcModel * babModel = NULL;
    14381441    int cutPass=-1234567;
    14391442    int cutPassInTree=-1234567;
     
    31543157                  process.addCutGenerator(&generator1);
    31553158                  int translate[]={9999,0,0,-1,2,3,-2};
    3156                   process.messageHandler()->setLogLevel(babModel->logLevel());
     3159                  process.passInMessageHandler(babModel->messageHandler());
     3160                  //process.messageHandler()->setLogLevel(babModel->logLevel());
    31573161#ifdef COIN_HAS_ASL
    31583162                  if (info.numberSos&&doSOS&&usingAmpl) {
     
    36053609              int * changed = NULL;
    36063610              if (!miplib&&increment==normalIncrement)
    3607                 changed=analyze( osiclp,numberChanged,increment,false);
     3611                changed=analyze( osiclp,numberChanged,increment,false,generalMessageHandler);
    36083612              if (debugValues) {
    36093613                if (numberDebugValues==babModel->getNumCols()) {
     
    45724576              if (!noPrinting) {
    45734577                // Print more statistics
    4574                 std::cout<<"Cuts at root node changed objective from "<<babModel->getContinuousObjective()
    4575                          <<" to "<<babModel->rootObjectiveAfterCuts()<<std::endl;
     4578                sprintf(generalPrint,"Cuts at root node changed objective from %g to %g",
     4579                        babModel->getContinuousObjective(),babModel->rootObjectiveAfterCuts());
     4580                generalMessageHandler->message(CLP_GENERAL,generalMessages)
     4581                  << generalPrint
     4582                  <<CoinMessageEol;
    45764583               
    45774584                numberGenerators = babModel->numberCutGenerators();
     4585                char timing[30];
    45784586                for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
    45794587                  CbcCutGenerator * generator = babModel->cutGenerator(iGenerator);
    4580                   std::cout<<generator->cutGeneratorName()<<" was tried "
    4581                            <<generator->numberTimesEntered()<<" times and created "
    4582                            <<generator->numberCutsInTotal()<<" cuts of which "
    4583                            <<generator->numberCutsActive()<<" were active after adding rounds of cuts";
    4584                   if (generator->timing())
    4585                     std::cout<<" ( "<<generator->timeInCutGenerator()<<" seconds)"<<std::endl;
    4586                   else
    4587                     std::cout<<std::endl;
     4588                  sprintf(generalPrint,"%s was tried %d times and created %d cuts of which %d were active after adding rounds of cuts",
     4589                          generator->cutGeneratorName(),
     4590                          generator->numberTimesEntered(),
     4591                          generator->numberCutsInTotal(),
     4592                          generator->numberCutsActive());
     4593                  if (generator->timing()) {
     4594                    sprintf(timing," (%.3f seconds)",generator->timeInCutGenerator());
     4595                    strcat(generalPrint,timing);
     4596                  }
     4597                  generalMessageHandler->message(CLP_GENERAL,generalMessages)
     4598                    << generalPrint
     4599                    <<CoinMessageEol;
    45884600                }
    45894601              }
     
    45954607              if (babModel->getMinimizationObjValue()<1.0e50&&type==BAB) {
    45964608                // post process
     4609                int n;
    45974610                if (preProcess) {
    4598                   int n = saveSolver->getNumCols();
     4611                  n = saveSolver->getNumCols();
    45994612                  bestSolution = new double [n];
    46004613                  OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (babModel->solver());
     
    46064619                  memcpy(bestSolution,babModel->solver()->getColSolution(),n*sizeof(double));
    46074620                } else {
    4608                   int n = babModel->solver()->getNumCols();
     4621                  n = babModel->solver()->getNumCols();
    46094622                  bestSolution = new double [n];
    46104623                  memcpy(bestSolution,babModel->solver()->getColSolution(),n*sizeof(double));
    46114624                }
     4625                model.setBestSolution(bestSolution,n,babModel->getObjValue());
    46124626                // and put back in very original solver
    46134627                {
     
    46624676                int iStat = babModel->status();
    46634677                int iStat2 = babModel->secondaryStatus();
    4664                 if (!noPrinting)
    4665                   std::cout<<"Result - "<<statusName[iStat]<<minor[iStat2]
    4666                            <<" objective "<<babModel->getObjValue()<<
    4667                     " after "<<babModel->getNodeCount()<<" nodes and "
    4668                            <<babModel->getIterationCount()<<
    4669                     " iterations - took "<<time2-time1<<" seconds"<<std::endl;
     4678                if (!noPrinting) {
     4679                  sprintf(generalPrint,"Result - %s%s objective %.16g after %d nodes and %d iterations - took %.2f seconds",
     4680                          statusName[iStat].c_str(),minor[iStat2].c_str(),
     4681                          babModel->getObjValue(),babModel->getNodeCount(),
     4682                          babModel->getIterationCount(),time2-time1);
     4683                  generalMessageHandler->message(CLP_GENERAL,generalMessages)
     4684                    << generalPrint
     4685                    <<CoinMessageEol;
     4686                }
    46704687#ifdef COIN_HAS_ASL
    46714688                if (usingAmpl) {
     
    47554772              }
    47564773#endif
    4757               delete babModel;
    4758               babModel=NULL;
     4774              //delete babModel;
     4775              //babModel=NULL;
    47594776            } else {
    47604777              std::cout << "** Current model not valid" << std::endl ;
     
    47934810              }
    47944811#endif               
    4795               delete babModel;
    4796               babModel=NULL;
     4812              //delete babModel;
     4813              //babModel=NULL;
    47974814              // get next field
    47984815              field = CoinReadGetString(argc,argv);
     
    58355852            break;
    58365853          case USERCLP:
     5854#ifdef USER_HAS_FAKE_CLP
    58375855            // Replace the sample code by whatever you want
    58385856            if (goodModel) {
    5839 #ifndef USER_HAS_FAKE_MAIN
    5840               printf("Dummy user clp code - model has %d rows and %d columns\n",
    5841                      lpSolver->numberRows(),lpSolver->numberColumns());
    5842 #else
    58435857              // Way of using an existing piece of code
    58445858              OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (model.solver());
     
    58565870              //int iStat2 = lpSolver->secondaryStatus();
    58575871#endif
     5872            }
    58585873#endif
    5859             }
    58605874            break;
    58615875          case USERCBC:
     5876#ifdef USER_HAS_FAKE_CBC
    58625877            // Replace the sample code by whatever you want
    58635878            if (goodModel) {
    5864 #ifndef USER_HAS_FAKE_MAIN
    5865               printf("Dummy user cbc code - model has %d rows and %d columns\n",
    5866                      model.getNumRows(),model.getNumCols());
    5867               // Reduce printout
    5868               model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
    5869               // Do complete search
    5870               model.branchAndBound();
    5871 #ifdef COIN_HAS_ASL
    5872               double objectiveValue=model.getMinimizationObjValue();
    5873               int iStat = model.status();
    5874               int iStat2 = model.secondaryStatus();
    5875 #endif
    5876 #else
    58775879              // Way of using an existing piece of code
    58785880              OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (model.solver());
     
    58875889              int iStat = lpSolver->status();
    58885890              int iStat2 = lpSolver->secondaryStatus();
    5889 #endif
    58905891#endif
    58915892              // make sure solution back in correct place
     
    59485949#endif
    59495950            }
     5951#endif
    59505952            break;
    59515953          case HELP:
     
    63116313  dmalloc_shutdown();
    63126314#endif
     6315  if (babModel)
     6316    model.moveInfo(*babModel);
     6317  delete babModel;
    63136318  return 0;
    63146319}   
  • trunk/Cbc/src/CoinSolve.cpp

    r696 r715  
    1313#include <cstring>
    1414#include <iostream>
    15 //#############################################################################
    16 // To use USERCBC or USERCLP uncomment the following define and add in your fake main program here
    17 //#define USER_HAS_FAKE_MAIN
    18 //  Start any fake main program
    19 #ifdef USER_HAS_FAKE_MAIN
    20 #endif
     15// This driver shows how to trap messages - this is just as in unitTest.cpp
     16// ****** THis code is similar to MyMessageHandler.hpp and MyMessagehandler.cpp
     17#include "CoinMessageHandler.hpp"
     18
     19/** This just adds a model to CoinMessage and a void pointer so
     20    user can trap messages and do useful stuff. 
     21    This is used in Clp/Test/unitTest.cpp
     22
     23    The file pointer is just there as an example of user stuff.
     24
     25*/
     26class CbcModel;
     27
     28class MyMessageHandler : public CoinMessageHandler {
     29 
     30public:
     31  /**@name Overrides */
     32  //@{
     33  virtual int print();
     34  //@}
     35  /**@name set and get */
     36  //@{
     37  /// Model
     38  const CbcModel * model() const;
     39  void setModel(CbcModel * model);
     40  //@}
     41
     42  /**@name Constructors, destructor */
     43  //@{
     44  /** Default constructor. */
     45  MyMessageHandler();
     46  /// Constructor with pointer to model
     47  MyMessageHandler(CbcModel * model,
     48                           FILE * userPointer=NULL);
     49  /** Destructor */
     50  virtual ~MyMessageHandler();
     51  //@}
     52
     53  /**@name Copy method */
     54  //@{
     55  /** The copy constructor. */
     56  MyMessageHandler(const MyMessageHandler&);
     57  /** The copy constructor from an CoinSimplexMessageHandler. */
     58  MyMessageHandler(const CoinMessageHandler&);
     59 
     60  MyMessageHandler& operator=(const MyMessageHandler&);
     61  /// Clone
     62  virtual CoinMessageHandler * clone() const ;
     63  //@}
     64   
     65   
     66protected:
     67  /**@name Data members
     68     The data members are protected to allow access for derived classes. */
     69  //@{
     70  /// Pointer back to model
     71  CbcModel * model_;
     72  //@}
     73};
     74
     75
     76//#############################################################################
     77// Constructors / Destructor / Assignment
     78//#############################################################################
     79
     80//-------------------------------------------------------------------
     81// Default Constructor
     82//-------------------------------------------------------------------
     83MyMessageHandler::MyMessageHandler ()
     84  : CoinMessageHandler(),
     85    model_(NULL)
     86{
     87}
     88
     89//-------------------------------------------------------------------
     90// Copy constructor
     91//-------------------------------------------------------------------
     92MyMessageHandler::MyMessageHandler (const MyMessageHandler & rhs)
     93: CoinMessageHandler(rhs),
     94    model_(rhs.model_)
     95
     96}
     97
     98MyMessageHandler::MyMessageHandler (const CoinMessageHandler & rhs)
     99  : CoinMessageHandler(),
     100    model_(NULL)
     101
     102}
     103
     104// Constructor with pointer to model
     105MyMessageHandler::MyMessageHandler(CbcModel * model,
     106               FILE * userPointer)
     107  : CoinMessageHandler(),
     108    model_(model)
     109{
     110}
     111
     112//-------------------------------------------------------------------
     113// Destructor
     114//-------------------------------------------------------------------
     115MyMessageHandler::~MyMessageHandler ()
     116{
     117}
     118
     119//----------------------------------------------------------------
     120// Assignment operator
     121//-------------------------------------------------------------------
     122MyMessageHandler &
     123MyMessageHandler::operator=(const MyMessageHandler& rhs)
     124{
     125  if (this != &rhs) {
     126    CoinMessageHandler::operator=(rhs);
     127    model_ = rhs.model_;
     128  }
     129  return *this;
     130}
     131//-------------------------------------------------------------------
     132// Clone
     133//-------------------------------------------------------------------
     134CoinMessageHandler * MyMessageHandler::clone() const
     135{
     136  return new MyMessageHandler(*this);
     137}
     138int
     139MyMessageHandler::print()
     140{
     141  // Just add ==
     142  fprintf(fp_," == ");
     143  fprintf(fp_,"%s\n",messageBuffer_);
     144  return 0;
     145}
     146const CbcModel *
     147MyMessageHandler::model() const
     148{
     149  return model_;
     150}
     151void
     152MyMessageHandler::setModel(CbcModel * model)
     153{
     154  model_ = model;
     155}
     156//#############################################################################
     157// To use USERCBC or USERCLP change 0 to 1 in defines and add in your fake main program(s) and any other code
     158//#define USER_HAS_FAKE_CBC
     159//#define USER_HAS_FAKE_CLP
     160#ifdef USER_HAS_FAKE_CBC
     161#endif
     162void fakeMain (ClpSimplex & model,OsiSolverInterface & osiSolver, CbcModel & babSolver)
     163{
     164#ifdef USER_HAS_FAKE_CBC
     165#else
     166  printf("Dummy user cbc code - model has %d rows and %d columns\n",
     167         model.getNumRows(),model.getNumCols());
     168  // Reduce printout
     169  babSolver.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
     170  // Do complete search
     171  babSolver.branchAndBound();
     172#endif
     173}
     174// Clp stuff
     175#ifdef USER_HAS_FAKE_CLP
     176#endif
     177void fakeMain2 (ClpSimplex & model,OsiClpSolverInterface & osiSolver,int options) {
     178#ifdef USER_HAS_FAKE_CLP
     179#else
     180  ClpSimplex * lpSolver = osiSolver.getModelPtr();
     181  printf("Dummy user clp code - model has %d rows and %d columns\n",
     182         lpSolver->numberRows(),lpSolver->numberColumns());
     183  osiSolver.initialSolve();
     184#endif
     185}
    21186//  End any fake main program
    22187//#############################################################################
     
    26191  OsiClpSolverInterface solver1;
    27192  CbcModel model(solver1);
    28   int returnCode = CbcMain (argc, argv,model);
     193  // define TEST_MESSAGE_HANDLER to check works on all messages
     194  //#define TEST_MESSAGE_HANDLER
     195#ifdef TEST_MESSAGE_HANDLER
     196  MyMessageHandler messageHandler(&model);
     197  std::cout<<"Testing derived message handler"<<std::endl;
     198  model.passInMessageHandler(&messageHandler);
     199  OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (model.solver());
     200  // Could use different handlers (if different log levels)
     201  clpSolver->passInMessageHandler(&messageHandler);
     202  clpSolver->getModelPtr()->passInMessageHandler(&messageHandler);
     203#endif
     204  // initialize
     205  CbcMain0(model);
     206#ifdef TEST_MESSAGE_HANDLER
     207  // Set log levels same so can use one message handler
     208  clpSolver->messageHandler()->setLogLevel(1) ;
     209  model.messageHandler()->setLogLevel(1);
     210#endif
     211  int returnCode = CbcMain1 (argc, argv,model);
    29212  if (returnCode!=777) {
    30213    return returnCode;
Note: See TracChangeset for help on using the changeset viewer.