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
array.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, 2002
8
*
9
* Last modified:
10
* $Date: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
11
* $Revision: 14967 $
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.hh
>
39
40
namespace
Gecode
{
41
42
IntArgs::IntArgs
(
int
n
,
int
e0, ...) :
PrimArgArray
<int>(
n
) {
43
va_list args;
44
va_start(args, e0);
45
a
[0] = e0;
46
for
(
int
i
= 1;
i
<
n
;
i
++)
47
a
[
i
] = va_arg(args,
int
);
48
va_end(args);
49
}
50
51
IntVarArray::IntVarArray
(
Space
& home,
int
n
,
int
min
,
int
max
)
52
:
VarArray
<
IntVar
>(home,
n
) {
53
Int::Limits::check
(
min
,
"IntVarArray::IntVarArray"
);
54
Int::Limits::check
(
max
,
"IntVarArray::IntVarArray"
);
55
if
(
min
>
max
)
56
throw
Int::VariableEmptyDomain
(
"IntVarArray::IntVarArray"
);
57
for
(
int
i
=
size
();
i
--; )
58
x
[
i
]._init(home,
min
,
max
);
59
}
60
61
IntVarArray::IntVarArray
(
Space
& home,
int
n
,
const
IntSet
& s)
62
:
VarArray
<
IntVar
>(home,
n
) {
63
Int::Limits::check
(s.
min
(),
"IntVarArray::IntVarArray"
);
64
Int::Limits::check
(s.
max
(),
"IntVarArray::IntVarArray"
);
65
if
(s.
size
() == 0)
66
throw
Int::VariableEmptyDomain
(
"IntVarArray::IntVarArray"
);
67
for
(
int
i
=
size
();
i
--; )
68
x
[
i
]._init(home,s);
69
}
70
71
BoolVarArray::BoolVarArray
(
Space
& home,
int
n
,
int
min
,
int
max
)
72
:
VarArray
<
BoolVar
>(home,
n
) {
73
if
((
min
< 0) || (
max
> 1))
74
throw
Int::NotZeroOne
(
"BoolVarArray::BoolVarArray"
);
75
if
(
min
>
max
)
76
throw
Int::VariableEmptyDomain
(
"BoolVarArray::BoolVarArray"
);
77
for
(
int
i
=
size
();
i
--; )
78
x
[
i
]._init(home,
min
,
max
);
79
}
80
81
IntVarArgs::IntVarArgs
(
Space
& home,
int
n
,
int
min
,
int
max
)
82
:
VarArgArray
<
IntVar
>(
n
) {
83
Int::Limits::check
(
min
,
"IntVarArgs::IntVarArgs"
);
84
Int::Limits::check
(
max
,
"IntVarArgs::IntVarArgs"
);
85
if
(
min
>
max
)
86
throw
Int::VariableEmptyDomain
(
"IntVarArgs::IntVarArgs"
);
87
for
(
int
i
=
size
();
i
--; )
88
a
[
i
]._init(home,
min
,
max
);
89
}
90
91
IntVarArgs::IntVarArgs
(
Space
& home,
int
n
,
const
IntSet
& s)
92
:
VarArgArray
<
IntVar
>(
n
) {
93
Int::Limits::check
(s.
min
(),
"IntVarArgs::IntVarArgs"
);
94
Int::Limits::check
(s.
max
(),
"IntVarArgs::IntVarArgs"
);
95
if
(s.
size
() == 0)
96
throw
Int::VariableEmptyDomain
(
"IntVarArgs::IntVarArgs"
);
97
for
(
int
i
=
size
();
i
--; )
98
a
[
i
]._init(home,s);
99
}
100
101
BoolVarArgs::BoolVarArgs
(
Space
& home,
int
n
,
int
min
,
int
max
)
102
:
VarArgArray
<
BoolVar
>(
n
) {
103
if
((
min
< 0) || (
max
> 1))
104
throw
Int::NotZeroOne
(
"BoolVarArgs::BoolVarArgs"
);
105
if
(
min
>
max
)
106
throw
Int::VariableEmptyDomain
(
"BoolVarArgs::BoolVarArgs"
);
107
for
(
int
i
=
size
();
i
--; )
108
a
[
i
]._init(home,
min
,
max
);
109
}
110
111
}
112
113
// STATISTICS: int-post
Gecode::IntSet::min
int min(int i) const
Return minimum of range at position i.
Definition:
int-set-1.hpp:115
Gecode::max
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:53
Gecode::IntSet::max
int max(int i) const
Return maximum of range at position i.
Definition:
int-set-1.hpp:121
Gecode::PrimArgArray
Argument array for primtive types.
Definition:
array.hpp:640
int.hh
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::Int::Limits::check
void check(int n, const char *l)
Check whether n is in range, otherwise throw out of limits with information l.
Definition:
limits.hpp:50
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::VarArray< IntVar >::x
IntVar * x
Array of variables.
Definition:
array.hpp:91
Gecode::BoolVarArgs::BoolVarArgs
BoolVarArgs(void)
Allocate empty array.
Definition:
int.hh:698
Gecode::VarArray< IntVar >::size
int size(void) const
Return size of array (number of elements)
Definition:
array.hpp:985
Gecode::IntSet::size
unsigned int size(void) const
Return size (cardinality) of set.
Definition:
int-set-1.hpp:161
Gecode::IntVarArgs::IntVarArgs
IntVarArgs(void)
Allocate empty array.
Definition:
int.hh:644
Gecode::VarArray
Variable arrays
Definition:
array.hpp:52
Gecode::IntArgs::IntArgs
IntArgs(void)
Allocate empty array.
Definition:
array.hpp:46
Gecode::Int::NotZeroOne
Exception: Not 0/1 integer
Definition:
exception.hpp:55
Gecode
Gecode toplevel namespace
Gecode::IntSet
Integer sets.
Definition:
int.hh:174
a
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Gecode::BoolVar
Boolean integer variables.
Definition:
int.hh:494
Gecode::BoolVarArray::BoolVarArray
BoolVarArray(void)
Default constructor (array of size 0)
Definition:
array.hpp:96
Gecode::IntVar
Integer variables.
Definition:
int.hh:353
Gecode::Int::VariableEmptyDomain
Exception: Variable created with empty domain
Definition:
exception.hpp:63
Gecode::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:71
Gecode::IntVarArray::IntVarArray
IntVarArray(void)
Default constructor (array of size 0)
Definition:
array.hpp:80
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:238
Gecode::VarArgArray
Argument array for variables.
Definition:
array.hpp:53