main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Jul 27 2020 00:00:00 for Gecode by
doxygen
1.8.18
gecode
int
unary
not-first-not-last.hpp
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, 2009
8
*
9
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
#include <algorithm>
35
36
namespace
Gecode
{
namespace
Int {
namespace
Unary {
37
38
template
<
class
ManTaskView>
39
forceinline
ExecStatus
40
notlast
(
Space
& home,
TaskViewArray<ManTaskView>
&
t
) {
41
sort<ManTaskView,STO_LCT,true>(
t
);
42
43
Region
r
;
44
45
OmegaTree<ManTaskView>
o(
r
,
t
);
46
TaskViewIter<ManTaskView,STO_LST,true>
q(
r
,
t
);
47
int
* lct =
r
.alloc<
int
>(
t
.size());
48
49
for
(
int
i
=0;
i
<
t
.size();
i
++)
50
lct[
i
] =
t
[
i
].lct();
51
52
for
(
int
i
=0;
i
<
t
.size();
i
++) {
53
int
j = -1;
54
while
(q() && (
t
[
i
].lct() >
t
[q.
task
()].lst())) {
55
if
((j >= 0) && (o.
ect
() >
t
[q.
task
()].lst()))
56
lct[q.
task
()] =
std::min
(lct[q.
task
()],
t
[j].lst());
57
j = q.
task
();
58
o.
insert
(j); ++q;
59
}
60
if
((j >= 0) && (o.
ect
(
i
) >
t
[
i
].lst()))
61
lct[
i
] =
std::min
(lct[
i
],
t
[j].lst());
62
}
63
64
for
(
int
i
=0;
i
<
t
.size();
i
++)
65
GECODE_ME_CHECK
(
t
[
i
].lct(home,lct[
i
]));
66
67
return
ES_OK
;
68
}
69
70
template
<
class
ManTask>
71
ExecStatus
72
notfirstnotlast
(
Space
& home,
TaskArray<ManTask>
&
t
) {
73
TaskViewArray<typename TaskTraits<ManTask>::TaskViewFwd
>
f
(
t
);
74
GECODE_ES_CHECK
(
notlast
(home,
f
));
75
TaskViewArray<typename TaskTraits<ManTask>::TaskViewBwd
>
b
(
t
);
76
return
notlast
(home,
b
);
77
}
78
79
template
<
class
OptTaskView,
class
PL>
80
forceinline
ExecStatus
81
notlast
(
Space
& home,
Propagator
&
p
,
TaskViewArray<OptTaskView>
&
t
) {
82
sort<OptTaskView,STO_LCT,true>(
t
);
83
84
Region
r
;
85
86
OmegaTree<OptTaskView>
o(
r
,
t
);
87
ManTaskViewIter<OptTaskView,STO_LST,true>
q(
r
,
t
);
88
int
* lct =
r
.alloc<
int
>(
t
.size());
89
90
for
(
int
i
=0;
i
<
t
.size();
i
++)
91
lct[
i
] =
t
[
i
].lct();
92
93
for
(
int
i
=0;
i
<
t
.size();
i
++) {
94
int
j = -1;
95
while
(q() && (
t
[
i
].lct() >
t
[q.
task
()].lst())) {
96
if
((j >= 0) && (o.
ect
() >
t
[q.
task
()].lst()))
97
lct[q.
task
()] =
std::min
(lct[q.
task
()],
t
[j].lst());
98
j = q.
task
();
99
o.
insert
(j); ++q;
100
}
101
if
((j >= 0) && (o.
ect
(
i
) >
t
[
i
].lst()))
102
lct[
i
] =
std::min
(lct[
i
],
t
[j].lst());
103
}
104
105
{
106
int
n
=
t
.size();
107
for
(
int
i
=
n
;
i
--; )
108
if
(
t
[
i
].mandatory()) {
109
GECODE_ME_CHECK
(
t
[
i
].lct(home,lct[
i
]));
110
}
else
if
(lct[
i
] <
t
[
i
].ect()) {
111
GECODE_ME_CHECK
(
t
[
i
].excluded(home));
112
t
[
i
].cancel(home,
p
,PL::pc);
t
[
i
]=
t
[--
n
];
113
}
114
t
.size(
n
);
115
}
116
117
return
(
t
.size() < 2) ? home.
ES_SUBSUMED
(
p
) :
ES_OK
;
118
}
119
120
template
<
class
OptTask,
class
PL>
121
ExecStatus
122
notfirstnotlast
(
Space
& home,
Propagator
&
p
,
TaskArray<OptTask>
&
t
) {
123
TaskViewArray<typename TaskTraits<OptTask>::TaskViewFwd
>
f
(
t
);
124
GECODE_ES_CHECK
((
notlast
<
typename
TaskTraits<OptTask>::TaskViewFwd
,PL>
125
(home,
p
,
f
)));
126
TaskViewArray<typename TaskTraits<OptTask>::TaskViewBwd
>
b
(
t
);
127
return
notlast<typename TaskTraits<OptTask>::TaskViewBwd,PL>(home,
p
,
b
);
128
}
129
130
}}}
131
132
// STATISTICS: int-prop
Gecode::Space::ES_SUBSUMED
ExecStatus ES_SUBSUMED(Propagator &p)
Definition:
core.hpp:3563
t
NodeType t
Type of node.
Definition:
bool-expr.cpp:230
Gecode::Float::Limits::min
const FloatNum min
Smallest allowed float value.
Definition:
float.hh:846
Gecode::Int::ManTaskViewIter
Allows to iterate over mandatory task views according to a specified order.
Definition:
task.hh:339
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Int::Unary::OmegaTree::insert
void insert(int i)
Insert task with index i.
Definition:
tree.hpp:65
Gecode::Int::TaskTraits
Traits class for mapping tasks to task views.
Definition:
task.hh:157
Gecode
Gecode toplevel namespace
Gecode::Propagator
Base-class for propagators.
Definition:
core.hpp:1064
GECODE_ES_CHECK
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Definition:
macros.hpp:91
Gecode::Region
Handle to region.
Definition:
region.hpp:55
Gecode::r
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition:
set.hh:767
Gecode::Int::TaskViewIter::task
int task(void) const
Return current task position.
Definition:
iter.hpp:68
b
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Gecode::Int::Unary::notlast
ExecStatus notlast(Space &home, TaskViewArray< ManTaskView > &t)
Definition:
not-first-not-last.hpp:40
Gecode::Int::Unary::OmegaTree
Omega trees for computing ect of task sets.
Definition:
unary.hh:674
Gecode::Int::TaskArray< ManTask >
Gecode::Int::Unary::OmegaTree::ect
int ect(void) const
Return earliest completion time of all tasks.
Definition:
tree.hpp:80
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Int::Unary::notfirstnotlast
ExecStatus notfirstnotlast(Space &home, TaskArray< ManTask > &t)
Propagate not-first and not-last.
Definition:
not-first-not-last.hpp:72
Gecode::Int::TaskViewArray
Task view array.
Definition:
task.hh:233
GECODE_ME_CHECK
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition:
macros.hpp:52
Gecode::f
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::ES_OK
@ ES_OK
Execution is okay.
Definition:
core.hpp:476
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:232
Gecode::Int::TaskViewIter
Allows to iterate over task views according to a specified order.
Definition:
task.hh:309
Gecode::ExecStatus
ExecStatus
Definition:
core.hpp:472