Generated on Tue Jul 18 2017 18:41:42 for Gecode by doxygen 1.8.13
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  * Gabor Szokoli <szokoli@gecode.org>
8  * Guido Tack <tack@gecode.org>
9  *
10  * Copyright:
11  * Christian Schulte, 2012
12  * Gabor Szokoli, 2004
13  * Guido Tack, 2004
14  *
15  * Last modified:
16  * $Date: 2017-04-01 20:27:10 +0200 (Sat, 01 Apr 2017) $ by $Author: schulte $
17  * $Revision: 15623 $
18  *
19  * This file is part of Gecode, the generic constraint
20  * development environment:
21  * http://www.gecode.org
22  *
23  * Permission is hereby granted, free of charge, to any person obtaining
24  * a copy of this software and associated documentation files (the
25  * "Software"), to deal in the Software without restriction, including
26  * without limitation the rights to use, copy, modify, merge, publish,
27  * distribute, sublicense, and/or sell copies of the Software, and to
28  * permit persons to whom the Software is furnished to do so, subject to
29  * the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be
32  * included in all copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
38  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
39  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41  *
42  */
43 
44 namespace Gecode { namespace Set { namespace Branch {
45 
46  // Minimum merit
49  : MeritBase<SetView,int>(home,vb) {}
52  : MeritBase<SetView,int>(home,shared,m) {}
53  forceinline int
56  return u.min();
57  }
58 
59  // Maximum merit
62  : MeritBase<SetView,int>(home,vb) {}
65  : MeritBase<SetView,int>(home,shared,m) {}
66  forceinline int
68  int max = Limits::max;
69  for (UnknownRanges<SetView> u(x); u(); ++u)
70  max = u.max();
71  return max;
72  }
73 
74  // Size merit
77  : MeritBase<SetView,unsigned int>(home,vb) {}
80  : MeritBase<SetView,unsigned int>(home,shared,m) {}
81  forceinline unsigned int
83  return x.unknownSize();
84  }
85 
86  // Degree over size merit
89  : MeritBase<SetView,double>(home,vb) {}
92  MeritDegreeSize& m)
93  : MeritBase<SetView,double>(home,shared,m) {}
94  forceinline double
96  return static_cast<double>(x.unknownSize()) /
97  static_cast<double>(x.degree());
98  }
99 
100  // AFC over size merit
103  : MeritBase<SetView,double>(home,vb), afc(vb.afc()) {}
106  : MeritBase<SetView,double>(home,shared,m) {
107  afc.update(home,shared,m.afc);
108  }
109  forceinline double
111  return x.afc() / static_cast<double>(x.unknownSize());
112  }
113  forceinline bool
114  MeritAFCSize::notice(void) const {
115  return true;
116  }
117  forceinline void
119  afc.~AFC();
120  }
121 
122  // Action over size merit
125  const VarBranch<Var>& vb)
126  : MeritBase<SetView,double>(home,vb), action(vb.action()) {}
129  MeritActionSize& m)
130  : MeritBase<SetView,double>(home,shared,m) {
131  action.update(home, shared, m.action);
132  }
133  forceinline double
135  return action[i] / static_cast<double>(x.unknownSize());
136  }
137  forceinline bool
139  return true;
140  }
141  forceinline void
143  action.~Action();
144  }
145 
146 
147  // CHB Q-score over size merit
150  const VarBranch<Var>& vb)
151  : MeritBase<SetView,double>(home,vb), chb(vb.chb()) {}
154  MeritCHBSize& m)
155  : MeritBase<SetView,double>(home,shared,m) {
156  chb.update(home, shared, m.chb);
157  }
158  forceinline double
160  return chb[i] / static_cast<double>(x.unknownSize());
161  }
162  forceinline bool
163  MeritCHBSize::notice(void) const {
164  return true;
165  }
166  forceinline void
168  chb.~CHB();
169  }
170 
171 }}}
172 
173 // STATISTICS: set-branch
Merit class for AFC over size.
Definition: branch.hh:138
Merit class for maximum of set view.
Definition: branch.hh:90
double operator()(const Space &home, SetView x, int i)
Return AFC over size as merit for view x at position i.
Definition: merit.hpp:110
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:118
Range iterator for the unknown set.
Definition: var-imp.hpp:406
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:142
union Gecode::@579::NNF::@61 u
Union depending on nodetype t.
Merit class for CHB Q-score over size.
Definition: branch.hh:184
double operator()(const Space &home, SetView x, int i)
Return CHB Q-score over size as merit for view x at position i.
Definition: merit.hpp:159
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:53
~Action(void)
Destructor.
Definition: action.cpp:74
void update(int i)
Update chb value at position i.
int operator()(const Space &home, SetView x, int i)
Return minimum as merit for view x at position i.
Definition: merit.hpp:54
AFC afc
Definition: afc.cpp:139
Base-class for merit class.
~AFC(void)
Destructor.
Definition: afc.hpp:152
double operator()(const Space &home, SetView x, int i)
Return degree over size as merit for view x at position i.
Definition: merit.hpp:95
const int max
Largest allowed integer in integer set.
Definition: set.hh:101
Computation spaces.
Definition: core.hpp:1748
unsigned int unknownSize(void) const
Return the number of unknown elements.
Definition: set.hpp:74
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:138
Gecode::IntArgs i(4, 1, 2, 3, 4)
void update(int i)
Update action value at position i.
Definition: action.hpp:306
Merit class for action over size.
Definition: branch.hh:161
MeritDegreeSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:88
AFC afc
AFC information.
Definition: branch.hh:141
MeritAFCSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:102
MeritSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:76
double operator()(const Space &home, SetView x, int i)
Return action over size as merit for view x at position i.
Definition: merit.hpp:134
~CHB(void)
Destructor.
Definition: chb.cpp:74
MeritMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:61
CHB chb
CHB information.
Definition: branch.hh:187
MeritCHBSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:149
Set view for set variables
Definition: view.hpp:60
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:167
Merit class for size of set view.
Definition: branch.hh:106
Variable branching information.
Definition: branch-var.hpp:59
Action action
Action information.
Definition: branch.hh:164
int operator()(const Space &home, SetView x, int i)
Return maximum as merit for view x at position i.
Definition: merit.hpp:67
Merit class for degree over size.
Definition: branch.hh:122
#define forceinline
Definition: config.hpp:173
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:114
Post propagator for SetVar x
Definition: set.hh:784
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors)
Definition: view.hpp:468
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:702
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:124
unsigned int operator()(const Space &home, SetView x, int i)
Return size as merit for view x at position i.
Definition: merit.hpp:82
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:163
Gecode toplevel namespace
void update(Space &home, bool share, AFC &a)
Updating during cloning.
Definition: afc.hpp:155
int min(void) const
Return smallest value of range.
MeritMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:48
Merit class for mimimum of set views.
Definition: branch.hh:74
double afc(void) const
Return accumulated failure count.
Definition: view.hpp:473