source: branches/sandbox/Cbc/src/CbcOneGeneralBranchingObject.cpp @ 1293

Last change on this file since 1293 was 1293, checked in by EdwinStraver, 10 years ago
File size: 3.9 KB
Line 
1// Edwin 11/10/2009-- carved out of CbcBranchActual
2#if defined(_MSC_VER)
3// Turn off compiler warning about long names
4#  pragma warning(disable:4786)
5#endif
6#include <cassert>
7#include <cstdlib>
8#include <cmath>
9#include <cfloat>
10//#define CBC_DEBUG
11
12#include "CoinTypes.hpp"
13#include "OsiSolverInterface.hpp"
14#include "OsiSolverBranch.hpp"
15#include "CbcModel.hpp"
16#include "CbcMessage.hpp"
17#include "CbcOneGeneralBranchingObject.hpp"
18#include "CbcBranchActual.hpp"
19#include "CoinSort.hpp"
20#include "CoinError.hpp"
21
22#ifdef COIN_HAS_CLP
23// Default Constructor
24CbcOneGeneralBranchingObject::CbcOneGeneralBranchingObject()
25        : CbcBranchingObject(),
26        object_(NULL),
27        whichOne_(-1)
28{
29    //printf("CbcOneGeneral %x default constructor\n",this);
30}
31
32// Useful constructor
33CbcOneGeneralBranchingObject::CbcOneGeneralBranchingObject (CbcModel * model,
34        CbcGeneralBranchingObject * object,
35        int whichOne)
36        : CbcBranchingObject(model, -1, -1, 0.5),
37        object_(object),
38        whichOne_(whichOne)
39{
40    //printf("CbcOneGeneral %x useful constructor object %x %d left\n",this,
41    //   object_,object_->numberSubLeft_);
42    numberBranches_ = 1;
43}
44
45// Copy constructor
46CbcOneGeneralBranchingObject::CbcOneGeneralBranchingObject ( const CbcOneGeneralBranchingObject & rhs)
47        : CbcBranchingObject(rhs),
48        object_(rhs.object_),
49        whichOne_(rhs.whichOne_)
50{
51}
52
53// Assignment operator
54CbcOneGeneralBranchingObject &
55CbcOneGeneralBranchingObject::operator=( const CbcOneGeneralBranchingObject & rhs)
56{
57    if (this != &rhs) {
58        CbcBranchingObject::operator=(rhs);
59        object_ = rhs.object_;
60        whichOne_ = rhs.whichOne_;
61    }
62    return *this;
63}
64CbcBranchingObject *
65CbcOneGeneralBranchingObject::clone() const
66{
67    return (new CbcOneGeneralBranchingObject(*this));
68}
69
70
71// Destructor
72CbcOneGeneralBranchingObject::~CbcOneGeneralBranchingObject ()
73{
74    //printf("CbcOneGeneral %x destructor object %x %d left\n",this,
75    // object_,object_->numberSubLeft_);
76    assert (object_->numberSubLeft_ > 0 &&
77            object_->numberSubLeft_ < 1000000);
78    if (!object_->decrementNumberLeft()) {
79        // printf("CbcGeneral %x yy destructor\n",object_);
80        delete object_;
81    }
82}
83double
84CbcOneGeneralBranchingObject::branch()
85{
86    assert (numberBranchesLeft());
87    decrementNumberBranchesLeft();
88    assert (!numberBranchesLeft());
89    object_->setWhichNode(whichOne_);
90    object_->branch();
91    return 0.0;
92}
93/* Double checks in case node can change its mind!
94   Can change objective etc */
95void
96CbcOneGeneralBranchingObject::checkIsCutoff(double /*cutoff*/)
97{
98    assert (numberBranchesLeft());
99}
100// Print what would happen
101void
102CbcOneGeneralBranchingObject::print()
103{
104    //printf("CbcOneGeneralObject has 1 subproblem\n");
105}
106/** Compare the original object of \c this with the original object of \c
107    brObj. Assumes that there is an ordering of the original objects.
108    This method should be invoked only if \c this and brObj are of the same
109    type.
110    Return negative/0/positive depending on whether \c this is
111    smaller/same/larger than the argument.
112*/
113int
114CbcOneGeneralBranchingObject::compareOriginalObject
115(const CbcBranchingObject* /*brObj*/) const
116{
117    throw("must implement");
118}
119
120/** Compare the \c this with \c brObj. \c this and \c brObj must be os the
121    same type and must have the same original object, but they may have
122    different feasible regions.
123    Return the appropriate CbcRangeCompare value (first argument being the
124    sub/superset if that's the case). In case of overlap (and if \c
125    replaceIfOverlap is true) replace the current branching object with one
126    whose feasible region is the overlap.
127*/
128CbcRangeCompare
129CbcOneGeneralBranchingObject::compareBranchingObject
130(const CbcBranchingObject* /*brObj*/, const bool /*replaceIfOverlap*/)
131{
132    throw("must implement");
133}
134
135#endif
Note: See TracBrowser for help on using the repository browser.