Generated on Tue Jan 28 2020 00:00:00 for Gecode by doxygen 1.8.17
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: 2017-04-01 20:27:10 +0200 (Sat, 01 Apr 2017) $ by $Author: schulte $
15  * $Revision: 15623 $
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
47  : MeritBase<FloatView,double>(home,vb) {}
50  : MeritBase<FloatView,double>(home,shared,m) {}
51  forceinline double
53  return x.min();
54  }
55 
56  // Maximum merit
59  : MeritBase<FloatView,double>(home,vb) {}
62  : MeritBase<FloatView,double>(home,shared,m) {}
63  forceinline double
65  return x.max();
66  }
67 
68  // Size merit
71  : MeritBase<FloatView,double>(home,vb) {}
74  : MeritBase<FloatView,double>(home,shared,m) {}
75  forceinline double
77  return x.size();
78  }
79 
80  // Degree over size merit
83  : MeritBase<FloatView,double>(home,vb) {}
86  MeritDegreeSize& m)
87  : MeritBase<FloatView,double>(home,shared,m) {}
88  forceinline double
90  return x.size() / static_cast<double>(x.degree());
91  }
92 
93  // AFC over size merit
96  : MeritBase<FloatView,double>(home,vb), afc(vb.afc()) {}
99  : MeritBase<FloatView,double>(home,shared,m) {
100  afc.update(home,shared,m.afc);
101  }
102  forceinline double
104  return x.afc() / static_cast<double>(x.size());
105  }
106  forceinline bool
107  MeritAFCSize::notice(void) const {
108  return true;
109  }
110  forceinline void
112  afc.~AFC();
113  }
114 
115  // Action over size merit
118  const VarBranch<Var>& vb)
119  : MeritBase<FloatView,double>(home,vb), action(vb.action()) {}
122  MeritActionSize& m)
123  : MeritBase<FloatView,double>(home,shared,m) {
124  action.update(home, shared, m.action);
125  }
126  forceinline double
128  return action[i] / static_cast<double>(x.size());
129  }
130  forceinline bool
132  return true;
133  }
134  forceinline void
136  action.~Action();
137  }
138 
139 
140  // CHB Q-score over size merit
143  const VarBranch<Var>& vb)
144  : MeritBase<FloatView,double>(home,vb), chb(vb.chb()) {}
147  MeritCHBSize& m)
148  : MeritBase<FloatView,double>(home,shared,m) {
149  chb.update(home, shared, m.chb);
150  }
151  forceinline double
153  return chb[i] / static_cast<double>(x.size());
154  }
155  forceinline bool
156  MeritCHBSize::notice(void) const {
157  return true;
158  }
159  forceinline void
161  chb.~CHB();
162  }
163 
164 }}}
165 
166 // STATISTICS: float-branch
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors)
Definition: var.hpp:113
Post propagator for SetVar x
Definition: set.hh:784
Merit class for mimimum.
Definition: branch.hh:70
double operator()(const Space &home, FloatView x, int i)
Return degree over size as merit for view x at position i.
Definition: merit.hpp:89
void update(int i)
Update chb value at position i.
#define forceinline
Definition: config.hpp:173
double operator()(const Space &home, FloatView x, int i)
Return minimum as merit for view x at position i.
Definition: merit.hpp:52
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:131
Merit class for degree over size.
Definition: branch.hh:118
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:135
Gecode::IntArgs i(4, 1, 2, 3, 4)
Computation spaces.
Definition: core.hpp:1748
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:117
MeritSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:70
Variable branching information.
Definition: branch-var.hpp:59
Gecode toplevel namespace
Merit class for action over size.
Definition: branch.hh:157
double operator()(const Space &home, FloatView x, int i)
Return action over size as merit for view x at position i.
Definition: merit.hpp:127
Float view for float variables.
Definition: view.hpp:56
AFC afc
AFC information.
Definition: branch.hh:137
MeritDegreeSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:82
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:111
Base-class for merit class.
Merit class for size of float view.
Definition: branch.hh:102
double operator()(const Space &home, FloatView x, int i)
Return size as merit for view x at position i.
Definition: merit.hpp:76
MeritCHBSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:142
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:156
MeritMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:58
~CHB(void)
Destructor.
Definition: chb.cpp:74
Merit class for AFC over size.
Definition: branch.hh:134
AFC afc
Definition: afc.cpp:139
~Action(void)
Destructor.
Definition: action.cpp:74
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:160
MeritMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:46
double operator()(const Space &home, FloatView x, int i)
Return CHB Q-score over size as merit for view x at position i.
Definition: merit.hpp:152
Merit class for maximum of float view.
Definition: branch.hh:86
bool shared(const IntSet &, VX)
Definition: view-base.hpp:122
void update(int i)
Update action value at position i.
Definition: action.hpp:306
MeritAFCSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:95
~AFC(void)
Destructor.
Definition: afc.hpp:152
double operator()(const Space &home, FloatView x, int i)
Return maximum as merit for view x at position i.
Definition: merit.hpp:64
double afc(void) const
Return accumulated failure count.
Definition: var.hpp:118
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:107
double operator()(const Space &home, FloatView x, int i)
Return AFC over size as merit for view x at position i.
Definition: merit.hpp:103
void update(Space &home, bool share, AFC &a)
Updating during cloning.
Definition: afc.hpp:155
Merit class for CHB Q-score over size.
Definition: branch.hh:180
CHB chb
CHB information.
Definition: branch.hh:183
Action action
Action information.
Definition: branch.hh:160