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

Last change on this file since 1293 was 1293, checked in by EdwinStraver, 10 years ago
File size: 3.6 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 "CbcIntegerPseudoCostBranchingObject.hpp"
18#include "CbcBranchActual.hpp"
19#include "CoinSort.hpp"
20#include "CoinError.hpp"
21
22//##############################################################################
23
24// Default Constructor
25CbcIntegerPseudoCostBranchingObject::CbcIntegerPseudoCostBranchingObject()
26        : CbcIntegerBranchingObject()
27{
28    changeInGuessed_ = 1.0e-5;
29}
30
31// Useful constructor
32CbcIntegerPseudoCostBranchingObject::CbcIntegerPseudoCostBranchingObject (CbcModel * model,
33        int variable, int way , double value)
34        : CbcIntegerBranchingObject(model, variable, way, value)
35{
36}
37// Useful constructor for fixing
38CbcIntegerPseudoCostBranchingObject::CbcIntegerPseudoCostBranchingObject (CbcModel * model,
39        int variable, int way,
40        double lowerValue,
41        double /*upperValue*/)
42        : CbcIntegerBranchingObject(model, variable, way, lowerValue)
43{
44    changeInGuessed_ = 1.0e100;
45}
46
47
48// Copy constructor
49CbcIntegerPseudoCostBranchingObject::CbcIntegerPseudoCostBranchingObject (
50    const CbcIntegerPseudoCostBranchingObject & rhs)
51        : CbcIntegerBranchingObject(rhs)
52{
53    changeInGuessed_ = rhs.changeInGuessed_;
54}
55
56// Assignment operator
57CbcIntegerPseudoCostBranchingObject &
58CbcIntegerPseudoCostBranchingObject::operator=( const CbcIntegerPseudoCostBranchingObject & rhs)
59{
60    if (this != &rhs) {
61        CbcIntegerBranchingObject::operator=(rhs);
62        changeInGuessed_ = rhs.changeInGuessed_;
63    }
64    return *this;
65}
66CbcBranchingObject *
67CbcIntegerPseudoCostBranchingObject::clone() const
68{
69    return (new CbcIntegerPseudoCostBranchingObject(*this));
70}
71
72
73// Destructor
74CbcIntegerPseudoCostBranchingObject::~CbcIntegerPseudoCostBranchingObject ()
75{
76}
77
78/*
79  Perform a branch by adjusting the bounds of the specified variable. Note
80  that each arm of the branch advances the object to the next arm by
81  advancing the value of way_.
82
83  Providing new values for the variable's lower and upper bounds for each
84  branching direction gives a little bit of additional flexibility and will
85  be easily extensible to multi-way branching.
86  Returns change in guessed objective on next branch
87*/
88double
89CbcIntegerPseudoCostBranchingObject::branch()
90{
91    CbcIntegerBranchingObject::branch();
92    return changeInGuessed_;
93}
94
95/** Compare the \c this with \c brObj. \c this and \c brObj must be os the
96    same type and must have the same original object, but they may have
97    different feasible regions.
98    Return the appropriate CbcRangeCompare value (first argument being the
99    sub/superset if that's the case). In case of overlap (and if \c
100    replaceIfOverlap is true) replace the current branching object with one
101    whose feasible region is the overlap.
102*/
103CbcRangeCompare
104CbcIntegerPseudoCostBranchingObject::compareBranchingObject
105(const CbcBranchingObject* brObj, const bool replaceIfOverlap)
106{
107    const CbcIntegerPseudoCostBranchingObject* br =
108        dynamic_cast<const CbcIntegerPseudoCostBranchingObject*>(brObj);
109    assert(br);
110    double* thisBd = way_ < 0 ? down_ : up_;
111    const double* otherBd = br->way_ < 0 ? br->down_ : br->up_;
112    return CbcCompareRanges(thisBd, otherBd, replaceIfOverlap);
113}
Note: See TracBrowser for help on using the repository browser.