main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Oct 22 2013 00:49:00 for Gecode by
doxygen
1.8.4
gecode
int
branch.hh
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
* Copyright:
7
* Christian Schulte, 2012
8
*
9
* Last modified:
10
* $Date: 2013-07-08 19:23:25 +0200 (Mon, 08 Jul 2013) $ by $Author: schulte $
11
* $Revision: 13827 $
12
*
13
* This file is part of Gecode, the generic constraint
14
* development environment:
15
* http://www.gecode.org
16
*
17
* Permission is hereby granted, free of charge, to any person obtaining
18
* a copy of this software and associated documentation files (the
19
* "Software"), to deal in the Software without restriction, including
20
* without limitation the rights to use, copy, modify, merge, publish,
21
* distribute, sublicense, and/or sell copies of the Software, and to
22
* permit persons to whom the Software is furnished to do so, subject to
23
* the following conditions:
24
*
25
* The above copyright notice and this permission notice shall be
26
* included in all copies or substantial portions of the Software.
27
*
28
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
*
36
*/
37
38
#ifndef __GECODE_INT_BRANCH_HH__
39
#define __GECODE_INT_BRANCH_HH__
40
41
#include <
gecode/int.hh
>
42
48
namespace
Gecode {
namespace
Int {
namespace
Branch {
49
68
template
<
class
View>
69
class
MeritMin
:
public
MeritBase
<View,int> {
70
public
:
72
MeritMin
(
Space
& home,
const
VarBranch
& vb);
74
MeritMin
(
Space
& home,
bool
shared
,
MeritMin
& m);
76
int
operator ()
(
const
Space
& home,
View
x
,
int
i
);
77
};
78
85
template
<
class
View>
86
class
MeritMax
:
public
MeritBase
<View,int> {
87
public
:
89
MeritMax
(
Space
& home,
const
VarBranch
& vb);
91
MeritMax
(
Space
& home,
bool
shared
,
MeritMax
& m);
93
int
operator ()
(
const
Space
& home,
View
x
,
int
i
);
94
};
95
102
template
<
class
View>
103
class
MeritSize
:
public
MeritBase
<View,unsigned int> {
104
public
:
106
MeritSize
(
Space
& home,
const
VarBranch
& vb);
108
MeritSize
(
Space
& home,
bool
shared
,
MeritSize
& m);
110
unsigned
int
operator ()
(
const
Space
& home,
View
x
,
int
i
);
111
};
112
119
template
<
class
View>
120
class
MeritDegreeSize
:
public
MeritBase
<View,double> {
121
public
:
123
MeritDegreeSize
(
Space
& home,
const
VarBranch
& vb);
125
MeritDegreeSize
(
Space
& home,
bool
shared
,
MeritDegreeSize
& m);
127
double
operator ()
(
const
Space
& home,
View
x
,
int
i
);
128
};
129
136
template
<
class
View>
137
class
MeritAFCSize
:
public
MeritBase
<View,double> {
138
protected
:
140
AFC
afc
;
141
public
:
143
MeritAFCSize
(
Space
& home,
const
VarBranch
& vb);
145
MeritAFCSize
(
Space
& home,
bool
shared
,
MeritAFCSize
& m);
147
double
operator ()
(
const
Space
& home,
View
x
,
int
i
);
149
bool
notice
(
void
)
const
;
151
void
dispose
(
Space
& home);
152
};
153
160
template
<
class
View>
161
class
MeritActivitySize
:
public
MeritBase
<View,double> {
162
protected
:
164
Activity
activity
;
165
public
:
167
MeritActivitySize
(
Space
& home,
const
VarBranch
& vb);
169
MeritActivitySize
(
Space
& home,
bool
shared
,
MeritActivitySize
& m);
171
double
operator ()
(
const
Space
& home,
View
x
,
int
i
);
173
bool
notice
(
void
)
const
;
175
void
dispose
(
Space
& home);
176
};
177
184
template
<
class
View>
185
class
MeritRegretMin
:
public
MeritBase
<View,unsigned int> {
186
public
:
188
MeritRegretMin
(
Space
& home,
const
VarBranch
& vb);
190
MeritRegretMin
(
Space
& home,
bool
shared
,
MeritRegretMin
& m);
192
unsigned
int
operator ()
(
const
Space
& home,
View
x
,
int
i
);
193
};
194
201
template
<
class
View>
202
class
MeritRegretMax
:
public
MeritBase
<View,unsigned int> {
203
public
:
205
MeritRegretMax
(
Space
& home,
const
VarBranch
& vb);
207
MeritRegretMax
(
Space
& home,
bool
shared
,
MeritRegretMax
& m);
209
unsigned
int
operator ()
(
const
Space
& home,
View
x
,
int
i
);
210
};
211
212
}}}
213
214
#include <
gecode/int/branch/merit.hpp
>
215
216
namespace
Gecode {
namespace
Int {
namespace
Branch {
217
219
GECODE_INT_EXPORT
220
ViewSel<IntView>*
viewselint
(Space& home,
const
IntVarBranch& ivb);
222
GECODE_INT_EXPORT
223
ViewSel<BoolView>*
viewselbool
(Space& home,
const
IntVarBranch& ivb);
224
225
}}}
226
227
namespace
Gecode {
namespace
Int {
namespace
Branch {
228
247
template
<
class
View>
248
class
ValSelMin
:
public
ValSel
<View,int> {
249
public
:
251
ValSelMin
(
Space
& home,
const
ValBranch
& vb);
253
ValSelMin
(
Space
& home,
bool
shared
,
ValSelMin
& vs);
255
int
val
(
const
Space
& home,
View
x
,
int
i
);
256
};
257
264
template
<
class
View>
265
class
ValSelMax
:
public
ValSel
<View,int> {
266
public
:
268
ValSelMax
(
Space
& home,
const
ValBranch
& vb);
270
ValSelMax
(
Space
& home,
bool
shared
,
ValSelMax
& vs);
272
int
val
(
const
Space
& home,
View
x
,
int
i
);
273
};
274
281
template
<
class
View>
282
class
ValSelMed
:
public
ValSel
<View,int> {
283
public
:
285
ValSelMed
(
Space
& home,
const
ValBranch
& vb);
287
ValSelMed
(
Space
& home,
bool
shared
,
ValSelMed
& vs);
289
int
val
(
const
Space
& home,
View
x
,
int
i
);
290
};
291
298
template
<
class
View>
299
class
ValSelAvg
:
public
ValSel
<View,int> {
300
public
:
302
ValSelAvg
(
Space
& home,
const
ValBranch
& vb);
304
ValSelAvg
(
Space
& home,
bool
shared
,
ValSelAvg
& vs);
306
int
val
(
const
Space
& home,
View
x
,
int
i
);
307
};
308
315
template
<
class
View>
316
class
ValSelRnd
:
public
ValSel
<View,int> {
317
protected
:
319
Rnd
r
;
320
public
:
322
ValSelRnd
(
Space
& home,
const
ValBranch
& vb);
324
ValSelRnd
(
Space
& home,
bool
shared
,
ValSelRnd
& vs);
326
int
val
(
const
Space
& home,
View
x
,
int
i
);
328
bool
notice
(
void
)
const
;
330
void
dispose
(
Space
& home);
331
};
332
339
class
ValSelRangeMin
:
public
ValSel
<IntView,int> {
340
public
:
342
ValSelRangeMin
(
Space
& home,
const
ValBranch
& vb);
344
ValSelRangeMin
(
Space
& home,
bool
shared
,
ValSelRangeMin
& vs);
346
int
val
(
const
Space
& home,
IntView
x
,
int
i
);
347
};
348
355
class
ValSelRangeMax
:
public
ValSel
<IntView,int> {
356
public
:
358
ValSelRangeMax
(
Space
& home,
const
ValBranch
& vb);
360
ValSelRangeMax
(
Space
& home,
bool
shared
,
ValSelRangeMax
& vs);
362
int
val
(
const
Space
& home,
IntView
x
,
int
i
);
363
};
364
371
template
<
class
View,
bool
min>
372
class
ValSelNearMinMax
:
public
ValSel
<View,int> {
373
protected
:
375
IntSharedArray
c
;
376
public
:
378
ValSelNearMinMax
(
Space
& home,
const
ValBranch
& vb);
380
ValSelNearMinMax
(
Space
& home,
bool
shared
,
ValSelNearMinMax
& vs);
382
int
val
(
const
Space
& home,
View
x
,
int
i
);
384
bool
notice
(
void
)
const
;
386
void
dispose
(
Space
& home);
387
};
388
395
template
<
class
View,
bool
inc>
396
class
ValSelNearIncDec
:
public
ValSel
<View,int> {
397
protected
:
399
IntSharedArray
c
;
400
public
:
402
ValSelNearIncDec
(
Space
& home,
const
ValBranch
& vb);
404
ValSelNearIncDec
(
Space
& home,
bool
shared
,
ValSelNearIncDec
& vs);
406
int
val
(
const
Space
& home,
View
x
,
int
i
);
408
bool
notice
(
void
)
const
;
410
void
dispose
(
Space
& home);
411
};
412
413
}}}
414
415
#include <
gecode/int/branch/val-sel.hpp
>
416
417
namespace
Gecode {
namespace
Int {
namespace
Branch {
418
420
template
<
class
View>
421
class
EqNGL
:
public
ViewValNGL
<View,int,PC_INT_VAL> {
422
using
ViewValNGL<View,int,PC_INT_VAL>::x
;
423
using
ViewValNGL<View,int,PC_INT_VAL>::n
;
424
public
:
426
EqNGL
(
Space
& home, View
x
,
int
n
);
428
EqNGL
(
Space
& home,
bool
share,
EqNGL
& ngl);
430
virtual
NGL::Status
status
(
const
Space
& home)
const
;
432
virtual
ExecStatus
prune
(
Space
& home);
434
virtual
NGL
*
copy
(
Space
& home,
bool
share);
435
};
436
438
template
<
class
View>
439
class
NqNGL
:
public
ViewValNGL
<View,int,PC_INT_DOM> {
440
using
ViewValNGL<View,int,PC_INT_DOM>::x
;
441
using
ViewValNGL<View,int,PC_INT_DOM>::n
;
442
public
:
444
NqNGL
(
Space
& home, View
x
,
int
n
);
446
NqNGL
(
Space
& home,
bool
share,
NqNGL
& ngl);
448
virtual
NGL::Status
status
(
const
Space
& home)
const
;
450
virtual
ExecStatus
prune
(
Space
& home);
452
virtual
NGL
*
copy
(
Space
& home,
bool
share);
453
};
454
456
template
<
class
View>
457
class
LqNGL
:
public
ViewValNGL
<View,int,PC_INT_BND> {
458
using
ViewValNGL<View,int,PC_INT_BND>::x
;
459
using
ViewValNGL<View,int,PC_INT_BND>::n
;
460
public
:
462
LqNGL
(
Space
& home, View
x
,
int
n
);
464
LqNGL
(
Space
& home,
bool
share,
LqNGL
& ngl);
466
virtual
NGL::Status
status
(
const
Space
& home)
const
;
468
virtual
ExecStatus
prune
(
Space
& home);
470
virtual
NGL
*
copy
(
Space
& home,
bool
share);
471
};
472
474
template
<
class
View>
475
class
GqNGL
:
public
ViewValNGL
<View,int,PC_INT_BND> {
476
using
ViewValNGL<View,int,PC_INT_BND>::x
;
477
using
ViewValNGL<View,int,PC_INT_BND>::n
;
478
public
:
480
GqNGL
(
Space
& home, View
x
,
int
n
);
482
GqNGL
(
Space
& home,
bool
share,
GqNGL
& ngl);
484
virtual
NGL::Status
status
(
const
Space
& home)
const
;
486
virtual
ExecStatus
prune
(
Space
& home);
488
virtual
NGL
*
copy
(
Space
& home,
bool
share);
489
};
490
491
}}}
492
493
#include <
gecode/int/branch/ngl.hpp
>
494
495
namespace
Gecode {
namespace
Int {
namespace
Branch {
496
515
template
<
class
View>
516
class
ValCommitEq
:
public
ValCommit
<View,int> {
517
public
:
519
ValCommitEq
(
Space
& home,
const
ValBranch
& vb);
521
ValCommitEq
(
Space
& home,
bool
shared
,
ValCommitEq
& vc);
523
ModEvent
commit
(
Space
& home,
unsigned
int
a
,
View
x
,
int
i
,
int
n
);
525
NGL
*
ngl
(
Space
& home,
unsigned
int
a,
View
x,
int
n)
const
;
527
void
print
(
const
Space
& home,
unsigned
int
a,
View
x,
int
i,
int
n,
528
std::ostream& o)
const
;
529
};
530
537
template
<
class
View>
538
class
ValCommitLq
:
public
ValCommit
<View,int> {
539
public
:
541
ValCommitLq
(
Space
& home,
const
ValBranch
& vb);
543
ValCommitLq
(
Space
& home,
bool
shared
,
ValCommitLq
& vc);
545
ModEvent
commit
(
Space
& home,
unsigned
int
a
,
View
x
,
int
i
,
int
n
);
547
NGL
*
ngl
(
Space
& home,
unsigned
int
a,
View
x,
int
n)
const
;
549
void
print
(
const
Space
& home,
unsigned
int
a,
View
x,
int
i,
int
n,
550
std::ostream& o)
const
;
551
};
552
559
template
<
class
View>
560
class
ValCommitGq
:
public
ValCommit
<View,int> {
561
public
:
563
ValCommitGq
(
Space
& home,
const
ValBranch
& vb);
565
ValCommitGq
(
Space
& home,
bool
shared
,
ValCommitGq
& vc);
567
ModEvent
commit
(
Space
& home,
unsigned
int
a
,
View
x
,
int
i
,
int
n
);
569
NGL
*
ngl
(
Space
& home,
unsigned
int
a,
View
x,
int
n)
const
;
571
void
print
(
const
Space
& home,
unsigned
int
a,
View
x,
int
i,
int
n,
572
std::ostream& o)
const
;
573
};
574
581
template
<
class
View>
582
class
ValCommitGr
:
public
ValCommit
<View,int> {
583
public
:
585
ValCommitGr
(
Space
& home,
const
ValBranch
& vb);
587
ValCommitGr
(
Space
& home,
bool
shared
,
ValCommitGr
& vc);
589
ModEvent
commit
(
Space
& home,
unsigned
int
a
,
View
x
,
int
i
,
int
n
);
591
NGL
*
ngl
(
Space
& home,
unsigned
int
a,
View
x,
int
n)
const
;
593
void
print
(
const
Space
& home,
unsigned
int
a,
View
x,
int
i,
int
n,
594
std::ostream& o)
const
;
595
};
596
597
}}}
598
599
#include <
gecode/int/branch/val-commit.hpp
>
600
601
namespace
Gecode {
namespace
Int {
namespace
Branch {
602
604
GECODE_INT_EXPORT
605
ValSelCommitBase<IntView,int>*
606
valselcommitint
(Space& home,
int
n
,
const
IntValBranch& ivb);
607
609
GECODE_INT_EXPORT
610
ValSelCommitBase<BoolView,int>*
611
valselcommitbool
(Space& home,
int
n
,
const
IntValBranch& ivb);
612
614
GECODE_INT_EXPORT
615
ValSelCommitBase<IntView,int>*
616
valselcommitint
(Space& home,
const
IntAssign& ia);
617
619
GECODE_INT_EXPORT
620
ValSelCommitBase<BoolView,int>*
621
valselcommitbool
(Space& home,
const
IntAssign& ia);
622
623
}}}
624
625
namespace
Gecode {
namespace
Int {
namespace
Branch {
626
631
template
<
int
n,
bool
min>
632
class
ViewValuesBrancher
:
public
ViewBrancher
<IntView,n> {
633
typedef
typename
ViewBrancher<IntView,n>::BranchFilter
BranchFilter;
634
protected
:
635
using
ViewBrancher<IntView,n>::x
;
637
IntVarValPrint
vvp
;
639
ViewValuesBrancher
(
Space
& home,
bool
shared
,
ViewValuesBrancher
&
b
);
641
ViewValuesBrancher
(
Home
home,
ViewArray<IntView>
&
x
,
642
ViewSel<IntView>
*
vs
[
n
],
643
BranchFilter
bf
,
IntVarValPrint
vvp
);
644
public
:
646
virtual
const
Choice
*
choice
(
Space
& home);
648
virtual
const
Choice
*
choice
(
const
Space
& home,
Archive
& e);
650
virtual
ExecStatus
commit
(
Space
& home,
const
Choice
&
c
,
unsigned
int
a
);
652
virtual
NGL
*
ngl
(
Space
& home,
const
Choice
&
c
,
unsigned
int
a
)
const
;
660
virtual
void
print
(
const
Space
& home,
const
Choice
&
c
,
unsigned
int
a
,
661
std::ostream& o)
const
;
663
virtual
Actor
*
copy
(
Space
& home,
bool
share);
665
static
BrancherHandle
post
(
Home
home,
ViewArray<IntView>
&
x
,
666
ViewSel<IntView>
*
vs
[
n
],
667
BranchFilter
bf
,
IntVarValPrint
vvp
);
668
};
669
670
}}}
671
672
#include <
gecode/int/branch/view-values.hpp
>
673
674
#endif
675
676
// STATISTICS: int-branch