source: trunk/Cbc/src/CbcCompareEstimate.cpp

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

script to format sources

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1// $Id: CbcCompareEstimate.cpp 2465 2019-01-03 19:26:52Z stefan $
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/25/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 "CbcCompareEstimate.hpp"
24/** Default Constructor
25
26*/
27CbcCompareEstimate::CbcCompareEstimate()
28  : CbcCompareBase()
29{
30  test_ = this;
31}
32
33// Copy constructor
34CbcCompareEstimate::CbcCompareEstimate(const CbcCompareEstimate &rhs)
35  : CbcCompareBase(rhs)
36
37{
38}
39
40// Clone
41CbcCompareBase *
42CbcCompareEstimate::clone() const
43{
44  return new CbcCompareEstimate(*this);
45}
46
47// Assignment operator
48CbcCompareEstimate &
49CbcCompareEstimate::operator=(const CbcCompareEstimate &rhs)
50{
51  if (this != &rhs) {
52    CbcCompareBase::operator=(rhs);
53  }
54  return *this;
55}
56
57// Destructor
58CbcCompareEstimate::~CbcCompareEstimate()
59{
60}
61
62// Returns true if y better than x
63bool CbcCompareEstimate::test(CbcNode *x, CbcNode *y)
64{
65  double testX = x->guessedObjectiveValue();
66  double testY = y->guessedObjectiveValue();
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
73// Create C++ lines to get to current state
74void CbcCompareEstimate::generateCpp(FILE *fp)
75{
76  fprintf(fp, "0#include \"CbcCompareActual.hpp\"\n");
77  fprintf(fp, "3  CbcCompareEstimate compare;\n");
78  fprintf(fp, "3  cbcModel->setNodeComparison(compare);\n");
79}
80
81/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
82*/
Note: See TracBrowser for help on using the repository browser.