1 | // $Id: CbcCompareDepth.cpp 1899 2013-04-09 18:12:08Z forrest $ |
---|
2 | // Copyright (C) 2002, International Business Machines |
---|
3 | // Corporation and others. All Rights Reserved. |
---|
4 | // This code is licensed under the terms of the Eclipse Public License (EPL). |
---|
5 | |
---|
6 | //Edwin 11/24/09 carved out of CbcCompareActual |
---|
7 | |
---|
8 | #if defined(_MSC_VER) |
---|
9 | // Turn off compiler warning about long names |
---|
10 | # pragma warning(disable:4786) |
---|
11 | #endif |
---|
12 | #include <cassert> |
---|
13 | #include <cstdlib> |
---|
14 | #include <cmath> |
---|
15 | #include <cfloat> |
---|
16 | //#define CBC_DEBUG |
---|
17 | |
---|
18 | #include "CbcMessage.hpp" |
---|
19 | #include "CbcModel.hpp" |
---|
20 | #include "CbcTree.hpp" |
---|
21 | #include "CbcCompareActual.hpp" |
---|
22 | #include "CoinError.hpp" |
---|
23 | #include "CbcCompareDepth.hpp" |
---|
24 | /** Default Constructor |
---|
25 | |
---|
26 | */ |
---|
27 | CbcCompareDepth::CbcCompareDepth () |
---|
28 | : CbcCompareBase() |
---|
29 | { |
---|
30 | test_ = this; |
---|
31 | } |
---|
32 | |
---|
33 | // Copy constructor |
---|
34 | CbcCompareDepth::CbcCompareDepth ( const CbcCompareDepth & rhs) |
---|
35 | : CbcCompareBase(rhs) |
---|
36 | |
---|
37 | { |
---|
38 | } |
---|
39 | |
---|
40 | // Clone |
---|
41 | CbcCompareBase * |
---|
42 | CbcCompareDepth::clone() const |
---|
43 | { |
---|
44 | return new CbcCompareDepth(*this); |
---|
45 | } |
---|
46 | |
---|
47 | // Assignment operator |
---|
48 | CbcCompareDepth & |
---|
49 | CbcCompareDepth::operator=( const CbcCompareDepth & rhs) |
---|
50 | { |
---|
51 | if (this != &rhs) { |
---|
52 | CbcCompareBase::operator=(rhs); |
---|
53 | } |
---|
54 | return *this; |
---|
55 | } |
---|
56 | |
---|
57 | // Destructor |
---|
58 | CbcCompareDepth::~CbcCompareDepth () |
---|
59 | { |
---|
60 | } |
---|
61 | |
---|
62 | // Returns true if y better than x |
---|
63 | bool |
---|
64 | CbcCompareDepth::test (CbcNode * x, CbcNode * y) |
---|
65 | { |
---|
66 | int testX = x->depth(); |
---|
67 | int testY = y->depth(); |
---|
68 | if (testX != testY) |
---|
69 | return testX < testY; |
---|
70 | else |
---|
71 | return equalityTest(x, y); // so ties will be broken in consistent manner |
---|
72 | } |
---|
73 | // Create C++ lines to get to current state |
---|
74 | void |
---|
75 | CbcCompareDepth::generateCpp( FILE * fp) |
---|
76 | { |
---|
77 | fprintf(fp, "0#include \"CbcCompareActual.hpp\"\n"); |
---|
78 | fprintf(fp, "3 CbcCompareDepth compare;\n"); |
---|
79 | fprintf(fp, "3 cbcModel->setNodeComparison(compare);\n"); |
---|
80 | } |
---|
81 | |
---|