main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Aug 25 2012 03:32:45 for Gecode by
doxygen
1.8.1.2
gecode
int
channel.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, 2006
8
*
9
* Last modified:
10
* $Date: 2011-07-07 19:23:22 +1000 (Thu, 07 Jul 2011) $ by $Author: schulte $
11
* $Revision: 12155 $
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_CHANNEL_HH__
39
#define __GECODE_INT_CHANNEL_HH__
40
41
#include <
gecode/int.hh
>
42
#include <
gecode/int/distinct.hh
>
43
49
namespace
Gecode {
namespace
Int {
namespace
Channel {
50
52
typedef
Support::StaticStack<int,Region>
ProcessStack
;
53
58
template
<
class
Info,
class
Offset, PropCond pc>
59
class
Base
:
public
Propagator
{
60
protected
:
62
int
n
;
64
int
n_na
;
66
Offset
ox
;
68
Offset
oy
;
70
Info*
xy
;
72
Base
(
Space
& home,
bool
share,
Base<Info,Offset,pc>
& p);
74
Base
(
Home
home,
int
n
, Info*
xy
,
Offset
&
ox
,
Offset
&
oy
);
75
public
:
77
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
79
virtual
size_t
dispose
(
Space
& home);
80
};
81
82
87
template
<
class
View>
class
ValInfo
;
88
98
template
<
class
View,
class
Offset,
bool
shared>
99
class
Val
:
public
Base
<ValInfo<View>,Offset,PC_INT_VAL> {
100
protected
:
101
using
Base<ValInfo<View>
,
Offset
,
PC_INT_VAL
>
::n
;
102
using
Base<ValInfo<View>
,
Offset
,
PC_INT_VAL
>
::n_na
;
103
using
Base<ValInfo<View>
,
Offset
,
PC_INT_VAL
>
::xy
;
104
using
Base<ValInfo<View>
,
Offset
,
PC_INT_VAL
>
::ox
;
105
using
Base<ValInfo<View>
,
Offset
,
PC_INT_VAL
>
::oy
;
107
Val
(
Space
& home,
bool
share,
Val
& p);
109
Val
(
Home
home,
int
n
,
ValInfo<View>
*
xy
,
Offset
&
ox
,
Offset
&
oy
);
110
public
:
112
virtual
Actor
*
copy
(
Space
& home,
bool
share);
114
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
116
static
ExecStatus
post
(
Home
home,
int
n,
ValInfo<View>
* xy,
117
Offset
& ox,
Offset
& oy);
118
};
119
124
template
<
class
View,
class
Offset>
class
DomInfo
;
125
135
template
<
class
View,
class
Offset,
bool
shared>
136
class
Dom
:
public
Base
<DomInfo<View,Offset>,Offset,PC_INT_DOM> {
137
protected
:
138
using
Base<DomInfo<View,Offset>
,
Offset
,
PC_INT_DOM
>
::n
;
139
using
Base<DomInfo<View,Offset>
,
Offset
,
PC_INT_DOM
>
::n_na
;
140
using
Base<DomInfo<View,Offset>
,
Offset
,
PC_INT_DOM
>
::xy
;
141
using
Base<DomInfo<View,Offset>
,
Offset
,
PC_INT_DOM
>
::ox
;
142
using
Base<DomInfo<View,Offset>
,
Offset
,
PC_INT_DOM
>
::oy
;
144
Distinct::DomCtrl<View>
dc
;
146
Dom
(
Space
& home,
bool
share,
Dom
& p);
148
Dom
(
Home
home,
int
n
,
DomInfo<View,Offset>
*
xy
,
Offset
&
ox
,
Offset
&
oy
);
149
public
:
151
virtual
Actor
*
copy
(
Space
& home,
bool
share);
158
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
160
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
162
static
ExecStatus
post
(
Home
home,
int
n
,
DomInfo<View,Offset>
*
xy
,
163
Offset
&
ox
,
Offset
&
oy
);
164
};
165
172
class
LinkSingle
:
173
public
MixBinaryPropagator
<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
174
private
:
175
using
MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x0
;
176
using
MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x1
;
177
179
LinkSingle
(
Space
& home,
bool
share,
LinkSingle
& p);
181
LinkSingle
(
Home
home,
BoolView
x0
,
IntView
x1
);
182
public
:
184
virtual
Actor
*
copy
(
Space
& home,
bool
share);
186
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
188
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
& med);
190
static
ExecStatus
post
(
Home
home,
BoolView
x0,
IntView
x1);
191
};
192
199
class
LinkMulti
:
200
public
MixNaryOnePropagator
<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM> {
201
private
:
202
using
MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::x
;
203
using
MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::y
;
205
Council<Advisor>
c;
207
static
const
int
S_NONE = 0;
209
static
const
int
S_ONE = 1;
211
static
const
int
S_RUN = 2;
213
int
status;
215
int
o;
217
LinkMulti
(
Space
& home,
bool
share,
LinkMulti
& p);
219
LinkMulti
(
Home
home,
ViewArray<BoolView>
&
x
,
IntView
y
,
int
o0);
220
public
:
222
virtual
Actor
*
copy
(
Space
& home,
bool
share);
224
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
226
virtual
ExecStatus
advise
(
Space
& home,
Advisor
&
a
,
const
Delta
&
d
);
228
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
& med);
230
GECODE_INT_EXPORT
231
static
ExecStatus
post
(
Home
home,
232
ViewArray<BoolView>
& x,
IntView
y,
int
o);
234
virtual
size_t
dispose
(
Space
& home);
235
};
236
237
}}}
238
239
#include <
gecode/int/channel/base.hpp
>
240
#include <
gecode/int/channel/val.hpp
>
241
#include <
gecode/int/channel/dom.hpp
>
242
243
#include <
gecode/int/channel/link-single.hpp
>
244
#include <
gecode/int/channel/link-multi.hpp
>
245
246
#endif
247
248
// STATISTICS: int-prop
249