main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Aug 25 2012 03:32:49 for Gecode by
doxygen
1.8.1.2
gecode
int
no-overlap.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, 2011
8
*
9
* Last modified:
10
* $Date: 2011-07-14 02:55:08 +1000 (Thu, 14 Jul 2011) $ by $Author: schulte $
11
* $Revision: 12194 $
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_NO_OVERLAP_HH__
39
#define __GECODE_INT_NO_OVERLAP_HH__
40
41
#include <
gecode/int.hh
>
42
48
namespace
Gecode {
namespace
Int {
namespace
NoOverlap {
49
53
class
FixDim
{
54
protected
:
56
IntView
c
;
58
int
s
;
60
ExecStatus
ssc
(
Space
& home,
int
n);
62
ExecStatus
lec
(
Space
& home,
int
n);
64
ExecStatus
nooverlap
(
Space
& home,
int
n,
int
m
);
65
public
:
67
FixDim
(
void
);
69
FixDim
(
IntView
c
,
int
s
);
70
72
int
ssc
(
void
)
const
;
74
int
lsc
(
void
)
const
;
76
int
sec
(
void
)
const
;
78
int
lec
(
void
)
const
;
79
81
ExecStatus
nooverlap
(
Space
& home,
FixDim
&
d
);
82
84
void
update
(
Space
& home,
bool
share,
FixDim
&
d
);
85
87
void
subscribe
(
Space
& home,
Propagator
& p);
89
void
cancel
(
Space
& home,
Propagator
& p);
90
};
91
95
class
FlexDim
{
96
protected
:
98
IntView
c0
;
100
IntView
s
;
102
IntView
c1
;
104
ExecStatus
ssc
(
Space
& home,
int
n);
106
ExecStatus
lec
(
Space
& home,
int
n);
108
ExecStatus
nooverlap
(
Space
& home,
int
n,
int
m
);
109
public
:
111
FlexDim
(
void
);
113
FlexDim
(
IntView
c0
,
IntView
s
,
IntView
c1
);
114
116
int
ssc
(
void
)
const
;
118
int
lsc
(
void
)
const
;
120
int
sec
(
void
)
const
;
122
int
lec
(
void
)
const
;
123
125
ExecStatus
nooverlap
(
Space
& home,
FlexDim
&
d
);
126
128
void
update
(
Space
& home,
bool
share,
FlexDim
&
d
);
129
131
void
subscribe
(
Space
& home,
Propagator
& p);
133
void
cancel
(
Space
& home,
Propagator
& p);
134
};
135
136
}}}
137
138
#include <
gecode/int/no-overlap/dim.hpp
>
139
140
namespace
Gecode {
namespace
Int {
namespace
NoOverlap {
141
145
template
<
class
Dim,
int
n>
146
class
ManBox
{
147
protected
:
149
Dim
d
[n];
150
public
:
152
const
Dim&
operator []
(
int
i
)
const
;
154
Dim&
operator []
(
int
i
);
156
static
int
dim
(
void
);
157
159
bool
mandatory
(
void
)
const
;
161
bool
optional
(
void
)
const
;
163
bool
excluded
(
void
)
const
;
164
166
ExecStatus
exclude
(
Space
& home);
167
169
bool
nooverlap
(
const
ManBox<Dim,n>
&
b
)
const
;
171
bool
overlap
(
const
ManBox<Dim,n>
&
b
)
const
;
172
174
ExecStatus
nooverlap
(
Space
& home,
ManBox<Dim,n>
&
b
);
175
177
void
update
(
Space
& home,
bool
share,
ManBox<Dim,n>
&
r
);
178
180
void
subscribe
(
Space
& home,
Propagator
& p);
182
void
cancel
(
Space
& home,
Propagator
& p);
183
};
184
188
template
<
class
Dim,
int
n>
189
class
OptBox
:
public
ManBox
<Dim,n> {
190
protected
:
191
using
ManBox<Dim,n>::d
;
193
BoolView
o
;
194
public
:
196
void
optional
(
BoolView
o
);
198
bool
mandatory
(
void
)
const
;
200
bool
optional
(
void
)
const
;
202
bool
excluded
(
void
)
const
;
203
205
ExecStatus
exclude
(
Space
& home);
206
208
void
update
(
Space
& home,
bool
share,
OptBox<Dim,n>
&
r
);
209
211
void
subscribe
(
Space
& home,
Propagator
& p);
213
void
cancel
(
Space
& home,
Propagator
& p);
214
};
215
216
}}}
217
218
#include <
gecode/int/no-overlap/box.hpp
>
219
220
namespace
Gecode {
namespace
Int {
namespace
NoOverlap {
221
229
template
<
class
Box>
230
class
Base
:
public
Propagator
{
231
protected
:
233
Box*
b
;
235
int
n
;
237
Base
(
Home
home, Box*
b
,
int
n
);
239
Base
(
Space
& home,
bool
share,
Base<Box>
& p,
int
m
);
245
static
int
partition
(Box*
b
,
int
i
,
int
n
);
246
public
:
248
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
250
virtual
size_t
dispose
(
Space
& home);
251
};
252
260
template
<
class
Dim,
int
d>
261
class
ManProp
:
public
Base
<ManBox<Dim,d> > {
262
protected
:
263
using
Base<ManBox<Dim,d>
>
::b
;
264
using
Base<ManBox<Dim,d>
>
::n
;
266
ManProp
(
Home
home,
ManBox<Dim,d>
*
b
,
int
n
);
268
ManProp
(
Space
& home,
bool
share,
ManProp<Dim,d>
& p);
269
public
:
271
static
ExecStatus
post
(
Home
home,
ManBox<Dim,d>
* b,
int
n);
273
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
275
virtual
Actor
*
copy
(
Space
& home,
bool
share);
277
virtual
size_t
dispose
(
Space
& home);
278
};
279
287
template
<
class
Dim,
int
d>
288
class
OptProp
:
public
Base
<OptBox<Dim,d> > {
289
protected
:
290
using
Base<OptBox<Dim,d>
>
::b
;
291
using
Base<OptBox<Dim,d>
>
::n
;
293
int
m
;
295
OptProp
(
Home
home,
OptBox<Dim,d>
*
b
,
int
n
,
int
m
);
297
OptProp
(
Space
& home,
bool
share,
OptProp<Dim,d>
& p);
298
public
:
300
static
ExecStatus
post
(
Home
home,
OptBox<Dim,d>
*
b
,
int
n
);
302
virtual
ExecStatus
propagate
(
Space
& home,
const
ModEventDelta
&
med
);
304
virtual
Actor
*
copy
(
Space
& home,
bool
share);
306
virtual
size_t
dispose
(
Space
& home);
307
};
308
309
}}}
310
311
#include <
gecode/int/no-overlap/base.hpp
>
312
#include <
gecode/int/no-overlap/man.hpp
>
313
#include <
gecode/int/no-overlap/opt.hpp
>
314
315
#endif
316
317
// STATISTICS: int-prop
318