source: trunk/Cbc/src/CbcCompareObjective.cpp @ 1557

Last change on this file since 1557 was 1357, checked in by coin, 10 years ago

run 'astyle -A4 -p' and dos2unix

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 "CbcCompareObjective.hpp"
18/** Default Constructor
19
20*/
21CbcCompareObjective::CbcCompareObjective ()
22        : CbcCompareBase()
23{
24    test_ = this;
25}
26
27// Copy constructor
28CbcCompareObjective::CbcCompareObjective ( const CbcCompareObjective & rhs)
29        : CbcCompareBase(rhs)
30
31{
32}
33
34// Clone
35CbcCompareBase *
36CbcCompareObjective::clone() const
37{
38    return new CbcCompareObjective(*this);
39}
40
41// Assignment operator
42CbcCompareObjective &
43CbcCompareObjective::operator=( const CbcCompareObjective & rhs)
44{
45    if (this != &rhs) {
46        CbcCompareBase::operator=(rhs);
47    }
48    return *this;
49}
50
51// Destructor
52CbcCompareObjective::~CbcCompareObjective ()
53{
54}
55
56// Returns true if y better than x
57bool
58CbcCompareObjective::test (CbcNode * x, CbcNode * y)
59{
60    double testX = x->objectiveValue();
61    double testY = y->objectiveValue();
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// Create C++ lines to get to current state
68void
69CbcCompareObjective::generateCpp( FILE * fp)
70{
71    fprintf(fp, "0#include \"CbcCompareActual.hpp\"\n");
72    fprintf(fp, "3  CbcCompareObjective compare;\n");
73    fprintf(fp, "3  cbcModel->setNodeComparison(compare);\n");
74}
Note: See TracBrowser for help on using the repository browser.