main page
modules
namespaces
classes
files
Gecode home
Generated on Fri Jan 10 2020 11:38:25 for Gecode by
doxygen
1.8.16
gecode
int
trace
int-trace-view.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, 2016
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
namespace
Gecode
{
namespace
Int {
35
37
class
IntTraceView
{
38
protected
:
40
RangeList
*
dom
;
41
public
:
43
IntTraceView
(
void
);
45
IntTraceView
(
Space
& home,
IntView
y
);
47
RangeList
*
ranges
(
void
)
const
;
49
void
prune
(
Space
& home,
IntView
y
,
const
Delta
&
d
);
51
void
update
(
Space
& home,
IntTraceView
x
);
53
static
unsigned
long
long
int
slack
(
IntView
x
);
54
};
55
56
forceinline
57
IntTraceView::IntTraceView
(
void
) {}
58
59
forceinline
60
IntTraceView::IntTraceView
(
Space
& home,
IntView
y
) {
61
ViewRanges<IntView>
yr(
y
);
62
RangeList::copy
(home,
dom
, yr);
63
}
64
65
forceinline
RangeList
*
66
IntTraceView::ranges
(
void
)
const
{
67
return
dom
;
68
}
69
70
forceinline
void
71
IntTraceView::prune
(
Space
& home,
IntView
y
,
const
Delta
&
d
) {
72
if
(
y
.range() && (
dom
->
next
() == NULL)) {
73
dom
->
min
(
y
.min());
dom
->
max
(
y
.max());
74
}
else
if
(!
y
.any(
d
) && (
y
.max(
d
)+1 ==
y
.min())) {
75
// The lower bound has been adjusted
76
if
(
y
.min() >
dom
->
max
()) {
77
RangeList
*
p
=
dom
;
78
RangeList
*
l
=
p
->next();
79
while
((
l
!= NULL) && (
l
->max() <
y
.min())) {
80
p
=
l
;
l
=
l
->next();
81
}
82
dom
->
dispose
(home,
p
);
83
dom
=
l
;
84
}
85
dom
->
min
(
y
.min());
86
}
else
if
(!
y
.any(
d
) && (
y
.max()+1 ==
y
.min(
d
))) {
87
// upper bound has been adjusted
88
if
((
y
.max() <=
dom
->
max
()) && (
dom
->
next
() == NULL)) {
89
dom
->
max
(
y
.max());
90
}
else
{
91
RangeList
*
p
=
dom
;
92
RangeList
*
l
=
p
->next();
93
while
((
l
!= NULL) && (
l
->min() <=
y
.max())) {
94
p
=
l
;
l
=
l
->next();
95
}
96
p
->max(
y
.max());
97
if
(
p
->next() != NULL)
98
p
->next()->dispose(home);
99
p
->next(NULL);
100
}
101
}
else
{
102
// Just copy the domain
103
ViewRanges<IntView>
yr(
y
);
104
RangeList::overwrite
(home,
dom
,yr);
105
}
106
}
107
108
forceinline
void
109
IntTraceView::update
(
Space
& home,
IntTraceView
y
) {
110
Iter::Ranges::RangeList
yr(
y
.dom);
111
RangeList::copy
(home,
dom
,yr);
112
}
113
114
forceinline
unsigned
long
long
int
115
IntTraceView::slack
(
IntView
x
) {
116
return
x
.width()-1;
117
}
118
119
120
}}
121
122
// STATISTICS: int-trace
Gecode::Int::IntTraceView
Duplicate of an integer view.
Definition:
int-trace-view.hpp:37
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:767
Gecode::RangeList::min
int min(void) const
Return minimum.
Definition:
range-list.hpp:164
Gecode::Int::IntTraceView::ranges
RangeList * ranges(void) const
Give access to ranges.
Definition:
int-trace-view.hpp:66
Gecode::Int::IntTraceView::dom
RangeList * dom
Ranges capturing the variable domain.
Definition:
int-trace-view.hpp:40
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::RangeList::overwrite
static void overwrite(Space &home, RangeList *&r, Iter &i)
Overwrite rangelist r with ranges from range iterator i.
Definition:
range-list.hpp:228
Gecode
Gecode toplevel namespace
Gecode::Delta
Generic domain change information to be supplied to advisors.
Definition:
core.hpp:204
Gecode::RangeList::copy
static void copy(Space &home, RangeList *&r, Iter &i)
Create rangelist r from range iterator i.
Definition:
range-list.hpp:215
Gecode::Int::IntTraceView::slack
static unsigned long long int slack(IntView x)
Return slack measure.
Definition:
int-trace-view.hpp:115
Gecode::RangeList::max
int max(void) const
Return maximum.
Definition:
range-list.hpp:168
Gecode::Int::IntTraceView::prune
void prune(Space &home, IntView y, const Delta &d)
Update duplicated view from view y and modification delta d.
Definition:
int-trace-view.hpp:71
l
NNF * l
Left subtree.
Definition:
bool-expr.cpp:240
Gecode::Int::IntTraceView::IntTraceView
IntTraceView(void)
Default constructor (initializes with no view)
Definition:
int-trace-view.hpp:57
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::Int::IntTraceView::update
void update(Space &home, IntTraceView x)
Update during cloning.
Definition:
int-trace-view.hpp:109
Gecode::RangeList::dispose
void dispose(Space &home, RangeList *l)
Free memory for all elements between this and l (inclusive)
Definition:
range-list.hpp:201
Gecode::Int::IntView
Integer view for integer variables.
Definition:
view.hpp:129
Gecode::Int::ViewRanges< IntView >
Range iterator for integer variable views
Definition:
int.hpp:246
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Iter::Ranges::RangeList
Range iterator for range lists
Definition:
ranges-rangelist.hpp:44
Gecode::RangeList::next
RangeList * next(void) const
Return next element.
Definition:
range-list.hpp:141
Gecode::RangeList
Lists of ranges (intervals)
Definition:
range-list.hpp:49
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:232