Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
int.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, 2002
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
34namespace Gecode {
35
36 forceinline void
37 IntVar::_init(Space& home, int min, int max) {
38 x = new (home) Int::IntVarImp(home,min,max);
39 }
40
41 forceinline void
42 IntVar::_init(Space& home, const IntSet& ds) {
43 x = new (home) Int::IntVarImp(home,ds);
44 }
45
50 : VarImpVar<Int::IntVarImp>(y.varimp()) {}
53 : VarImpVar<Int::IntVarImp>(y.varimp()) {}
54
55 forceinline int
56 IntVar::val(void) const {
57 if (!x->assigned())
58 throw Int::ValOfUnassignedVar("IntVar::val");
59 return x->val();
60 }
61 forceinline int
62 IntVar::min(void) const {
63 return x->min();
64 }
65 forceinline int
66 IntVar::med(void) const {
67 return x->med();
68 }
69 forceinline int
70 IntVar::max(void) const {
71 return x->max();
72 }
73
74
75 forceinline unsigned int
76 IntVar::width(void) const {
77 return x->width();
78 }
79 forceinline unsigned int
80 IntVar::size(void) const {
81 return x->size();
82 }
83 forceinline unsigned int
84 IntVar::regret_min(void) const {
85 return x->regret_min();
86 }
87 forceinline unsigned int
88 IntVar::regret_max(void) const {
89 return x->regret_max();
90 }
91
92 forceinline bool
93 IntVar::range(void) const {
94 return x->range();
95 }
96 forceinline bool
97 IntVar::in(int n) const {
98 return x->in(n);
99 }
100
101 /*
102 * Range iterator
103 *
104 */
107
110 : Int::IntVarImpFwd(x.varimp()) {}
111
112 forceinline void
116
117
118 /*
119 * Value iterator
120 *
121 */
122
125
131
132 forceinline void
137
138}
139
140// STATISTICS: int-var
141
int n
Number of negative literals for node type.
Range iterator for integer variables
Definition int.hh:473
IntVarRanges(void)
Default constructor.
Definition int.hpp:106
void init(const IntVar &x)
Initialize with ranges for integer variable x.
Definition int.hpp:113
IntVarValues(void)
Default constructor.
Definition int.hpp:124
void init(const IntVar &x)
Initialize with values x.
Definition int.hpp:133
Integer variables.
Definition int.hh:371
unsigned int size(void) const
Return size (cardinality) of domain.
Definition int.hpp:80
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Definition int.hpp:88
int min(void) const
Return minimum of domain.
Definition int.hpp:62
int val(void) const
Return assigned value.
Definition int.hpp:56
IntVar(void)
Default constructor.
Definition int.hpp:47
bool in(int n) const
Test whether n is contained in domain.
Definition int.hpp:97
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition int.hpp:76
bool range(void) const
Test whether domain is a range.
Definition int.hpp:93
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Definition int.hpp:84
int med(void) const
Return median of domain (greatest element not greater than the median)
Definition int.hpp:66
int max(void) const
Return maximum of domain.
Definition int.hpp:70
Range iterator for ranges of integer variable implementation.
Definition var-imp.hpp:392
void init(const IntVarImp *x)
Initialize with ranges from variable implementation x.
Definition int.hpp:432
Integer variable implementation.
Definition var-imp.hpp:89
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition int.hpp:248
int med(void) const
Return median of domain (greatest element not greater than the median)
Definition int.cpp:46
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Definition int.hpp:268
bool in(int n) const
Test whether n is contained in domain.
Definition int.hpp:286
bool assigned(void) const
Test whether variable is assigned.
Definition int.hpp:242
int max(void) const
Return maximum of domain.
Definition int.hpp:228
int val(void) const
Return assigned value (only if assigned)
Definition int.hpp:232
unsigned int size(void) const
Return size (cardinality) of domain.
Definition int.hpp:253
int min(void) const
Return minimum of domain.
Definition int.hpp:224
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Definition int.hpp:258
bool range(void) const
Test whether domain is a range.
Definition int.hpp:238
Integer view for integer variables.
Definition view.hpp:129
Exception: Attempt to access value of unassigned variable
void init(I &i)
Initialize with values from range iterator i.
Variables as interfaces to variable implementations.
Definition var.hpp:47
VarImp * varimp(void) const
Return variable implementation of variable.
Definition var.hpp:96
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition set.hh:767
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:767
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar x
Definition set.hh:767
#define forceinline
Definition config.hpp:187