Generated on Tue Mar 24 2020 14:04:04 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  * 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  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 namespace Gecode { namespace Set { namespace Branch {
41 
42  // Minimum merit
45  : MeritBase<SetView,int>(home,vb) {}
48  : MeritBase<SetView,int>(home,m) {}
49  forceinline int
52  return u.min();
53  }
54 
55  // Maximum merit
58  : MeritBase<SetView,int>(home,vb) {}
61  : MeritBase<SetView,int>(home,m) {}
62  forceinline int
64  int max = Limits::max;
65  for (UnknownRanges<SetView> u(x); u(); ++u)
66  max = u.max();
67  return max;
68  }
69 
70  // Size merit
73  : MeritBase<SetView,unsigned int>(home,vb) {}
76  : MeritBase<SetView,unsigned int>(home,m) {}
77  forceinline unsigned int
79  return x.unknownSize();
80  }
81 
82  // Degree over size merit
85  : MeritBase<SetView,double>(home,vb) {}
88  : MeritBase<SetView,double>(home,m) {}
89  forceinline double
91  return static_cast<double>(x.unknownSize()) /
92  static_cast<double>(x.degree());
93  }
94 
95  // AFC over size merit
98  : MeritBase<SetView,double>(home,vb), afc(vb.afc()) {}
101  : MeritBase<SetView,double>(home,m), afc(m.afc) {}
102  forceinline double
104  return x.afc() / static_cast<double>(x.unknownSize());
105  }
106  forceinline bool
107  MeritAFCSize::notice(void) const {
108  return false;
109  }
110  forceinline void
112  // Not really needed
113  afc.~AFC();
114  }
115 
116  // Action over size merit
119  : MeritBase<SetView,double>(home,vb), action(vb.action()) {}
122  : MeritBase<SetView,double>(home,m), action(m.action) {}
123  forceinline double
125  return action[i] / static_cast<double>(x.unknownSize());
126  }
127  forceinline bool
129  return true;
130  }
131  forceinline void
133  action.~Action();
134  }
135 
136 
137  // CHB Q-score over size merit
140  : MeritBase<SetView,double>(home,vb), chb(vb.chb()) {}
143  : MeritBase<SetView,double>(home,m), chb(m.chb) {}
144  forceinline double
146  return chb[i] / static_cast<double>(x.unknownSize());
147  }
148  forceinline bool
149  MeritCHBSize::notice(void) const {
150  return true;
151  }
152  forceinline void
154  chb.~CHB();
155  }
156 
157 }}}
158 
159 // STATISTICS: set-branch
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors)
Definition: var.hpp:101
Post propagator for SetVar x
Definition: set.hh:767
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:49
Merit class for AFC over size.
Definition: branch.hh:134
MeritDegreeSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:84
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:128
MeritAFCSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:97
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:145
Merit class for CHB Q-score over size.
Definition: branch.hh:180
Merit class for size of set view.
Definition: branch.hh:102
Range iterator for the unknown set.
Definition: var-imp.hpp:402
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:111
int operator()(const Space &home, SetView x, int i)
Return minimum as merit for view x at position i.
Definition: merit.hpp:50
Computation spaces.
Definition: core.hpp:1742
double operator()(const Space &home, SetView x, int i)
Return degree over size as merit for view x at position i.
Definition: merit.hpp:90
Variable branching information.
Definition: var.hpp:55
Gecode toplevel namespace
union Gecode::@602::NNF::@65 u
Union depending on nodetype t.
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:149
const int max
Largest allowed integer in integer set.
Definition: set.hh:97
AFC afc
AFC information.
Definition: branch.hh:137
double operator()(const Space &home, SetView x, int i)
Return action over size as merit for view x at position i.
Definition: merit.hpp:124
Base-class for merit class.
Definition: merit.hpp:46
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:118
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:132
unsigned int unknownSize(void) const
Return number of unknown elements (elements in lub but not in glb)
Definition: set.hpp:69
double operator()(const Space &home, SetView x, int i)
Return AFC over size as merit for view x at position i.
Definition: merit.hpp:103
~CHB(void)
Destructor.
Definition: chb.cpp:55
Merit class for degree over size.
Definition: branch.hh:118
Merit class for action over size.
Definition: branch.hh:157
AFC afc
Definition: afc.cpp:135
~Action(void)
Destructor.
Definition: action.cpp:55
int operator()(const Space &home, SetView x, int i)
Return maximum as merit for view x at position i.
Definition: merit.hpp:63
CHB chb
CHB information.
Definition: branch.hh:183
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:107
Action action
Action information.
Definition: branch.hh:160
Set view for set variables
Definition: view.hpp:56
MeritMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:57
#define forceinline
Definition: config.hpp:185
MeritCHBSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:139
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:153
MeritSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:72
unsigned int operator()(const Space &home, SetView x, int i)
Return size as merit for view x at position i.
Definition: merit.hpp:78
MeritMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: merit.hpp:44
Merit class for mimimum of set views.
Definition: branch.hh:70
~AFC(void)
Destructor.
Definition: afc.hpp:157
Gecode::IntArgs i({1, 2, 3, 4})
double afc(void) const
Return accumulated failure count.
Definition: var.hpp:106
Merit class for maximum of set view.
Definition: branch.hh:86