Generated on Thu Apr 5 2018 19:44:19 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$ by $Author$
17  * $Revision$
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,m) {}
53  forceinline int
56  return u.min();
57  }
58 
59  // Maximum merit
62  : MeritBase<SetView,int>(home,vb) {}
65  : MeritBase<SetView,int>(home,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,m) {}
81  forceinline unsigned int
83  return x.unknownSize();
84  }
85 
86  // Degree over size merit
89  : MeritBase<SetView,double>(home,vb) {}
92  : MeritBase<SetView,double>(home,m) {}
93  forceinline double
95  return static_cast<double>(x.unknownSize()) /
96  static_cast<double>(x.degree());
97  }
98 
99  // AFC over size merit
102  : MeritBase<SetView,double>(home,vb), afc(vb.afc()) {}
105  : MeritBase<SetView,double>(home,m), afc(m.afc) {}
106  forceinline double
108  return x.afc() / static_cast<double>(x.unknownSize());
109  }
110  forceinline bool
111  MeritAFCSize::notice(void) const {
112  return false;
113  }
114  forceinline void
116  // Not really needed
117  afc.~AFC();
118  }
119 
120  // Action over size merit
123  : MeritBase<SetView,double>(home,vb), action(vb.action()) {}
126  : MeritBase<SetView,double>(home,m), action(m.action) {}
127  forceinline double
129  return action[i] / static_cast<double>(x.unknownSize());
130  }
131  forceinline bool
133  return true;
134  }
135  forceinline void
137  action.~Action();
138  }
139 
140 
141  // CHB Q-score over size merit
144  : MeritBase<SetView,double>(home,vb), chb(vb.chb()) {}
147  : MeritBase<SetView,double>(home,m), chb(m.chb) {}
148  forceinline double
150  return chb[i] / static_cast<double>(x.unknownSize());
151  }
152  forceinline bool
153  MeritCHBSize::notice(void) const {
154  return true;
155  }
156  forceinline void
158  chb.~CHB();
159  }
160 
161 }}}
162 
163 // 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:107
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:115
Range iterator for the unknown set.
Definition: var-imp.hpp:406
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:136
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:149
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:53
~Action(void)
Destructor.
Definition: action.cpp:59
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.
Definition: merit.hpp:50
~AFC(void)
Destructor.
Definition: afc.hpp:161
double operator()(const Space &home, SetView x, int i)
Return degree over size as merit for view x at position i.
Definition: merit.hpp:94
#define forceinline
Definition: config.hpp:182
const int max
Largest allowed integer in integer set.
Definition: set.hh:101
Computation spaces.
Definition: core.hpp:1668
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:132
Gecode::IntArgs i(4, 1, 2, 3, 4)
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:101
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:128
~CHB(void)
Destructor.
Definition: chb.cpp:59
union Gecode::@585::NNF::@62 u
Union depending on nodetype t.
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:143
Set view for set variables
Definition: view.hpp:60
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:157
Merit class for size of set view.
Definition: branch.hh:106
Variable branching information.
Definition: 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
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:111
Post propagator for SetVar x
Definition: set.hh:769
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors)
Definition: view.hpp:468
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:122
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:153
Gecode toplevel namespace
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