3
* Christian Schulte <schulte@gecode.org>
6
* Christian Schulte, 2002
9
* $Date: 2005-10-19 18:05:44 +0200 (Wed, 19 Oct 2005) $ by $Author: tack $
12
* This file is part of Gecode, the generic constraint
13
* development environment:
14
* http://www.gecode.org
16
* See the file "LICENSE" for information on usage and
17
* redistribution of this file, and for a
18
* DISCLAIMER OF ALL WARRANTIES.
22
#ifndef __GECODE_INT_BRANCH_HH__
23
#define __GECODE_INT_BRANCH_HH__
28
* \namespace Gecode::Int::Branch
29
* \brief Integer branchings
32
namespace Gecode { namespace Int { namespace Branch {
35
* Value selection classes
39
* \brief Class for selecting minimum value
41
* All value selection classes require
42
* \code #include "int/branch.hh" \endcode
43
* \ingroup FuncIntSelVal
47
/// Return minimum value of view \a x
49
/// Tell \f$x=n\f$ (\a a = 0) or \f$x\neq n\f$ (\a a = 1)
50
ModEvent tell(Space* home, unsigned int a, IntView x, int n);
54
* \brief Class for selecting maximum value
57
* \code #include "int/branch.hh" \endcode
58
* \ingroup FuncIntSelVal
62
/// Return maximum value of view \a x
64
/// Tell \f$x=n\f$ (\a a = 0) or \f$x\neq n\f$ (\a a = 1)
65
ModEvent tell(Space* home, unsigned int a, IntView x, int n);
69
* \brief Class for selecting median value
72
* \code #include "int/branch.hh" \endcode
73
* \ingroup FuncIntSelVal
77
/// Return median value of view \a x
79
/// Tell \f$x=n\f$ (\a a = 0) or \f$x\neq n\f$ (\a a = 1)
80
ModEvent tell(Space* home, unsigned int a, IntView x, int n);
84
* \brief Class for splitting domain (lower half first)
87
* \code #include "int/branch.hh" \endcode
88
* \ingroup FuncIntSelVal
92
/// Return minimum value of view \a x
94
/// Tell \f$x\leq n\f$ (\a a = 0) or \f$x >n\f$ (\a a = 1)
95
ModEvent tell(Space* home, unsigned int a, IntView x, int n);
99
* \brief Class for splitting domain (upper half first)
102
* \code #include "int/branch.hh" \endcode
103
* \ingroup FuncIntSelVal
107
/// Return minimum value of view \a x
109
/// Tell \f$x>n\f$ (\a a = 0) or \f$x\leq n\f$ (\a a = 1)
110
ModEvent tell(Space* home, unsigned int a, IntView x, int n);
113
/// Create branchings for a given view selection strategy \a ViewSel
114
template <class SelView>
116
create(Space* home, ViewArray<IntView>&, BvalSel);
120
* Variable selection classes
125
* \brief View selection class for first variable
127
* Requires \code #include "int/branch.hh" \endcode
128
* \ingroup FuncIntSelView
132
/// Intialize with view \a x
133
ViewSelStatus init(IntView x);
134
/// Possibly select better view \a x
135
ViewSelStatus select(IntView x);
139
* \brief View selection class for view with smallest min
141
* Requires \code #include "int/branch.hh" \endcode
142
* \ingroup FuncIntSelView
146
/// So-far smallest minimum
149
/// Intialize with view \a x
150
ViewSelStatus init(IntView x);
151
/// Possibly select better view \a x
152
ViewSelStatus select(IntView x);
156
* \brief View selection class for view with largest min
158
* Requires \code #include "int/branch.hh" \endcode
159
* \ingroup FuncIntSelView
163
/// So-far largest minimum
166
/// Intialize with view \a x
167
ViewSelStatus init(IntView x);
168
/// Possibly select better view \a x
169
ViewSelStatus select(IntView x);
173
* \brief View selection class for view with smallest max
175
* Requires \code #include "int/branch.hh" \endcode
176
* \ingroup FuncIntSelView
180
/// So-far smallest maximum
183
/// Intialize with view \a x
184
ViewSelStatus init(IntView x);
185
/// Possibly select better view \a x
186
ViewSelStatus select(IntView x);
190
* \brief View selection class for view with largest max
192
* Requires \code #include "int/branch.hh" \endcode
193
* \ingroup FuncIntSelView
197
/// So-far largest maximum
200
/// Intialize with view \a x
201
ViewSelStatus init(IntView x);
202
/// Possibly select better view \a x
203
ViewSelStatus select(IntView x);
207
* \brief View selection class for view with smallest size
209
* Requires \code #include "int/branch.hh" \endcode
210
* \ingroup FuncIntSelView
214
/// So-far smallest size
217
/// Intialize with view \a x
218
ViewSelStatus init(IntView x);
219
/// Possibly select better view \a x
220
ViewSelStatus select(IntView x);
224
* \brief View selection class for view with largest size
226
* Requires \code #include "int/branch.hh" \endcode
227
* \ingroup FuncIntSelView
231
/// So-far largest size
234
/// Intialize with view \a x
235
ViewSelStatus init(IntView x);
236
/// Possibly select better view \a x
237
ViewSelStatus select(IntView x);
241
* \brief View selection class for view with smallest degree (and smallest size in case of ties)
243
* Requires \code #include "int/branch.hh" \endcode
244
* \ingroup FuncIntSelView
248
/// So-far smallest degree
250
/// So-far smallest size for degree
253
/// Intialize with view \a x
254
ViewSelStatus init(IntView x);
255
/// Possibly select better view \a x
256
ViewSelStatus select(IntView x);
260
* \brief View selection class for view with largest degree (and smallest size in case of ties)
262
* Requires \code #include "int/branch.hh" \endcode
263
* \ingroup FuncIntSelView
267
/// So-far largest degree
269
/// So-far smallest size for degree
272
/// Intialize with view \a x
273
ViewSelStatus init(IntView x);
274
/// Possibly select better view \a x
275
ViewSelStatus select(IntView x);
279
* \brief View selection class for view with smallest min-regret
281
* Requires \code #include "int/branch.hh" \endcode
282
* \ingroup FuncIntSelView
284
class ByRegretMinMin {
286
/// So-far smallest regret
289
/// Intialize with view \a x
290
ViewSelStatus init(IntView x);
291
/// Possibly select better view \a x
292
ViewSelStatus select(IntView x);
296
* \brief View selection class for view with largest min-regret
298
* Requires \code #include "int/branch.hh" \endcode
299
* \ingroup FuncIntSelView
301
class ByRegretMinMax {
303
/// So-far largest regret
306
/// Intialize with view \a x
307
ViewSelStatus init(IntView x);
308
/// Possibly select better view \a x
309
ViewSelStatus select(IntView x);
313
* \brief View selection class for view with smallest max-regret
315
* Requires \code #include "int/branch.hh" \endcode
316
* \ingroup FuncIntSelView
318
class ByRegretMaxMin {
320
/// So-far smallest regret
323
/// Intialize with view \a x
324
ViewSelStatus init(IntView x);
325
/// Possibly select better view \a x
326
ViewSelStatus select(IntView x);
330
* \brief View selection class for view with largest max-regret
332
* Requires \code #include "int/branch.hh" \endcode
333
* \ingroup FuncIntSelView
335
class ByRegretMaxMax {
337
/// So-far largest regret
340
/// Intialize with view \a x
341
ViewSelStatus init(IntView x);
342
/// Possibly select better view \a x
343
ViewSelStatus select(IntView x);
348
* Classes for assignment
352
/// Assignment (single-alternative branching) base-class
353
class Assign : public Branching {
356
ViewArray<IntView> x;
357
/// Next position to be assigned
359
/// Constructor for cloning \a b
360
Assign(Space* home, bool share, Assign& b);
362
/// Constructor for creation
363
Assign(Space* home, ViewArray<IntView>& x);
364
/// Perform branching (selects view)
365
virtual unsigned int branch(void);
369
/// Minimum assignment (single-alternative branching)
370
class AssignMin : public Assign {
372
/// Constructor for cloning \a b
373
AssignMin(Space* home, bool share, AssignMin& b);
375
/// Constructor for creation
376
AssignMin(Space* home, ViewArray<IntView>& x);
378
virtual Actor* copy(Space* home, bool share);
379
/// Return branching description (of type Gecode::PosValDesc)
380
virtual BranchingDesc* description(void);
381
/// Perform commit for alternative \a a and branching description \a d
382
virtual ExecStatus commit(Space* home, unsigned int a, BranchingDesc* d);
385
/// Median assignment (single-alternative branching)
386
class AssignMed : public Assign {
388
/// Constructor for cloning \a b
389
AssignMed(Space* home, bool share, AssignMed& b);
391
/// Constructor for creation
392
AssignMed(Space* home, ViewArray<IntView>& x);
394
virtual Actor* copy(Space* home, bool share);
395
/// Return branching description (of type Gecode::PosValDesc)
396
virtual BranchingDesc* description(void);
397
/// Perform commit for alternative \a a and branching description \a d
398
virtual ExecStatus commit(Space* home, unsigned int a, BranchingDesc* d);
401
/// Maximum assignment (single-alternative branching)
402
class AssignMax : public Assign {
404
/// Constructor for cloning \a b
405
AssignMax(Space* home, bool share, AssignMax& b);
407
/// Constructor for creation
408
AssignMax(Space* home, ViewArray<IntView>& x);
410
virtual Actor* copy(Space* home, bool share);
411
/// Return branching description (of type Gecode::PosValDesc)
412
virtual BranchingDesc* description(void);
413
/// Perform commit for alternative \a a and branching description \a d
414
virtual ExecStatus commit(Space* home, unsigned int a, BranchingDesc* d);
419
#include "int/branch/select-val.icc"
420
#include "int/branch/select-view.icc"
422
#include "int/branch/assign.icc"
426
// STATISTICS: int-branch