Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
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
40namespace 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) {}
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
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()) {}
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
150 return true;
151 }
152 forceinline void
154 chb.~CHB();
155 }
156
157}}}
158
159// STATISTICS: set-branch
void dispose(Space &home)
Dispose view selection.
Definition merit.hpp:122
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition merit.hpp:117
double operator()(const Space &home, View x, int i)
Return AFC over size as merit for view x at position i.
Definition merit.hpp:112
MeritAFCSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition merit.hpp:144
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
double operator()(const Space &home, View x, int i)
Return action over size as merit for view x at position i.
Definition merit.hpp:139
void dispose(Space &home)
Dispose view selection.
Definition merit.hpp:149
void dispose(Space &home)
Dispose view selection.
Definition merit.hpp:175
double operator()(const Space &home, View x, int i)
Return size over action as merit for view x at position i.
Definition merit.hpp:165
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition merit.hpp:170
MeritCHBSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
double operator()(const Space &home, View x, int i)
Return degree over size as merit for view x at position i.
Definition merit.hpp:96
MeritDegreeSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
MeritMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
int operator()(const Space &home, View x, int i)
Return maximum as merit for view x at position i.
Definition merit.hpp:64
MeritMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
int operator()(const Space &home, View x, int i)
Return minimum as merit for view x at position i.
Definition merit.hpp:48
MeritSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
unsigned int operator()(const Space &home, View x, int i)
Return size as merit for view x at position i.
Definition merit.hpp:80
int min(void) const
Return smallest value of range.
MeritBase(Space &home, const VarBranch< Var > &vb)
Definition merit.hpp:176
AFC afc
AFC information.
Definition branch.hh:137
MeritAFCSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:97
Action action
Action information.
Definition branch.hh:160
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:118
MeritCHBSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:139
CHB chb
CHB information.
Definition branch.hh:183
MeritDegreeSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:84
MeritMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:57
MeritMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:44
MeritSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:72
Set view for set variables
Definition view.hpp:56
Range iterator for the unknown set.
Definition var-imp.hpp:402
Computation spaces.
Definition core.hpp:1744
Variable branching information.
Definition var.hpp:55
Set branchings
const int max
Largest allowed integer in integer set.
Definition set.hh:97
Finite integer sets.
Definition var-imp.hpp:137
Gecode toplevel namespace
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar x
Definition set.hh:773
#define forceinline
Definition config.hpp:194