Generated on Sat Jan 12 2019 20:58:51 for Gecode by doxygen 1.8.13
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 
34 namespace 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 
47  IntVar::IntVar(void) {}
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
115  }
116 
117 
118  /*
119  * Value iterator
120  *
121  */
122 
125 
128  IntVarRanges r(x);
130  }
131 
132  forceinline void
134  IntVarRanges r(x);
136  }
137 
138 }
139 
140 // STATISTICS: int-var
141 
IntVar(void)
Default constructor.
Definition: int.hpp:47
Variables as interfaces to variable implementations.
Definition: var.hpp:47
int min(void) const
Return minimum of domain.
Definition: int.hpp:224
void init(I &i)
Initialize with values from range iterator i.
bool range(void) const
Test whether domain is a range.
Definition: int.hpp:238
Int::IntVarImp * varimp(void) const
Return variable implementation of variable.
Definition: var.hpp:96
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:49
bool in(int n) const
Test whether n is contained in domain.
Definition: int.hpp:286
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Definition: int.hpp:84
#define forceinline
Definition: config.hpp:185
int med(void) const
Return median of domain (greatest element not greater than the median)
Definition: int.cpp:46
Range iterator for integer variables
Definition: int.hh:473
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:80
bool assigned(void) const
Test whether variable is assigned.
Definition: int.hpp:242
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Definition: int.hpp:268
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition: int.hpp:248
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Definition: int.hpp:258
IntVarValues(void)
Default constructor.
Definition: int.hpp:124
Int::IntVarImp * x
Pointer to variable implementation.
Definition: var.hpp:50
int val(void) const
Return assigned value.
Definition: int.hpp:56
bool range(void) const
Test whether domain is a range.
Definition: int.hpp:93
Range iterator for ranges of integer variable implementation.
Definition: var-imp.hpp:392
void init(const IntVar &x)
Initialize with ranges for integer variable x.
Definition: int.hpp:113
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 .
Definition: arithmetic.cpp:67
int max(void) const
Return maximum of domain.
Definition: int.hpp:70
Integer view for integer variables.
Definition: view.hpp:129
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
void init(const IntVar &x)
Initialize with values x.
Definition: int.hpp:133
Exception: Attempt to access value of unassigned variable
Definition: exception.hpp:122
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:76
int min(void) const
Return minimum of domain.
Definition: int.hpp:62
Integer variables.
Definition: int.hh:371
Post propagator for SetVar x
Definition: set.hh:767
unsigned int size(void) const
Return size (cardinality) of domain.
Definition: int.hpp:253
IntVarRanges(void)
Default constructor.
Definition: int.hpp:106
Gecode toplevel namespace
int med(void) const
Return median of domain (greatest element not greater than the median)
Definition: int.hpp:66
void init(const IntVarImp *x)
Initialize with ranges from variable implementation x.
Definition: int.hpp:432
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Definition: int.hpp:88
bool in(int n) const
Test whether n is contained in domain.
Definition: int.hpp:97
int max(void) const
Return maximum of domain.
Definition: int.hpp:228