Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
bool.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 BoolVar::_init(Space& home, int min, int max) {
38 assert((min >= 0) && (max <= 1) && (min <= max));
39 if (min > 0)
40 x = &Int::BoolVarImp::s_one;
41 else if (max == 0)
42 x = &Int::BoolVarImp::s_zero;
43 else
44 x = new (home) Int::BoolVarImp(home,0,1);
45 }
46
55
56 forceinline int
57 BoolVar::val(void) const {
58 if (!x->assigned())
59 throw Int::ValOfUnassignedVar("BoolVar::val");
60 return x->val();
61 }
62 forceinline int
63 BoolVar::min(void) const {
64 return x->min();
65 }
66 forceinline int
67 BoolVar::med(void) const {
68 return x->med();
69 }
70 forceinline int
71 BoolVar::max(void) const {
72 return x->max();
73 }
74
75
76 forceinline unsigned int
77 BoolVar::width(void) const {
78 return x->width();
79 }
80 forceinline unsigned int
81 BoolVar::size(void) const {
82 return x->size();
83 }
84 forceinline unsigned int
85 BoolVar::regret_min(void) const {
86 return x->regret_min();
87 }
88 forceinline unsigned int
89 BoolVar::regret_max(void) const {
90 return x->regret_max();
91 }
92
93 forceinline bool
94 BoolVar::range(void) const {
95 return x->range();
96 }
97 forceinline bool
98 BoolVar::in(int n) const {
99 return x->in(n);
100 }
101
102 forceinline bool
103 BoolVar::zero(void) const {
104 return x->zero();
105 }
106 forceinline bool
107 BoolVar::one(void) const {
108 return x->one();
109 }
110 forceinline bool
111 BoolVar::none(void) const {
112 return x->none();
113 }
114
115}
116
117// STATISTICS: int-var
bool one(void) const
Test whether domain is one.
Definition bool.hpp:107
unsigned int size(void) const
Return size (cardinality) of domain.
Definition bool.hpp:81
int val(void) const
Return assigned value.
Definition bool.hpp:57
bool zero(void) const
Test whether domain is zero.
Definition bool.hpp:103
int max(void) const
Return maximum of domain.
Definition bool.hpp:71
int med(void) const
Return median of domain (greatest element not greater than the median)
Definition bool.hpp:67
bool in(int n) const
Test whether n is contained in domain.
Definition bool.hpp:98
BoolVar(void)
Default constructor.
Definition bool.hpp:48
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition bool.hpp:77
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Definition bool.hpp:85
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Definition bool.hpp:89
int min(void) const
Return minimum of domain.
Definition bool.hpp:63
bool none(void) const
Test whether domain is neither zero nor one.
Definition bool.hpp:111
bool range(void) const
Test whether domain is a range.
Definition bool.hpp:94
Boolean variable implementation.
Definition var-imp.hpp:491
Boolean view for Boolean variables.
Definition view.hpp:1380
Exception: Attempt to access value of unassigned variable
Computation spaces.
Definition core.hpp:1744
Int::BoolVarImp * varimp(void) const
Definition var.hpp:96
Finite domain integers.
Gecode toplevel namespace
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:773
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
#define forceinline
Definition config.hpp:194