main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Oct 22 2013 00:49:00 for Gecode by
doxygen
1.8.4
gecode
float
branch
merit.hpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Christian Schulte <schulte@gecode.org>
5
*
6
* Contributing authors:
7
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
8
*
9
* Copyright:
10
* Christian Schulte, 2012
11
* Vincent Barichard, 2012
12
*
13
* Last modified:
14
* $Date: 2013-06-13 20:53:42 +0200 (Thu, 13 Jun 2013) $ by $Author: tack $
15
* $Revision: 13706 $
16
*
17
* This file is part of Gecode, the generic constraint
18
* development environment:
19
* http://www.gecode.org
20
*
21
* Permission is hereby granted, free of charge, to any person obtaining
22
* a copy of this software and associated documentation files (the
23
* "Software"), to deal in the Software without restriction, including
24
* without limitation the rights to use, copy, modify, merge, publish,
25
* distribute, sublicense, and/or sell copies of the Software, and to
26
* permit persons to whom the Software is furnished to do so, subject to
27
* the following conditions:
28
*
29
* The above copyright notice and this permission notice shall be
30
* included in all copies or substantial portions of the Software.
31
*
32
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39
*
40
*/
41
42
namespace
Gecode {
namespace
Float {
namespace
Branch {
43
44
// Minimum merit
45
forceinline
46
MeritMin::MeritMin
(
Space
& home,
const
VarBranch
& vb)
47
:
MeritBase
<
FloatView
,double>(home,vb) {}
48
forceinline
49
MeritMin::MeritMin
(
Space
& home,
bool
shared
,
MeritMin
& m)
50
:
MeritBase
<
FloatView
,double>(home,shared,m) {}
51
forceinline
double
52
MeritMin::operator ()
(
const
Space
&,
FloatView
x
,
int
) {
53
return
x.
min
();
54
}
55
56
// Maximum merit
57
forceinline
58
MeritMax::MeritMax
(
Space
& home,
const
VarBranch
& vb)
59
:
MeritBase
<
FloatView
,double>(home,vb) {}
60
forceinline
61
MeritMax::MeritMax
(
Space
& home,
bool
shared
,
MeritMax
& m)
62
:
MeritBase
<
FloatView
,double>(home,shared,m) {}
63
forceinline
double
64
MeritMax::operator ()
(
const
Space
&,
FloatView
x
,
int
) {
65
return
x.
max
();
66
}
67
68
// Size merit
69
forceinline
70
MeritSize::MeritSize
(
Space
& home,
const
VarBranch
& vb)
71
:
MeritBase
<
FloatView
,double>(home,vb) {}
72
forceinline
73
MeritSize::MeritSize
(
Space
& home,
bool
shared
,
MeritSize
& m)
74
:
MeritBase
<
FloatView
,double>(home,shared,m) {}
75
forceinline
double
76
MeritSize::operator ()
(
const
Space
&,
FloatView
x
,
int
) {
77
return
x.
size
();
78
}
79
80
// Size over degree merit
81
forceinline
82
MeritDegreeSize::MeritDegreeSize
(
Space
& home,
const
VarBranch
& vb)
83
:
MeritBase
<
FloatView
,double>(home,vb) {}
84
forceinline
85
MeritDegreeSize::MeritDegreeSize
(
Space
& home,
bool
shared
,
86
MeritDegreeSize
& m)
87
:
MeritBase
<
FloatView
,double>(home,shared,m) {}
88
forceinline
double
89
MeritDegreeSize::operator ()
(
const
Space
&,
FloatView
x
,
int
) {
90
return
x.
size
() /
static_cast<
double
>
(x.
degree
());
91
}
92
93
// Size over AFC merit
94
forceinline
95
MeritAFCSize::MeritAFCSize
(
Space
& home,
const
VarBranch
& vb)
96
:
MeritBase
<
FloatView
,double>(home,vb),
afc
(vb.
afc
()) {}
97
forceinline
98
MeritAFCSize::MeritAFCSize
(
Space
& home,
bool
shared
,
MeritAFCSize
& m)
99
:
MeritBase
<
FloatView
,double>(home,shared,m) {
100
afc
.
update
(home,shared,m.
afc
);
101
}
102
forceinline
double
103
MeritAFCSize::operator ()
(
const
Space
& home,
FloatView
x
,
int
) {
104
return
x.
size
() / x.
afc
(home);
105
}
106
forceinline
bool
107
MeritAFCSize::notice
(
void
)
const
{
108
return
true
;
109
}
110
forceinline
void
111
MeritAFCSize::dispose
(
Space
&) {
112
afc
.
~AFC
();
113
}
114
115
// Size over activity merit
116
forceinline
117
MeritActivitySize::MeritActivitySize
(
Space
& home,
118
const
VarBranch
& vb)
119
:
MeritBase
<
FloatView
,double>(home,vb), activity(vb.activity()) {}
120
forceinline
121
MeritActivitySize::MeritActivitySize
(
Space
& home,
bool
shared
,
122
MeritActivitySize
& m)
123
:
MeritBase
<
FloatView
,double>(home,shared,m) {
124
activity
.
update
(home, shared, m.
activity
);
125
}
126
forceinline
double
127
MeritActivitySize::operator ()
(
const
Space
&,
FloatView
x
,
int
i
) {
128
return
activity
[
i
] /
static_cast<
double
>
(x.
size
());
129
}
130
forceinline
bool
131
MeritActivitySize::notice
(
void
)
const
{
132
return
true
;
133
}
134
forceinline
void
135
MeritActivitySize::dispose
(
Space
&) {
136
activity
.
~Activity
();
137
}
138
139
}}}
140
141
// STATISTICS: float-branch