Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • stable/2.8/Cbc/src/CbcSubProblem.cpp

    • Property svn:eol-style set to native
    • Property svn:keywords set to Author Date Id Revision
    r1675 r1902  
    2929// Default Constructor
    3030CbcSubProblem::CbcSubProblem()
    31         : objectiveValue_(0.0),
    32         sumInfeasibilities_(0.0),
    33         variables_(NULL),
    34         newBounds_(NULL),
    35         status_(NULL),
    36         depth_(0),
    37         numberChangedBounds_(0),
    38         numberInfeasibilities_(0)
     31  : objectiveValue_(0.0),
     32    sumInfeasibilities_(0.0),
     33    branchValue_(0.0),
     34    djValue_(0.0),
     35    variables_(NULL),
     36    newBounds_(NULL),
     37    status_(NULL),
     38    depth_(0),
     39    numberChangedBounds_(0),
     40    numberInfeasibilities_(0),
     41    problemStatus_(0),
     42    branchVariable_(0)
    3943{
    4044}
     
    4650                              const unsigned char * status,
    4751                              int depth)
    48         : objectiveValue_(0.0),
    49         sumInfeasibilities_(0.0),
    50         variables_(NULL),
    51         newBounds_(NULL),
    52         status_(NULL),
    53         depth_(depth),
    54         numberChangedBounds_(0),
    55         numberInfeasibilities_(0)
     52  : objectiveValue_(0.0),
     53    sumInfeasibilities_(0.0),
     54    branchValue_(0.0),
     55    djValue_(0.0),
     56    variables_(NULL),
     57    newBounds_(NULL),
     58    status_(NULL),
     59    depth_(depth),
     60    numberChangedBounds_(0),
     61    numberInfeasibilities_(0),
     62    problemStatus_(0),
     63    branchVariable_(0)
    5664{
    5765    const double * lower = solver->getColLower();
     
    110118CbcSubProblem::CbcSubProblem ( const CbcSubProblem & rhs)
    111119        : objectiveValue_(rhs.objectiveValue_),
    112         sumInfeasibilities_(rhs.sumInfeasibilities_),
    113         variables_(NULL),
    114         newBounds_(NULL),
    115         status_(NULL),
    116         depth_(rhs.depth_),
    117         numberChangedBounds_(rhs.numberChangedBounds_),
    118         numberInfeasibilities_(rhs.numberInfeasibilities_)
     120          sumInfeasibilities_(rhs.sumInfeasibilities_),
     121          branchValue_(rhs.branchValue_),
     122          djValue_(rhs.djValue_),
     123          variables_(NULL),
     124          newBounds_(NULL),
     125          status_(NULL),
     126          depth_(rhs.depth_),
     127          numberChangedBounds_(rhs.numberChangedBounds_),
     128          numberInfeasibilities_(rhs.numberInfeasibilities_),
     129          problemStatus_(rhs.problemStatus_),
     130          branchVariable_(rhs.branchVariable_)
    119131{
    120132    if (numberChangedBounds_) {
     
    137149        objectiveValue_ = rhs.objectiveValue_;
    138150        sumInfeasibilities_ = rhs.sumInfeasibilities_;
     151        branchValue_ = rhs.branchValue_;
     152        djValue_ = rhs.djValue_;
    139153        depth_ = rhs.depth_;
    140154        numberChangedBounds_ = rhs.numberChangedBounds_;
    141155        numberInfeasibilities_ = rhs.numberInfeasibilities_;
     156        problemStatus_ = rhs.problemStatus_;
     157        branchVariable_ = rhs.branchVariable_;
    142158        if (numberChangedBounds_) {
    143159            variables_ = CoinCopyOfArray(rhs.variables_, numberChangedBounds_);
     
    155171    return *this;
    156172}
     173// Take over
     174void
     175CbcSubProblem::takeOver( CbcSubProblem & rhs, bool cleanUp)
     176{
     177    if (this != &rhs) {
     178        delete [] variables_;
     179        delete [] newBounds_;
     180        delete status_;
     181        objectiveValue_ = rhs.objectiveValue_;
     182        sumInfeasibilities_ = rhs.sumInfeasibilities_;
     183        branchValue_ = rhs.branchValue_;
     184        djValue_ = rhs.djValue_;
     185        depth_ = rhs.depth_;
     186        numberChangedBounds_ = rhs.numberChangedBounds_;
     187        numberInfeasibilities_ = rhs.numberInfeasibilities_;
     188        problemStatus_ = rhs.problemStatus_;
     189        branchVariable_ = rhs.branchVariable_;
     190        variables_ = rhs.variables_;
     191        newBounds_ = rhs.newBounds_;
     192        rhs.variables_ = NULL;
     193        rhs.newBounds_ = NULL;
     194        status_ = rhs.status_;
     195        rhs.status_ = NULL;
     196        if (cleanUp) {
     197          delete [] variables_;
     198          delete [] newBounds_;
     199          variables_ = new int [1];
     200          newBounds_ = new double [1];
     201          // swap way and make only fix
     202          numberChangedBounds_=1;
     203          if ((problemStatus_&1)==0) {
     204            // last way was down
     205            newBounds_[0] = ceil(branchValue_);
     206            variables_[0] = branchVariable_;
     207          } else {
     208            // last way was up
     209            newBounds_[0] = floor(branchValue_);
     210            variables_[0] = branchVariable_ | 0x80000000;
     211          }
     212        }
     213    }
     214}
    157215
    158216// Destructor
     
    169227    int i;
    170228    if ((what&1) != 0) {
     229    printf("CbcSubapply depth %d column %d way %d bvalue %g obj %g\n",
     230                 this->depth_,this->branchVariable_,this->problemStatus_,
     231                 this->branchValue_,this->objectiveValue_);
     232    printf("current bounds %g <= %g <= %g\n",solver->getColLower()[branchVariable_],branchValue_,solver->getColUpper()[branchVariable_]);
    171233#ifndef NDEBUG
    172234        int nSame = 0;
     
    228290#endif
    229291#endif
     292    printf("new bounds %g <= %g <= %g\n",solver->getColLower()[branchVariable_],branchValue_,solver->getColUpper()[branchVariable_]);
    230293    }
    231294#ifdef JJF_ZERO
     
    258321        assert (clpSolver);
    259322        clpSolver->setBasis(*status_);
    260         delete status_;
    261         status_ = NULL;
    262     }
    263 }
    264 
     323        if ((what&16)==0) {
     324          delete status_;
     325          status_ = NULL;
     326        }
     327    }
     328}
     329
Note: See TracChangeset for help on using the changeset viewer.