source: trunk/Cbc/src/CbcCompareDepth.cpp @ 2464

Last change on this file since 2464 was 2464, checked in by unxusr, 9 months ago

.clang-format with proposal for formatting code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1// $Id: CbcCompareDepth.cpp 2464 2019-01-03 19:03:23Z unxusr $
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*/
27CbcCompareDepth::CbcCompareDepth()
28  : CbcCompareBase()
29{
30  test_ = this;
31}
32
33// Copy constructor
34CbcCompareDepth::CbcCompareDepth(const CbcCompareDepth &rhs)
35  : CbcCompareBase(rhs)
36
37{
38}
39
40// Clone
41CbcCompareBase *
42CbcCompareDepth::clone() const
43{
44  return new CbcCompareDepth(*this);
45}
46
47// Assignment operator
48CbcCompareDepth &
49CbcCompareDepth::operator=(const CbcCompareDepth &rhs)
50{
51  if (this != &rhs) {
52    CbcCompareBase::operator=(rhs);
53  }
54  return *this;
55}
56
57// Destructor
58CbcCompareDepth::~CbcCompareDepth()
59{
60}
61
62// Returns true if y better than x
63bool CbcCompareDepth::test(CbcNode *x, CbcNode *y)
64{
65  int testX = x->depth();
66  int testY = y->depth();
67  if (testX != testY)
68    return testX < testY;
69  else
70    return equalityTest(x, y); // so ties will be broken in consistent manner
71}
72// Create C++ lines to get to current state
73void CbcCompareDepth::generateCpp(FILE *fp)
74{
75  fprintf(fp, "0#include \"CbcCompareActual.hpp\"\n");
76  fprintf(fp, "3  CbcCompareDepth compare;\n");
77  fprintf(fp, "3  cbcModel->setNodeComparison(compare);\n");
78}
Note: See TracBrowser for help on using the repository browser.