Cbc
2.10.13
Toggle main menu visibility
Loading...
Searching...
No Matches
Cbc
src
CbcCompareBase.hpp
Go to the documentation of this file.
1
/* $Id$ */
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
#ifndef CbcCompareBase_H
7
#define CbcCompareBase_H
8
9
//#############################################################################
10
/* These are alternative strategies for node traversal.
11
They can take data etc for fine tuning
12
13
At present the node list is stored as a heap and the "test"
14
comparison function returns true if node y is better than node x.
15
16
This is rather inflexible so if the comparison functions wants
17
it can signal to use alternative criterion on a complete pass
18
throgh tree.
19
20
*/
21
#include "
CbcNode.hpp
"
22
#include "
CbcConfig.h
"
23
24
class
CbcModel
;
25
class
CbcTree
;
26
class
CbcCompareBase
{
27
public
:
28
// Default Constructor
29
CbcCompareBase
()
30
{
31
test_
= NULL;
32
threaded_
=
false
;
33
}
34
45
virtual
bool
newSolution
(
CbcModel
*) {
return
(
false
); }
46
57
virtual
bool
newSolution
(
CbcModel
*,
58
double
,
59
int
) {
return
(
false
); }
60
61
// This allows any method to change behavior as it is called
62
// after every 1000 nodes.
63
// Return true if want tree re-sorted
64
virtual
bool
every1000Nodes
(
CbcModel
*,
int
)
65
{
66
return
false
;
67
}
68
72
virtual
bool
fullScan
()
const
73
{
74
return
false
;
75
}
76
77
virtual
~CbcCompareBase
() {}
79
virtual
void
generateCpp
(FILE *) {}
80
81
// Copy constructor
82
CbcCompareBase
(
const
CbcCompareBase
&rhs)
83
{
84
test_
= rhs.
test_
;
85
threaded_
= rhs.
threaded_
;
86
}
87
88
// Assignment operator
89
CbcCompareBase
&
operator=
(
const
CbcCompareBase
&rhs)
90
{
91
if
(
this
!= &rhs) {
92
test_
= rhs.
test_
;
93
threaded_
= rhs.
threaded_
;
94
}
95
return
*
this
;
96
}
97
99
virtual
CbcCompareBase
*
clone
()
const
100
{
101
abort();
102
return
NULL;
103
}
104
106
virtual
bool
test
(CbcNode *, CbcNode *)
107
{
108
return
true
;
109
}
110
112
virtual
bool
alternateTest
(CbcNode *x, CbcNode *y)
113
{
114
return
test
(x, y);
115
}
116
117
bool
operator()
(CbcNode *x, CbcNode *y)
118
{
119
return
test
(x, y);
120
}
121
122
inline
bool
equalityTest
(CbcNode *x, CbcNode *y)
const
123
{
124
assert(x);
125
assert(y);
126
if
(!
threaded_
) {
127
CbcNodeInfo
*infoX = x->nodeInfo();
128
assert(infoX);
129
int
nodeNumberX = infoX->
nodeNumber
();
130
CbcNodeInfo
*infoY = y->nodeInfo();
131
assert(infoY);
132
int
nodeNumberY = infoY->
nodeNumber
();
133
assert(nodeNumberX != nodeNumberY);
134
return
(nodeNumberX > nodeNumberY);
135
}
else
{
136
assert(x->nodeNumber() != y->nodeNumber());
137
return
(x->nodeNumber() > y->nodeNumber());
138
}
139
}
140
141
inline
void
sayThreaded
()
142
{
143
threaded_
=
true
;
144
}
145
146
protected
:
147
CbcCompareBase
*
test_
;
148
// If not threaded we can use better way to break ties
149
bool
threaded_
;
150
};
151
152
#endif
153
154
/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
155
*/
CbcConfig.h
CbcNode.hpp
CbcCompareBase::alternateTest
virtual bool alternateTest(CbcNode *x, CbcNode *y)
This is alternate test function.
Definition
CbcCompareBase.hpp:112
CbcCompareBase::test
virtual bool test(CbcNode *, CbcNode *)
This is test function.
Definition
CbcCompareBase.hpp:106
CbcCompareBase::operator=
CbcCompareBase & operator=(const CbcCompareBase &rhs)
Definition
CbcCompareBase.hpp:89
CbcCompareBase::clone
virtual CbcCompareBase * clone() const
Clone.
Definition
CbcCompareBase.hpp:99
CbcCompareBase::operator()
bool operator()(CbcNode *x, CbcNode *y)
Definition
CbcCompareBase.hpp:117
CbcCompareBase::threaded_
bool threaded_
Definition
CbcCompareBase.hpp:149
CbcCompareBase::~CbcCompareBase
virtual ~CbcCompareBase()
Definition
CbcCompareBase.hpp:77
CbcCompareBase::equalityTest
bool equalityTest(CbcNode *x, CbcNode *y) const
Further test if everything else equal.
Definition
CbcCompareBase.hpp:122
CbcCompareBase::test_
CbcCompareBase * test_
Definition
CbcCompareBase.hpp:147
CbcCompareBase::generateCpp
virtual void generateCpp(FILE *)
Create C++ lines to get to current state.
Definition
CbcCompareBase.hpp:79
CbcCompareBase::fullScan
virtual bool fullScan() const
Returns true if wants code to do scan with alternate criterion NOTE - this is temporarily disabled.
Definition
CbcCompareBase.hpp:72
CbcCompareBase::newSolution
virtual bool newSolution(CbcModel *)
Reconsider behaviour after discovering a new solution.
Definition
CbcCompareBase.hpp:45
CbcCompareBase::CbcCompareBase
CbcCompareBase(const CbcCompareBase &rhs)
Definition
CbcCompareBase.hpp:82
CbcCompareBase::every1000Nodes
virtual bool every1000Nodes(CbcModel *, int)
Definition
CbcCompareBase.hpp:64
CbcCompareBase::sayThreaded
void sayThreaded()
Say threaded.
Definition
CbcCompareBase.hpp:141
CbcCompareBase::CbcCompareBase
CbcCompareBase()
Definition
CbcCompareBase.hpp:29
CbcCompareBase::newSolution
virtual bool newSolution(CbcModel *, double, int)
Reconsider behaviour after discovering a new solution.
Definition
CbcCompareBase.hpp:57
CbcModel
Simple Branch and bound class.
Definition
CbcModel.hpp:100
CbcNodeInfo
Information required to recreate the subproblem at this node.
Definition
CbcNodeInfo.hpp:68
CbcNodeInfo::nodeNumber
*The node number int nodeNumber() const
Definition
CbcNodeInfo.hpp:265
CbcTree
Using MS heap implementation.
Definition
CbcTree.hpp:52
Generated by
1.17.0