Ignore:
Timestamp:
Sep 27, 2010 12:55:11 PM (9 years ago)
Author:
lou
Message:

Fix `Invalid heap' error in cl debug builds. Add validateHeap method to CbcTree? for future debugging.

File:
1 edited

Legend:

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

    r1393 r1506  
    2929        breadthDepth_(5),
    3030        startNodeNumber_(-1),
    31         afterNodeNumber_(-1)
     31        afterNodeNumber_(-1),
     32        setupForDiving_(false)
    3233{
    3334    test_ = this;
     
    4546        breadthDepth_(5),
    4647        startNodeNumber_(-1),
    47         afterNodeNumber_(-1)
     48        afterNodeNumber_(-1),
     49        setupForDiving_(false)
    4850{
    4951    test_ = this;
     
    6567    startNodeNumber_ = rhs.startNodeNumber_;
    6668    afterNodeNumber_ = rhs.afterNodeNumber_;
     69    setupForDiving_ = rhs.setupForDiving_ ;
    6770}
    6871
     
    8992        startNodeNumber_ = rhs.startNodeNumber_;
    9093        afterNodeNumber_ = rhs.afterNodeNumber_;
     94        setupForDiving_ = rhs.setupForDiving_ ;
    9195    }
    9296    return *this;
     
    203207    }
    204208}
    205 // This allows method to change behavior as it is called
    206 // after each solution
    207 void
     209/*
     210  Change the weight attached to unsatisfied integer variables, unless it's
     211  fairly early on in the search and all solutions to date are heuristic.
     212*/
     213bool
    208214CbcCompareDefault::newSolution(CbcModel * model,
    209215                               double objectiveAtContinuous,
     
    213219    if (model->getSolutionCount() == model->getNumberHeuristicSolutions() &&
    214220            model->getSolutionCount() < 5 && model->getNodeCount() < 500)
    215         return; // solution was got by rounding
     221        return (false) ; // solution was got by rounding
    216222    // set to get close to this solution
    217223    double costPerInteger =
     
    223229    //if (numberSolutions_>5)
    224230    //weight_ =0.0; // this searches on objective
     231    return (true) ;
    225232}
    226233// This allows method to change behavior
     
    278285    startNodeNumber_ = best->nodeNumber();
    279286    // send signal to setComparison
    280     afterNodeNumber_ = -2;
     287    setupForDiving_ = true ;
     288    /*
     289      TODO (review when fixing cleanDive and setComparison)
     290      Both afterNodeNumber_ and weight_ must not change
     291      after setComparison is invoked, as that will change
     292      the behaviour of test(). I replaced the overload on
     293      afterNodeNumber_ (magic number -2) with a boolean. Weight_
     294      is more problematic. Either it's correct before calling
     295      setComparison, or it needs to be cut from the tie-breaking
     296      part of test() during a dive, or there needs to be a new
     297      attribute to save and restore it around the dive. Otherwise
     298      heap checks fail in debug builds with Visual Studio.
     299     
     300      Given that weight_ was restored immediately after the call
     301      to setComparison, there should be no change in behaviour
     302      in terms of calls to test().
     303      -- lh, 100921 --
     304    */
     305    afterNodeNumber_ = model->tree()->maximumNodeNumber();
     306    weight_ = saveWeight ;
    281307    // redo tree
    282308    model->tree()->setComparison(*this);
    283     afterNodeNumber_ = model->tree()->maximumNodeNumber();
    284     weight_ = saveWeight;
     309    setupForDiving_ = false ;
    285310}
    286311// Clean up dive
     
    288313CbcCompareDefault::cleanDive()
    289314{
    290     if (afterNodeNumber_ != -2) {
     315    if (setupForDiving_ == false) {
    291316        // switch off
    292317        startNodeNumber_ = -1;
Note: See TracChangeset for help on using the changeset viewer.