float.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 namespace Gecode { namespace Float {
00042
00043
00044
00045
00046
00047
00048 forceinline
00049 FloatVarImp::FloatVarImp(Space& home, const FloatVal& d)
00050 : FloatVarImpBase(home), dom(d) {}
00051
00052 forceinline
00053 FloatVarImp::FloatVarImp(Space& home, FloatVarImp& x)
00054 : FloatVarImpBase(home, x), dom(x.dom) {}
00055
00056
00057
00058
00059
00060
00061
00062 forceinline FloatVal
00063 FloatVarImp::domain(void) const {
00064 return dom;
00065 }
00066 forceinline FloatNum
00067 FloatVarImp::min(void) const {
00068 return dom.min();
00069 }
00070 forceinline FloatNum
00071 FloatVarImp::max(void) const {
00072 return dom.max();
00073 }
00074 forceinline FloatVal
00075 FloatVarImp::val(void) const {
00076 return dom;
00077 }
00078 forceinline FloatNum
00079 FloatVarImp::med(void) const {
00080 return dom.med();
00081 }
00082
00083 forceinline bool
00084 FloatVarImp::assigned(void) const {
00085 return dom.tight();
00086 }
00087
00088 forceinline FloatNum
00089 FloatVarImp::size(void) const {
00090 return dom.size();
00091 }
00092
00093
00094
00095
00096
00097
00098
00099 forceinline bool
00100 FloatVarImp::zero_in(void) const {
00101 return dom.zero_in();
00102 }
00103 forceinline bool
00104 FloatVarImp::in(FloatNum n) const {
00105 return dom.in(n);
00106 }
00107 forceinline bool
00108 FloatVarImp::in(const FloatVal& n) const {
00109 return subset(n,dom);
00110 }
00111
00112
00113
00114
00115
00116
00117 forceinline FloatNum
00118 FloatVarImp::min(const Delta& d) {
00119 return static_cast<const FloatDelta&>(d).min();
00120 }
00121 forceinline FloatNum
00122 FloatVarImp::max(const Delta& d) {
00123 return static_cast<const FloatDelta&>(d).max();
00124 }
00125
00126
00127
00128
00129
00130
00131
00132 forceinline ModEvent
00133 FloatVarImp::gq(Space& home, FloatNum n) {
00134 if (n > dom.max()) return fail(home);
00135 if ((n <= dom.min()) || assigned()) return ME_FLOAT_NONE;
00136 FloatDelta d(dom.min(),n);
00137 ModEvent me = ME_FLOAT_BND;
00138 dom = intersect(dom,FloatVal(n,dom.max()));
00139 if (assigned()) me = ME_FLOAT_VAL;
00140 GECODE_ASSUME((me == ME_FLOAT_VAL) |
00141 (me == ME_FLOAT_BND));
00142 return notify(home,me,d);
00143 }
00144 forceinline ModEvent
00145 FloatVarImp::gq(Space& home, const FloatVal& n) {
00146 if (n.min() > dom.max()) return fail(home);
00147 if ((n.min() <= dom.min()) || assigned()) return ME_FLOAT_NONE;
00148 FloatDelta d(dom.min(),n.min());
00149 ModEvent me = ME_FLOAT_BND;
00150 dom = intersect(dom,FloatVal(n.min(),dom.max()));
00151 if (assigned()) me = ME_FLOAT_VAL;
00152 GECODE_ASSUME((me == ME_FLOAT_VAL) |
00153 (me == ME_FLOAT_BND));
00154 return notify(home,me,d);
00155 }
00156
00157
00158 forceinline ModEvent
00159 FloatVarImp::lq(Space& home, FloatNum n) {
00160 if (n < dom.min()) return fail(home);
00161 if ((n >= dom.max()) || assigned()) return ME_FLOAT_NONE;
00162 FloatDelta d(n,dom.max());
00163 ModEvent me = ME_FLOAT_BND;
00164 dom = intersect(dom,FloatVal(dom.min(),n));
00165 if (assigned()) me = ME_FLOAT_VAL;
00166 GECODE_ASSUME((me == ME_FLOAT_VAL) |
00167 (me == ME_FLOAT_BND));
00168 return notify(home,me,d);
00169 }
00170 forceinline ModEvent
00171 FloatVarImp::lq(Space& home, const FloatVal& n) {
00172 if (n.max() < dom.min()) return fail(home);
00173 if ((n.max() >= dom.max()) || assigned()) return ME_FLOAT_NONE;
00174 FloatDelta d(n.max(),dom.max());
00175 ModEvent me = ME_FLOAT_BND;
00176 dom = intersect(dom,FloatVal(dom.min(),n.max()));
00177 if (assigned()) me = ME_FLOAT_VAL;
00178 GECODE_ASSUME((me == ME_FLOAT_VAL) |
00179 (me == ME_FLOAT_BND));
00180 return notify(home,me,d);
00181 }
00182
00183
00184 forceinline ModEvent
00185 FloatVarImp::eq(Space& home, FloatNum n) {
00186 if (!dom.in(n))
00187 return fail(home);
00188 if (assigned())
00189 return ME_FLOAT_NONE;
00190 FloatDelta d;
00191 dom = n;
00192 return notify(home,ME_FLOAT_VAL,d);
00193 }
00194 forceinline ModEvent
00195 FloatVarImp::eq(Space& home, const FloatVal& n) {
00196 if (!overlap(dom,n))
00197 return fail(home);
00198 if (assigned() || subset(dom,n))
00199 return ME_FLOAT_NONE;
00200 FloatDelta d;
00201 ModEvent me = ME_FLOAT_BND;
00202 dom = intersect(dom,n);
00203 if (assigned()) me = ME_FLOAT_VAL;
00204 GECODE_ASSUME((me == ME_FLOAT_VAL) |
00205 (me == ME_FLOAT_BND));
00206 return notify(home,me,d);
00207 }
00208
00209
00210
00211
00212
00213
00214
00215 forceinline FloatVarImp*
00216 FloatVarImp::copy(Space& home) {
00217 return copied() ? static_cast<FloatVarImp*>(forward())
00218 : perform_copy(home);
00219 }
00220
00222 forceinline FloatVarImp*
00223 FloatVarImp::perform_copy(Space& home) {
00224 return new (home) FloatVarImp(home, *this);
00225 }
00226
00227 forceinline ModEventDelta
00228 FloatVarImp::med(ModEvent me) {
00229 return FloatVarImpBase::med(me);
00230 }
00231
00232 }}
00233
00234