source: trunk/Cbc/src/CbcCompareEstimate.cpp @ 1566

Last change on this file since 1566 was 1432, checked in by bjarni, 10 years ago

Added extra return at end of each source file where needed, to remove possible linefeed conflicts (NightlyBuild? errors)

File size: 1.6 KB
Line 
1//Edwin 11/25/09 carved out of CbcCompareActual
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 "CbcMessage.hpp"
13#include "CbcModel.hpp"
14#include "CbcTree.hpp"
15#include "CbcCompareActual.hpp"
16#include "CoinError.hpp"
17#include "CbcCompareEstimate.hpp"
18/** Default Constructor
19
20*/
21CbcCompareEstimate::CbcCompareEstimate ()
22        : CbcCompareBase()
23{
24    test_ = this;
25}
26
27// Copy constructor
28CbcCompareEstimate::CbcCompareEstimate ( const CbcCompareEstimate & rhs)
29        : CbcCompareBase(rhs)
30
31{
32}
33
34// Clone
35CbcCompareBase *
36CbcCompareEstimate::clone() const
37{
38    return new CbcCompareEstimate(*this);
39}
40
41// Assignment operator
42CbcCompareEstimate &
43CbcCompareEstimate::operator=( const CbcCompareEstimate & rhs)
44{
45    if (this != &rhs) {
46        CbcCompareBase::operator=(rhs);
47    }
48    return *this;
49}
50
51// Destructor
52CbcCompareEstimate::~CbcCompareEstimate ()
53{
54}
55
56// Returns true if y better than x
57bool
58CbcCompareEstimate::test (CbcNode * x, CbcNode * y)
59{
60    double testX = x->guessedObjectiveValue();
61    double testY = y->guessedObjectiveValue();
62    if (testX != testY)
63        return testX > testY;
64    else
65        return equalityTest(x, y); // so ties will be broken in consistent manner
66}
67
68// Create C++ lines to get to current state
69void
70CbcCompareEstimate::generateCpp( FILE * fp)
71{
72    fprintf(fp, "0#include \"CbcCompareActual.hpp\"\n");
73    fprintf(fp, "3  CbcCompareEstimate compare;\n");
74    fprintf(fp, "3  cbcModel->setNodeComparison(compare);\n");
75}
76
Note: See TracBrowser for help on using the repository browser.