Cbc
2.10.13
Toggle main menu visibility
Loading...
Searching...
No Matches
Cbc
src
CbcCompareDefault.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
//Edwin 11/25/09 carved out of CbcCompareActual
7
8
#ifndef CbcCompareDefault_H
9
#define CbcCompareDefault_H
10
11
//#############################################################################
12
/* These are alternative strategies for node traversal.
13
They can take data etc for fine tuning
14
15
At present the node list is stored as a heap and the "test"
16
comparison function returns true if node y is better than node x.
17
18
*/
19
#include "
CbcNode.hpp
"
20
#include "
CbcCompareBase.hpp
"
21
#include "
CbcCompare.hpp
"
22
23
class
CbcModel
;
24
25
/* This is an example of a more complex rule with data
26
It is default after first solution
27
If weight is 0.0 then it is computed to hit first solution
28
less 5%
29
*/
30
class
CbcCompareDefault
:
public
CbcCompareBase
{
31
public
:
33
CbcCompareDefault
();
35
CbcCompareDefault
(
double
weight);
36
38
CbcCompareDefault
(
const
CbcCompareDefault
&rhs);
39
41
CbcCompareDefault
&
operator=
(
const
CbcCompareDefault
&rhs);
42
44
virtual
CbcCompareBase
*
clone
()
const
;
46
virtual
void
generateCpp
(FILE *fp);
47
48
~CbcCompareDefault
();
49
/* This returns true if weighted value of node y is less than
50
weighted value of node x */
51
virtual
bool
test
(CbcNode *x, CbcNode *y);
52
53
using
CbcCompareBase::newSolution
;
56
virtual
bool
newSolution
(
CbcModel
*
model
,
57
double
objectiveAtContinuous,
58
int
numberInfeasibilitiesAtContinuous);
61
virtual
bool
every1000Nodes
(
CbcModel
*
model
,
int
numberNodes);
62
63
/* if weight == -1.0 then fewest infeasibilities (before solution)
64
if -2.0 then do breadth first just for first 1000 nodes
65
if -3.0 then depth first before solution
66
*/
67
inline
double
getWeight
()
const
68
{
69
return
weight_
;
70
}
71
inline
void
setWeight
(
double
weight)
72
{
73
weight_
= weight;
74
}
75
76
inline
double
getCutoff
()
const
77
{
78
return
cutoff_
;
79
}
80
inline
void
setCutoff
(
double
cutoff)
81
{
82
cutoff_
= cutoff;
83
}
84
85
inline
double
getBestPossible
()
const
86
{
87
return
bestPossible_
;
88
}
89
inline
void
setBestPossible
(
double
bestPossible)
90
{
91
bestPossible_
= bestPossible;
92
}
93
94
inline
void
setBreadthDepth
(
int
value)
95
{
96
breadthDepth_
= value;
97
}
98
99
void
startDive
(
CbcModel
*
model
);
101
void
cleanDive
();
102
103
protected
:
105
double
weight_
;
107
double
saveWeight_
;
109
double
cutoff_
;
111
double
bestPossible_
;
113
int
numberSolutions_
;
115
int
treeSize_
;
117
int
breadthDepth_
;
119
int
startNodeNumber_
;
121
int
afterNodeNumber_
;
123
bool
setupForDiving_
;
124
};
125
126
#endif
//CbcCompareDefault_H
127
128
/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
129
*/
CbcCompareBase.hpp
CbcCompare.hpp
CbcNode.hpp
model
CbcModel * model() const
Return model.
Definition
CbcObject.hpp:252
CbcCompareBase::newSolution
virtual bool newSolution(CbcModel *)
Reconsider behaviour after discovering a new solution.
Definition
CbcCompareBase.hpp:45
CbcCompareBase::CbcCompareBase
CbcCompareBase()
Definition
CbcCompareBase.hpp:29
CbcCompareDefault::bestPossible_
double bestPossible_
Best possible solution.
Definition
CbcCompareDefault.hpp:111
CbcCompareDefault::~CbcCompareDefault
~CbcCompareDefault()
CbcCompareDefault::setWeight
void setWeight(double weight)
Definition
CbcCompareDefault.hpp:71
CbcCompareDefault::CbcCompareDefault
CbcCompareDefault(double weight)
Constructor with weight.
CbcCompareDefault::CbcCompareDefault
CbcCompareDefault()
Default Constructor.
CbcCompareDefault::numberSolutions_
int numberSolutions_
Number of solutions.
Definition
CbcCompareDefault.hpp:113
CbcCompareDefault::setCutoff
void setCutoff(double cutoff)
Definition
CbcCompareDefault.hpp:80
CbcCompareDefault::CbcCompareDefault
CbcCompareDefault(const CbcCompareDefault &rhs)
Copy constructor.
CbcCompareDefault::newSolution
virtual bool newSolution(CbcModel *model, double objectiveAtContinuous, int numberInfeasibilitiesAtContinuous)
This allows method to change behavior as it is called after each solution.
CbcCompareDefault::setBreadthDepth
void setBreadthDepth(int value)
Depth above which want to explore first.
Definition
CbcCompareDefault.hpp:94
CbcCompareDefault::cutoff_
double cutoff_
Cutoff.
Definition
CbcCompareDefault.hpp:109
CbcCompareDefault::saveWeight_
double saveWeight_
Weight for each infeasibility - computed from solution.
Definition
CbcCompareDefault.hpp:107
CbcCompareDefault::breadthDepth_
int breadthDepth_
Depth above which want to explore first.
Definition
CbcCompareDefault.hpp:117
CbcCompareDefault::operator=
CbcCompareDefault & operator=(const CbcCompareDefault &rhs)
Assignment operator.
CbcCompareDefault::weight_
double weight_
Weight for each infeasibility.
Definition
CbcCompareDefault.hpp:105
CbcCompareDefault::treeSize_
int treeSize_
Tree size (at last check).
Definition
CbcCompareDefault.hpp:115
CbcCompareDefault::afterNodeNumber_
int afterNodeNumber_
Node number when dive started.
Definition
CbcCompareDefault.hpp:121
CbcCompareDefault::every1000Nodes
virtual bool every1000Nodes(CbcModel *model, int numberNodes)
This allows method to change behavior Return true if want tree re-sorted.
CbcCompareDefault::startDive
void startDive(CbcModel *model)
Start dive.
CbcCompareDefault::getCutoff
double getCutoff() const
Cutoff.
Definition
CbcCompareDefault.hpp:76
CbcCompareDefault::setBestPossible
void setBestPossible(double bestPossible)
Definition
CbcCompareDefault.hpp:89
CbcCompareDefault::generateCpp
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
CbcCompareDefault::setupForDiving_
bool setupForDiving_
Indicates doing setup for diving.
Definition
CbcCompareDefault.hpp:123
CbcCompareDefault::clone
virtual CbcCompareBase * clone() const
Clone.
CbcCompareDefault::startNodeNumber_
int startNodeNumber_
Chosen node from estimated (-1 is off).
Definition
CbcCompareDefault.hpp:119
CbcCompareDefault::cleanDive
void cleanDive()
Clean up diving (i.e. switch off or prepare).
CbcCompareDefault::test
virtual bool test(CbcNode *x, CbcNode *y)
This is test function.
CbcCompareDefault::getWeight
double getWeight() const
Definition
CbcCompareDefault.hpp:67
CbcCompareDefault::getBestPossible
double getBestPossible() const
Best possible solution.
Definition
CbcCompareDefault.hpp:85
CbcModel
Simple Branch and bound class.
Definition
CbcModel.hpp:100
Generated by
1.17.0