Generated on Sat Feb 7 2015 02:01:15 for Gecode by doxygen 1.8.9.1
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: 2013-07-01 09:17:01 +0200 (Mon, 01 Jul 2013) $ by $Author: tack $
17  * $Revision: 13742 $
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  // Size over degree 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  // Size over AFC 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 static_cast<double>(x.unknownSize()) / x.afc(home);
112  }
113  forceinline bool
114  MeritAFCSize::notice(void) const {
115  return true;
116  }
117  forceinline void
119  afc.~AFC();
120  }
121 
122  // Size over activity merit
125  const VarBranch& vb)
126  : MeritBase<SetView,double>(home,vb), activity(vb.activity()) {}
130  : MeritBase<SetView,double>(home,shared,m) {
131  activity.update(home, shared, m.activity);
132  }
133  forceinline double
135  return activity[i] / static_cast<double>(x.unknownSize());
136  }
137  forceinline bool
139  return true;
140  }
141  forceinline void
144  }
145 
146 }}}
147 
148 // STATISTICS: set-branch
void update(int i)
Update activity value at position i.
Definition: activity.hpp:303
Merit class for size over afc.
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 size over AFC as merit for view x at position i.
Definition: merit.hpp:110
MeritMax(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:61
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
unsigned int unknownSize(void) const
Return the number of unknown elements.
Definition: set.hpp:74
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:57
MeritMin(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:48
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:154
double operator()(const Space &home, SetView x, int i)
Return size over degree as merit for view x at position i.
Definition: merit.hpp:95
const int max
Largest allowed integer in integer set.
Definition: set.hh:99
Computation spaces.
Definition: core.hpp:1362
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors)
Definition: view.hpp:438
int min(void) const
Return smallest value of range.
MeritDegreeSize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:88
Merit class for size over activity.
Definition: branch.hh:161
Gecode::IntArgs i(4, 1, 2, 3, 4)
MeritSize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:76
double operator()(const Space &home, SetView x, int i)
Return size over activity as merit for view x at position i.
Definition: merit.hpp:134
MeritActivitySize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:124
AFC afc
AFC information.
Definition: branch.hh:141
~Activity(void)
Destructor.
Definition: activity.cpp:74
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:138
union Gecode::@518::NNF::@57 u
Union depending on nodetype t.
Set view for set variables
Definition: view.hpp:60
Merit class for size of set view.
Definition: branch.hh:106
Variable branching information.
Definition: branch-var.hpp:55
double afc(const Space &home) const
Return accumulated failure count.
Definition: view.hpp:443
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
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 size over degree.
Definition: branch.hh:122
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:114
#define forceinline
Definition: config.hpp:132
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:662
unsigned int operator()(const Space &home, SetView x, int i)
Return size as merit for view x at position i.
Definition: merit.hpp:82
Gecode toplevel namespace
void update(Space &home, bool share, AFC &a)
Updating during cloning.
Definition: afc.hpp:157
MeritAFCSize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:102
Activity activity
Activity information.
Definition: branch.hh:164
Merit class for mimimum of set views.
Definition: branch.hh:74