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

Last change on this file since 1899 was 1899, checked in by stefan, 5 years ago

fixup svn properties

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