main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Sep 17 2012 22:20:37 for Gecode by
doxygen
1.8.1.1
gecode
int
count.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
* Guido Tack <tack@gecode.org>
6
*
7
* Copyright:
8
* Christian Schulte, 2002
9
* Guido Tack, 2004
10
*
11
* Last modified:
12
* $Date: 2011-09-20 21:58:39 +1000 (Tue, 20 Sep 2011) $ by $Author: schulte $
13
* $Revision: 12404 $
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
#ifndef __GECODE_INT_COUNT_HH__
41
#define __GECODE_INT_COUNT_HH__
42
43
#include <
gecode/int.hh
>
44
50
namespace
Gecode {
namespace
Int {
namespace
Count {
51
57
58
enum
ViewTypeDesc
{
59
VTD_CONSTVIEW
,
60
VTD_INTSET
,
61
VTD_VARVIEW
62
};
64
template
<
class
VY>
65
ViewTypeDesc
vtd
(VY y);
66
68
template
<
class
VY>
69
void
subscribe
(
Space
& home,
Propagator
& p, VY y);
71
template
<
class
VY>
72
void
cancel
(
Space
& home,
Propagator
& p, VY y);
73
75
template
<
class
VX>
76
RelTest
holds
(VX x, VX y);
78
template
<
class
VX>
79
RelTest
holds
(VX x,
ConstIntView
y);
81
template
<
class
VX>
82
RelTest
holds
(VX x,
ZeroIntView
y);
84
template
<
class
VX>
85
RelTest
holds
(VX x,
const
IntSet
& y);
86
88
template
<
class
VX>
89
ExecStatus
post_true
(
Home
home,
ViewArray<VX>
& x, VX y);
91
template
<
class
VX>
92
ExecStatus
post_true
(
Home
home,
ViewArray<VX>
& x,
ConstIntView
y);
94
template
<
class
VX>
95
ExecStatus
post_true
(
Home
home,
ViewArray<VX>
& x,
ZeroIntView
y);
97
template
<
class
VX>
98
ExecStatus
post_true
(
Home
home,
ViewArray<VX>
& x,
const
IntSet
& y);
99
101
template
<
class
VX>
102
ExecStatus
post_false
(
Home
home,
ViewArray<VX>
& x, VX y);
104
template
<
class
VX>
105
ExecStatus
post_false
(
Home
home,
ViewArray<VX>
& x,
ConstIntView
y);
107
template
<
class
VX>
108
ExecStatus
post_false
(
Home
home,
ViewArray<VX>
& x,
ZeroIntView
y);
110
template
<
class
VX>
111
ExecStatus
post_false
(
Home
home,
ViewArray<VX>
& x,
const
IntSet
& y);
112
114
template
<
class
VX>
115
ExecStatus
prune
(
Home
home,
ViewArray<VX>
& x, VX y);
117
template
<
class
VX>
118
ExecStatus
prune
(
Home
home,
ViewArray<VX>
& x,
ConstIntView
y);
120
template
<
class
VX>
121
ExecStatus
prune
(
Home
home,
ViewArray<VX>
& x,
ZeroIntView
y);
123
template
<
class
VX>
124
ExecStatus
prune
(
Home
home,
ViewArray<VX>
& x,
const
IntSet
& y);
126
127
}}}
128
129
#include <
gecode/int/count/rel.hpp
>
130
131
132
namespace
Gecode {
namespace
Int {
namespace
Count {
133
138
template
<
class
VX,
class
VY>
139
class
IntBase
:
public
Propagator
{
140
protected
:
142
ViewArray<VX>
x
;
144
int
n_s
;
146
VY
y
;
148
int
c
;
150
IntBase
(
Space
& home,
bool
share,
IntBase
& p);
152
IntBase
(
Home
home,
ViewArray<VX>
&
x
,
int
n_s
, VY
y
,
int
c
);
153
public
:
155
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
157
virtual
size_t
dispose
(
Space
& home);
158
};
159
170
template
<
class
VX,
class
VY>
171
class
EqInt
:
public
IntBase
<VX,VY> {
172
protected
:
173
using
IntBase<VX,VY>::x
;
174
using
IntBase<VX,VY>::n_s
;
175
using
IntBase<VX,VY>::y
;
176
using
IntBase<VX,VY>::c
;
178
EqInt
(
Space
& home,
bool
share,
EqInt
& p);
180
EqInt
(
Home
home,
ViewArray<VX>
&
x
,
int
n_s
, VY
y
,
int
c
);
181
public
:
183
virtual
Actor
*
copy
(
Space
& home,
bool
share);
185
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
187
static
ExecStatus
post
(
Home
home,
ViewArray<VX>
& x, VY y,
int
c);
188
};
189
200
template
<
class
VX,
class
VY>
201
class
GqInt
:
public
IntBase
<VX,VY> {
202
protected
:
203
using
IntBase<VX,VY>::x
;
204
using
IntBase<VX,VY>::n_s
;
205
using
IntBase<VX,VY>::y
;
206
using
IntBase<VX,VY>::c
;
208
GqInt
(
Space
& home,
bool
share,
GqInt
& p);
210
GqInt
(
Home
home,
ViewArray<VX>
&
x
,
int
n_s
, VY
y
,
int
c
);
211
public
:
213
virtual
Actor
*
copy
(
Space
& home,
bool
share);
215
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
217
static
ExecStatus
post
(
Home
home,
ViewArray<VX>
& x, VY y,
int
c);
218
};
219
230
template
<
class
VX,
class
VY>
231
class
LqInt
:
public
IntBase
<VX,VY> {
232
protected
:
233
using
IntBase<VX,VY>::x
;
234
using
IntBase<VX,VY>::n_s
;
235
using
IntBase<VX,VY>::y
;
236
using
IntBase<VX,VY>::c
;
238
LqInt
(
Space
& home,
bool
share,
LqInt
& p);
240
LqInt
(
Home
home,
ViewArray<VX>
&
x
,
int
n_s
, VY
y
,
int
c
);
241
public
:
243
virtual
Actor
*
copy
(
Space
& home,
bool
share);
245
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
247
static
ExecStatus
post
(
Home
home,
ViewArray<VX>
& x, VY y,
int
c);
248
};
249
250
}}}
251
252
#include <
gecode/int/count/int-base.hpp
>
253
#include <
gecode/int/count/int-eq.hpp
>
254
#include <
gecode/int/count/int-gq.hpp
>
255
#include <
gecode/int/count/int-lq.hpp
>
256
257
258
namespace
Gecode {
namespace
Int {
namespace
Count {
259
264
template
<
class
VX,
class
VY,
class
VZ>
265
class
ViewBase
:
public
Propagator
{
266
protected
:
268
ViewArray<VX>
x
;
270
VY
y
;
272
VZ
z
;
274
int
c
;
276
ViewBase
(
Space
& home,
bool
share,
ViewBase
& p);
278
ViewBase
(
Home
home,
ViewArray<VX>
&
x
, VY
y
, VZ
z
,
int
c
);
279
public
:
281
virtual
size_t
dispose
(
Space
& home);
283
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
284
protected
:
286
void
count
(
Space
& home);
288
int
atleast
(
void
)
const
;
290
int
atmost
(
void
)
const
;
292
static
bool
sharing
(
const
ViewArray<VX>
&
x
,
const
VY&
y
,
const
VZ&
z
);
293
};
294
305
template
<
class
VX,
class
VY,
class
VZ,
bool
shr,
bool
dom>
306
class
EqView
:
public
ViewBase
<VX,VY,VZ> {
307
protected
:
308
using
ViewBase<VX,VY,VZ>::x
;
309
using
ViewBase<VX,VY,VZ>::z
;
310
using
ViewBase<VX,VY,VZ>::c
;
311
using
ViewBase<VX,VY,VZ>::y
;
312
using
ViewBase<VX,VY,VZ>::count
;
313
using
ViewBase<VX,VY,VZ>::atleast
;
314
using
ViewBase<VX,VY,VZ>::atmost
;
315
using
ViewBase<VX,VY,VZ>::sharing
;
316
318
EqView
(
Space
& home,
bool
share,
EqView
& p);
319
public
:
321
EqView
(
Home
home,
ViewArray<VX>
&
x
, VY
y
, VZ
z
,
int
c
);
323
virtual
Actor
*
copy
(
Space
& home,
bool
share);
325
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
327
static
ExecStatus
post
(
Home
home,
ViewArray<VX>
& x, VY y, VZ z,
int
c);
328
};
329
340
template
<
class
VX,
class
VY,
class
VZ,
bool
shr>
341
class
LqView
:
public
ViewBase
<VX,VY,VZ> {
342
protected
:
343
using
ViewBase<VX,VY,VZ>::x
;
344
using
ViewBase<VX,VY,VZ>::z
;
345
using
ViewBase<VX,VY,VZ>::c
;
346
using
ViewBase<VX,VY,VZ>::y
;
347
using
ViewBase<VX,VY,VZ>::count
;
348
using
ViewBase<VX,VY,VZ>::atleast
;
349
using
ViewBase<VX,VY,VZ>::atmost
;
350
using
ViewBase<VX,VY,VZ>::sharing
;
351
353
LqView
(
Space
& home,
bool
share,
LqView
& p);
354
public
:
356
LqView
(
Home
home,
ViewArray<VX>
&
x
, VY
y
, VZ
z
,
int
c
);
358
virtual
Actor
*
copy
(
Space
& home,
bool
share);
360
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
362
static
ExecStatus
post
(
Home
home,
ViewArray<VX>
& x, VY y, VZ z,
int
c);
363
};
364
375
template
<
class
VX,
class
VY,
class
VZ,
bool
shr,
bool
dom>
376
class
GqView
:
public
ViewBase
<VX,VY,VZ> {
377
protected
:
378
using
ViewBase<VX,VY,VZ>::x
;
379
using
ViewBase<VX,VY,VZ>::z
;
380
using
ViewBase<VX,VY,VZ>::c
;
381
using
ViewBase<VX,VY,VZ>::y
;
382
using
ViewBase<VX,VY,VZ>::count
;
383
using
ViewBase<VX,VY,VZ>::atleast
;
384
using
ViewBase<VX,VY,VZ>::atmost
;
385
using
ViewBase<VX,VY,VZ>::sharing
;
386
388
GqView
(
Space
& home,
bool
share,
GqView
& p);
389
public
:
391
GqView
(
Home
home,
ViewArray<VX>
&
x
, VY
y
, VZ
z
,
int
c
);
393
virtual
Actor
*
copy
(
Space
& home,
bool
share);
395
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
397
static
ExecStatus
post
(
Home
home,
ViewArray<VX>
& x, VY y, VZ z,
int
c);
398
};
399
400
}}}
401
402
#include <
gecode/int/count/view-base.hpp
>
403
#include <
gecode/int/count/view-eq.hpp
>
404
#include <
gecode/int/count/view-gq.hpp
>
405
#include <
gecode/int/count/view-lq.hpp
>
406
407
#endif
408
409
// STATISTICS: int-prop
410