main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Jan 28 2020 00:00:00 for Gecode by
doxygen
1.8.17
gecode
int
branch
view-values.cpp
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, 2012
8
*
9
* Last modified:
10
* $Date: 2012-09-18 18:07:37 +0200 (Tue, 18 Sep 2012) $ by $Author: schulte $
11
* $Revision: 13101 $
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
#include <
gecode/int/branch.hh
>
39
40
namespace
Gecode
{
namespace
Int {
namespace
Branch {
41
42
PosValuesChoice::PosValuesChoice
(
const
Brancher
&
b
,
const
Pos
&
p
,
IntView
x
)
43
:
PosChoice
(
b
,
x
.
size
(),
p
),
n
(0) {
44
for
(
ViewRanges<IntView>
r
(
x
);
r
(); ++
r
)
45
n++;
46
pm =
heap
.
alloc
<PosMin>(n+1);
47
unsigned
int
w=0;
48
int
i
=0;
49
for
(
ViewRanges<IntView>
r
(
x
);
r
(); ++
r
) {
50
pm[
i
].min =
r
.min();
51
pm[
i
].pos = w;
52
w +=
r
.width();
i
++;
53
}
54
pm[
i
].pos = w;
55
}
56
57
PosValuesChoice::PosValuesChoice
(
const
Brancher
&
b
,
unsigned
int
a
,
Pos
p
,
58
Archive
& e)
59
:
PosChoice
(
b
,
a
,
p
) {
60
e >> n;
61
pm =
heap
.
alloc
<PosMin>(
n
+1);
62
for
(
unsigned
int
i
=0;
i
<
n
+1;
i
++) {
63
e >> pm[
i
].pos;
64
e >> pm[
i
].min;
65
}
66
}
67
68
size_t
69
PosValuesChoice::size
(
void
)
const
{
70
return
sizeof
(
PosValuesChoice
)+(n+1)*
sizeof
(PosMin);
71
}
72
73
PosValuesChoice::~PosValuesChoice
(
void
) {
74
heap
.
free
<PosMin>(pm,n+1);
75
}
76
77
forceinline
void
78
PosValuesChoice::archive
(
Archive
& e)
const
{
79
PosChoice::archive
(e);
80
e << this->
alternatives
() << n;
81
for
(
unsigned
int
i
=0;
i
<
n
+1;
i
++) {
82
e << pm[
i
].pos;
83
e << pm[
i
].min;
84
}
85
}
86
87
}}}
88
89
// STATISTICS: int-branch
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:784
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::Int::Branch::PosValuesChoice::size
virtual size_t size(void) const
Report size occupied.
Definition:
view-values.cpp:69
Gecode::Choice::alternatives
unsigned int alternatives(void) const
Return number of alternatives.
Definition:
core.hpp:3821
Gecode::Iter::Ranges::size
unsigned int size(I &i)
Size of all ranges of range iterator i.
Definition:
ranges-operations.hpp:78
Test::Int::Basic::i
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::Archive
Archive representation
Definition:
archive.hpp:45
Gecode::PosChoice::archive
virtual void archive(Archive &e) const
Archive into e.
Definition:
brancher-view.hpp:133
Gecode::Heap::alloc
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
Definition:
heap.hpp:435
Gecode
Gecode toplevel namespace
Gecode::PosChoice
Choices storing position
Definition:
brancher-view.hpp:57
Gecode::Brancher
Base-class for branchers.
Definition:
core.hpp:1446
a
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Gecode::Int::Branch::PosValuesChoice::archive
virtual void archive(Archive &e) const
Archive into e.
Definition:
view-values.cpp:78
b
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
Gecode::r
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition:
set.hh:784
branch.hh
Gecode::heap
Heap heap
The single global heap.
Definition:
heap.cpp:48
Gecode::Heap::free
void free(T *b, long unsigned int n)
Delete n objects starting at b.
Definition:
heap.hpp:461
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:236
Gecode::Int::Branch::PosValuesChoice::~PosValuesChoice
virtual ~PosValuesChoice(void)
Deallocate.
Definition:
view-values.cpp:73
Gecode::Int::Branch::PosValuesChoice::PosValuesChoice
PosValuesChoice(const Brancher &b, const Pos &p, IntView x)
Initialize choice for brancher b, position p, and view x.
Definition:
view-values.cpp:42
Gecode::Pos
Position information.
Definition:
brancher-view.hpp:48
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:238
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:236