1 /* 2 * CAUTION: 3 * This file has been automatically generated. Do not edit, 4 * edit the following files instead: 5 * - ./gecode/int/var-imp/int.vis 6 * - ./gecode/int/var-imp/bool.vis 7 * - ./gecode/set/var-imp/set.vis 8 * - ./gecode/float/var-imp/float.vis 9 * 10 * This file contains generated code fragments which are 11 * copyrighted as follows: 12 * 13 * Main author: 14 * Christian Schulte <schulte@gecode.org> 15 * 16 * Copyright: 17 * Christian Schulte, 2007 18 * 19 * The generated code fragments are part of Gecode, the generic 20 * constraint development environment: 21 * http://www.gecode.org 22 * 23 * Permission is hereby granted, free of charge, to any person obtaining 24 * a copy of this software and associated documentation files (the 25 * "Software"), to deal in the Software without restriction, including 26 * without limitation the rights to use, copy, modify, merge, publish, 27 * distribute, sublicense, and/or sell copies of the Software, and to 28 * permit persons to whom the Software is furnished to do so, subject to 29 * the following conditions: 30 * 31 * The above copyright notice and this permission notice shall be 32 * included in all copies or substantial portions of the Software. 33 * 34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 35 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 36 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 37 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 38 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 39 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 40 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 41 * 42 */ 43 44 #ifdef GECODE_HAS_INT_VARS 45 namespace Gecode { namespace Int { 46 /** 47 * \defgroup TaskActorIntMEPC Integer modification events and propagation conditions 48 * \ingroup TaskActorInt 49 */ 50 //@{ 51 /// Domain operation has resulted in failure 52 const Gecode::ModEvent ME_INT_FAILED = Gecode::ME_GEN_FAILED; 53 /// Domain operation has not changed domain 54 const Gecode::ModEvent ME_INT_NONE = Gecode::ME_GEN_NONE; 55 /// Domain operation has resulted in a value (assigned variable) 56 const Gecode::ModEvent ME_INT_VAL = Gecode::ME_GEN_ASSIGNED; 57 /** 58 * \brief Domain operation has changed the minimum or maximum of the domain 59 * 60 * Note that this implies that the domain has not resulted in a value. 61 * 62 * If a propagator subscribes to this variable, it will be processed 63 * assuming a ME_INT_BND modification event. 64 */ 65 const Gecode::ModEvent ME_INT_BND = Gecode::ME_GEN_ASSIGNED + 1; 66 /** 67 * \brief Domain operation has changed the domain 68 * 69 * Note that this implies that the domain has not resulted in a value 70 * and that also the minimum and maximum of the domain have not changed. 71 */ 72 const Gecode::ModEvent ME_INT_DOM = Gecode::ME_GEN_ASSIGNED + 2; 73 /// Propagation condition to be ignored (convenience) 74 const Gecode::PropCond PC_INT_NONE = Gecode::PC_GEN_NONE; 75 /** 76 * \brief Propagate when a view becomes assigned (single value) 77 * 78 * If a propagator \a p depends on a view \a x with propagation 79 * condition PC_INT_VAL, then \a p is propagated when a domain 80 * update operation on \a x returns the modification event ME_INT_VAL. 81 */ 82 const Gecode::PropCond PC_INT_VAL = Gecode::PC_GEN_ASSIGNED; 83 /** 84 * \brief Propagate when minimum or maximum of a view changes 85 * 86 * If a propagator \a p depends on a view \a x with propagation 87 * condition PC_INT_BND, then \a p is propagated when a domain 88 * update operation on \a x returns the modification events ME_INT_VAL 89 * or ME_INT_BND. 90 */ 91 const Gecode::PropCond PC_INT_BND = Gecode::PC_GEN_ASSIGNED + 1; 92 /** 93 * \brief Propagate when domain changes 94 * 95 * If a propagator \a p depends on a view \a x with propagation 96 * condition PC_INT_DOM, then \a p is propagated when a domain 97 * update operation on \a x returns the modification event ME_INT_VAL, 98 * ME_INT_BND, or ME_INT_DOM. 99 */ 100 const Gecode::PropCond PC_INT_DOM = Gecode::PC_GEN_ASSIGNED + 2; 101 //@} 102 }} 103 #endif 104 #ifdef GECODE_HAS_INT_VARS 105 namespace Gecode { namespace Int { 106 /** 107 * \defgroup TaskActorIntMEPC Integer modification events and propagation conditions 108 * \ingroup TaskActorInt 109 */ 110 //@{ 111 /// Domain operation has resulted in failure 112 const Gecode::ModEvent ME_BOOL_FAILED = Gecode::ME_GEN_FAILED; 113 /// Domain operation has not changed domain 114 const Gecode::ModEvent ME_BOOL_NONE = Gecode::ME_GEN_NONE; 115 /// Domain operation has resulted in a value (assigned variable) 116 const Gecode::ModEvent ME_BOOL_VAL = Gecode::ME_GEN_ASSIGNED; 117 /// Propagation condition to be ignored (convenience) 118 const Gecode::PropCond PC_BOOL_NONE = Gecode::PC_GEN_NONE; 119 /** 120 * \brief Propagate when a view becomes assigned (single value) 121 * 122 * If a propagator \a p depends on a view \a x with propagation 123 * condition PC_BOOL_VAL, then \a p is propagated when a domain 124 * update operation on \a x returns the modification event ME_BOOL_VAL. 125 */ 126 const Gecode::PropCond PC_BOOL_VAL = Gecode::PC_GEN_ASSIGNED; 127 //@} 128 }} 129 #endif 130 #ifdef GECODE_HAS_SET_VARS 131 namespace Gecode { namespace Set { 132 /** 133 * \defgroup TaskActorSetMEPC Set modification events and propagation conditions 134 * \ingroup TaskActorSet 135 */ 136 //@{ 137 /// Domain operation has resulted in failure 138 const Gecode::ModEvent ME_SET_FAILED = Gecode::ME_GEN_FAILED; 139 /// Domain operation has not changed domain 140 const Gecode::ModEvent ME_SET_NONE = Gecode::ME_GEN_NONE; 141 /// Domain operation has resulted in a value (assigned variable) 142 const Gecode::ModEvent ME_SET_VAL = Gecode::ME_GEN_ASSIGNED; 143 /** 144 * \brief Domain operation has changed the variable cardinality 145 * 146 * Note that this implies that the domain has not resulted in a value. 147 */ 148 const Gecode::ModEvent ME_SET_CARD = Gecode::ME_GEN_ASSIGNED + 1; 149 /** 150 * \brief Domain operation has changed the least upper bound 151 * 152 * Note that this implies that the domain has not resulted in a value 153 * and that also neither cardinality nor the greatest lower bound 154 * have changed. 155 */ 156 const Gecode::ModEvent ME_SET_LUB = Gecode::ME_GEN_ASSIGNED + 2; 157 /** 158 * \brief Domain operation has changed the greatest lower bound 159 * 160 * Note that this implies that the domain has not resulted in a value 161 * and that also neither cardinality nor the least upper bound 162 * have changed. 163 */ 164 const Gecode::ModEvent ME_SET_GLB = Gecode::ME_GEN_ASSIGNED + 3; 165 /** 166 * \brief Domain operation has changed both greatest lower and least 167 * upper bound 168 * 169 * Note that this implies that the domain has not resulted in a value 170 * and that also the cardinality has not changed. 171 */ 172 const Gecode::ModEvent ME_SET_BB = Gecode::ME_GEN_ASSIGNED + 4; 173 /** 174 * \brief Domain operation has changed the least upper bound and the cardinality 175 * 176 * Note that this implies that the domain has not resulted in a value 177 * and that also the greatest lower bound has not changed. 178 */ 179 const Gecode::ModEvent ME_SET_CLUB = Gecode::ME_GEN_ASSIGNED + 5; 180 /** 181 * \brief Domain operation has changed the greatest lower bound and the cardinality 182 * 183 * Note that this implies that the domain has not resulted in a value 184 * and that also the least upper bound has not changed. 185 */ 186 const Gecode::ModEvent ME_SET_CGLB = Gecode::ME_GEN_ASSIGNED + 6; 187 /** 188 * \brief Domain operation has changed both the greatest lower bound and 189 * the least upper bound, as well as the cardinality 190 * 191 * Note that this implies that the domain has not resulted in a value. 192 * 193 * If a propagator subscribes to this variable, it will be processed 194 * assuming a ME_SET_CBB modification event. 195 * 196 */ 197 const Gecode::ModEvent ME_SET_CBB = Gecode::ME_GEN_ASSIGNED + 7; 198 /// Propagation condition to be ignored (convenience) 199 const Gecode::PropCond PC_SET_NONE = Gecode::PC_GEN_NONE; 200 /** 201 * \brief Propagate when a view becomes assigned (single value) 202 * 203 * If a propagator \a p depends on a view \a x with propagation 204 * condition PC_SET_VAL, then \a p is propagated when a domain 205 * update operation on \a x returns the modification event ME_SET_VAL. 206 */ 207 const Gecode::PropCond PC_SET_VAL = Gecode::PC_GEN_ASSIGNED; 208 /** 209 * \brief Propagate when the cardinality of a view changes 210 * 211 * If a propagator \a p depends on a view \a x with propagation 212 * condition PC_SET_CARD, then \a p is propagated when a domain 213 * update operation on \a x returns the modification event ME_SET_VAL, 214 * ME_SET_CARD, ME_SET_CGLB, ME_SET_CLUB, or ME_SET_CBB. 215 */ 216 const Gecode::PropCond PC_SET_CARD = Gecode::PC_GEN_ASSIGNED + 1; 217 /** 218 * \brief Propagate when the cardinality or the least upper bound 219 * of a view changes 220 * 221 * If a propagator \a p depends on a view \a x with propagation 222 * condition PC_SET_CLUB, then \a p is propagated when a domain 223 * update operation on \a x returns the modification event ME_SET_VAL, 224 * ME_SET_LUB, ME_SET_BB, ME_SET_CARD, ME_SET_CGLB, ME_SET_CLUB, 225 * or ME_SET_CBB. 226 */ 227 const Gecode::PropCond PC_SET_CLUB = Gecode::PC_GEN_ASSIGNED + 2; 228 /** 229 * \brief Propagate when the cardinality or the greatest lower bound 230 * of a view changes 231 * 232 * If a propagator \a p depends on a view \a x with propagation 233 * condition PC_SET_CGLB, then \a p is propagated when a domain 234 * update operation on \a x returns the modification event ME_SET_VAL, 235 * ME_SET_GLB, ME_SET_BB, ME_SET_CARD, ME_SET_CGLB, ME_SET_CLUB, 236 * or ME_SET_CBB. 237 */ 238 const Gecode::PropCond PC_SET_CGLB = Gecode::PC_GEN_ASSIGNED + 3; 239 /** 240 * \brief Propagate when any bound or the cardinality 241 * of a view changes 242 * 243 * If a propagator \a p depends on a view \a x with propagation 244 * condition PC_SET_ANY, then \a p is propagated when a domain 245 * update operation on \a x returns any modification event but ME_SET_FAILED 246 * and ME_SET_NONE. 247 */ 248 const Gecode::PropCond PC_SET_ANY = Gecode::PC_GEN_ASSIGNED + 4; 249 //@} 250 }} 251 #endif 252 #ifdef GECODE_HAS_FLOAT_VARS 253 namespace Gecode { namespace Float { 254 /** 255 * \defgroup TaskActorFloatMEPC Float modification events and propagation conditions 256 * \ingroup TaskActorFloat 257 */ 258 //@{ 259 /// Domain operation has resulted in failure 260 const Gecode::ModEvent ME_FLOAT_FAILED = Gecode::ME_GEN_FAILED; 261 /// Domain operation has not changed domain 262 const Gecode::ModEvent ME_FLOAT_NONE = Gecode::ME_GEN_NONE; 263 /// Domain operation has resulted in a value (assigned variable) 264 const Gecode::ModEvent ME_FLOAT_VAL = Gecode::ME_GEN_ASSIGNED; 265 /** 266 * \brief Domain operation has changed the minimum or maximum of the domain 267 * 268 * Note that this implies that the domain has not resulted in a value. 269 * 270 * If a propagator subscribes to this variable, it will be processed 271 * assuming a ME_FLOAT_BND modification event. 272 */ 273 const Gecode::ModEvent ME_FLOAT_BND = Gecode::ME_GEN_ASSIGNED + 1; 274 /// Propagation condition to be ignored (convenience) 275 const Gecode::PropCond PC_FLOAT_NONE = Gecode::PC_GEN_NONE; 276 /** 277 * \brief Propagate when a view becomes assigned (single value) 278 * 279 * If a propagator \a p depends on a view \a x with propagation 280 * condition PC_FLOAT_VAL, then \a p is propagated when a domain 281 * update operation on \a x returns the modification event ME_FLOAT_VAL. 282 */ 283 const Gecode::PropCond PC_FLOAT_VAL = Gecode::PC_GEN_ASSIGNED; 284 /** 285 * \brief Propagate when minimum or maximum of a view changes 286 * 287 * If a propagator \a p depends on a view \a x with propagation 288 * condition PC_FLOAT_BND, then \a p is propagated when a domain 289 * update operation on \a x returns the modification events ME_FLOAT_VAL 290 * or ME_FLOAT_BND. 291 */ 292 const Gecode::PropCond PC_FLOAT_BND = Gecode::PC_GEN_ASSIGNED + 1; 293 //@} 294 }} 295 #endif 296 #ifdef GECODE_HAS_INT_VARS 297 namespace Gecode { namespace Int { 298 /// Configuration for Int-variable implementations 299 class IntVarImpConf { 300 public: 301 /// Index for cloning 302 static const int idx_c = 0; 303 /// Index for disposal 304 static const int idx_d = -1; 305 /// Maximal propagation condition 306 static const Gecode::PropCond pc_max = PC_INT_DOM; 307 /// Freely available bits 308 static const int free_bits = 0; 309 /// Start of bits for modification event delta 310 static const int med_fst = 0; 311 /// End of bits for modification event delta 312 static const int med_lst = med_fst + 2; 313 /// Bitmask for modification event delta 314 static const int med_mask = ((1 << 2) - 1) << med_fst; 315 /// Combine modification events \a me1 and \a me2 316 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2); 317 /// Update modification even delta \a med by \a me, return true on change 318 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me); 319 }; 320 }} 321 #else 322 namespace Gecode { namespace Int { 323 /// Dummy configuration for Int-variable implementations 324 class IntVarImpConf { 325 public: 326 /// Index for cloning 327 static const int idx_c = -1; 328 /// Index for disposal 329 static const int idx_d = -1; 330 /// End of bits for modification event delta 331 static const int med_lst = 0; 332 }; 333 }} 334 #endif 335 #ifdef GECODE_HAS_INT_VARS 336 namespace Gecode { namespace Int { 337 /// Configuration for Bool-variable implementations 338 class BoolVarImpConf { 339 public: 340 /// Index for cloning 341 static const int idx_c = Gecode::Int::IntVarImpConf::idx_c+1; 342 /// Index for disposal 343 static const int idx_d = Gecode::Int::IntVarImpConf::idx_d; 344 /// Maximal propagation condition 345 static const Gecode::PropCond pc_max = PC_BOOL_VAL; 346 /// Freely available bits 347 static const int free_bits = 2; 348 /// Start of bits for modification event delta 349 static const int med_fst = Gecode::Int::IntVarImpConf::med_lst; 350 /// End of bits for modification event delta 351 static const int med_lst = med_fst + 1; 352 /// Bitmask for modification event delta 353 static const int med_mask = ((1 << 1) - 1) << med_fst; 354 /// Combine modification events \a me1 and \a me2 355 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2); 356 /// Update modification even delta \a med by \a me, return true on change 357 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me); 358 }; 359 }} 360 #else 361 namespace Gecode { namespace Int { 362 /// Dummy configuration for Bool-variable implementations 363 class BoolVarImpConf { 364 public: 365 /// Index for cloning 366 static const int idx_c = Gecode::Int::IntVarImpConf::idx_c; 367 /// Index for disposal 368 static const int idx_d = Gecode::Int::IntVarImpConf::idx_d; 369 /// End of bits for modification event delta 370 static const int med_lst = Gecode::Int::IntVarImpConf::med_lst; 371 }; 372 }} 373 #endif 374 #ifdef GECODE_HAS_SET_VARS 375 namespace Gecode { namespace Set { 376 /// Configuration for Set-variable implementations 377 class SetVarImpConf { 378 public: 379 /// Index for cloning 380 static const int idx_c = Gecode::Int::BoolVarImpConf::idx_c+1; 381 /// Index for disposal 382 static const int idx_d = Gecode::Int::BoolVarImpConf::idx_d; 383 /// Maximal propagation condition 384 static const Gecode::PropCond pc_max = PC_SET_ANY; 385 /// Freely available bits 386 static const int free_bits = 0; 387 /// Start of bits for modification event delta 388 static const int med_fst = Gecode::Int::BoolVarImpConf::med_lst; 389 /// End of bits for modification event delta 390 static const int med_lst = med_fst + 4; 391 /// Bitmask for modification event delta 392 static const int med_mask = ((1 << 4) - 1) << med_fst; 393 /// Combine modification events \a me1 and \a me2 394 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2); 395 /// Update modification even delta \a med by \a me, return true on change 396 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me); 397 }; 398 }} 399 #else 400 namespace Gecode { namespace Set { 401 /// Dummy configuration for Set-variable implementations 402 class SetVarImpConf { 403 public: 404 /// Index for cloning 405 static const int idx_c = Gecode::Int::BoolVarImpConf::idx_c; 406 /// Index for disposal 407 static const int idx_d = Gecode::Int::BoolVarImpConf::idx_d; 408 /// End of bits for modification event delta 409 static const int med_lst = Gecode::Int::BoolVarImpConf::med_lst; 410 }; 411 }} 412 #endif 413 #ifdef GECODE_HAS_FLOAT_VARS 414 namespace Gecode { namespace Float { 415 /// Configuration for Float-variable implementations 416 class FloatVarImpConf { 417 public: 418 /// Index for cloning 419 static const int idx_c = Gecode::Set::SetVarImpConf::idx_c+1; 420 /// Index for disposal 421 static const int idx_d = Gecode::Set::SetVarImpConf::idx_d; 422 /// Maximal propagation condition 423 static const Gecode::PropCond pc_max = PC_FLOAT_BND; 424 /// Freely available bits 425 static const int free_bits = 0; 426 /// Start of bits for modification event delta 427 static const int med_fst = Gecode::Set::SetVarImpConf::med_lst; 428 /// End of bits for modification event delta 429 static const int med_lst = med_fst + 2; 430 /// Bitmask for modification event delta 431 static const int med_mask = ((1 << 2) - 1) << med_fst; 432 /// Combine modification events \a me1 and \a me2 433 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2); 434 /// Update modification even delta \a med by \a me, return true on change 435 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me); 436 }; 437 }} 438 #else 439 namespace Gecode { namespace Float { 440 /// Dummy configuration for Float-variable implementations 441 class FloatVarImpConf { 442 public: 443 /// Index for cloning 444 static const int idx_c = Gecode::Set::SetVarImpConf::idx_c; 445 /// Index for disposal 446 static const int idx_d = Gecode::Set::SetVarImpConf::idx_d; 447 /// End of bits for modification event delta 448 static const int med_lst = Gecode::Set::SetVarImpConf::med_lst; 449 }; 450 }} 451 #endif 452 453 namespace Gecode { 454 455 /// Configuration for all variable implementations 456 class AllVarConf { 457 public: 458 /// Index for cloning 459 static const int idx_c = Gecode::Float::FloatVarImpConf::idx_c+1; 460 /// Index for dispose 461 static const int idx_d = Gecode::Float::FloatVarImpConf::idx_d+1; 462 /// Combine modification event delta \a med1 with \a med2 463 static ModEventDelta med_combine(ModEventDelta med1, ModEventDelta med2); 464 }; 465 466 } 467 468 #ifdef GECODE_HAS_INT_VARS 469 namespace Gecode { namespace Int { 470 forceinline Gecode::ModEvent me_combine(Gecode::ModEvent me1,Gecode::ModEvent me2)471 IntVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) { 472 static const Gecode::ModEvent me_c = ( 473 ( 474 (ME_INT_NONE << 0) | // [ME_INT_NONE][ME_INT_NONE] 475 (ME_INT_VAL << 2) | // [ME_INT_NONE][ME_INT_VAL ] 476 (ME_INT_BND << 4) | // [ME_INT_NONE][ME_INT_BND ] 477 (ME_INT_DOM << 6) // [ME_INT_NONE][ME_INT_DOM ] 478 ) | 479 ( 480 (ME_INT_VAL << 8) | // [ME_INT_VAL ][ME_INT_NONE] 481 (ME_INT_VAL << 10) | // [ME_INT_VAL ][ME_INT_VAL ] 482 (ME_INT_VAL << 12) | // [ME_INT_VAL ][ME_INT_BND ] 483 (ME_INT_VAL << 14) // [ME_INT_VAL ][ME_INT_DOM ] 484 ) | 485 ( 486 (ME_INT_BND << 16) | // [ME_INT_BND ][ME_INT_NONE] 487 (ME_INT_VAL << 18) | // [ME_INT_BND ][ME_INT_VAL ] 488 (ME_INT_BND << 20) | // [ME_INT_BND ][ME_INT_BND ] 489 (ME_INT_BND << 22) // [ME_INT_BND ][ME_INT_DOM ] 490 ) | 491 ( 492 (ME_INT_DOM << 24) | // [ME_INT_DOM ][ME_INT_NONE] 493 (ME_INT_VAL << 26) | // [ME_INT_DOM ][ME_INT_VAL ] 494 (ME_INT_BND << 28) | // [ME_INT_DOM ][ME_INT_BND ] 495 (ME_INT_DOM << 30) // [ME_INT_DOM ][ME_INT_DOM ] 496 ) 497 ); 498 return ((me_c >> (me2 << 3)) >> (me1 << 1)) & 3; 499 } 500 forceinline bool med_update(Gecode::ModEventDelta & med,Gecode::ModEvent me)501 IntVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) { 502 switch (me) { 503 case ME_INT_NONE: 504 return false; 505 case ME_INT_VAL: 506 { 507 Gecode::ModEventDelta med_int = med & med_mask; 508 if (med_int == (ME_INT_VAL << med_fst)) 509 return false; 510 med ^= med_int; 511 med ^= ME_INT_VAL << med_fst; 512 break; 513 } 514 case ME_INT_BND: 515 { 516 static const Gecode::ModEvent me_c = ( 517 ((ME_INT_NONE ^ ME_INT_BND ) << 0) | 518 ((ME_INT_VAL ^ ME_INT_VAL ) << 4) | 519 ((ME_INT_BND ^ ME_INT_BND ) << 8) | 520 ((ME_INT_DOM ^ ME_INT_BND ) << 12) 521 ); 522 Gecode::ModEvent me_o = (med & med_mask) >> med_fst; 523 Gecode::ModEvent me_n = (me_c >> (me_o << 2)) & (med_mask >> med_fst); 524 if (me_n == 0) 525 return false; 526 med ^= me_n << med_fst; 527 break; 528 } 529 case ME_INT_DOM: 530 { 531 Gecode::ModEventDelta med_int = med & med_mask; 532 if (med_int != 0) 533 return false; 534 med |= ME_INT_DOM << med_fst; 535 break; 536 } 537 default: GECODE_NEVER; 538 } 539 return true; 540 } 541 542 }} 543 #endif 544 #ifdef GECODE_HAS_INT_VARS 545 namespace Gecode { namespace Int { 546 forceinline Gecode::ModEvent me_combine(Gecode::ModEvent me1,Gecode::ModEvent me2)547 BoolVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) { 548 return me1 | me2; 549 } 550 forceinline bool med_update(Gecode::ModEventDelta & med,Gecode::ModEvent me)551 BoolVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) { 552 switch (me) { 553 case ME_BOOL_NONE: 554 return false; 555 case ME_BOOL_VAL: 556 if ((med & (ME_BOOL_VAL << med_fst)) != 0) 557 return false; 558 med |= ME_BOOL_VAL << med_fst; 559 break; 560 default: GECODE_NEVER; 561 } 562 return true; 563 } 564 565 }} 566 #endif 567 #ifdef GECODE_HAS_SET_VARS 568 namespace Gecode { namespace Set { 569 forceinline Gecode::ModEvent me_combine(Gecode::ModEvent me1,Gecode::ModEvent me2)570 SetVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) { 571 static const Gecode::ModEvent me_c[ME_SET_CBB+1][ME_SET_CBB+1] = { 572 { 573 ME_SET_NONE, // [ME_SET_NONE][ME_SET_NONE] 574 ME_SET_VAL , // [ME_SET_NONE][ME_SET_VAL ] 575 ME_SET_CARD, // [ME_SET_NONE][ME_SET_CARD] 576 ME_SET_LUB , // [ME_SET_NONE][ME_SET_LUB ] 577 ME_SET_GLB , // [ME_SET_NONE][ME_SET_GLB ] 578 ME_SET_BB , // [ME_SET_NONE][ME_SET_BB ] 579 ME_SET_CLUB, // [ME_SET_NONE][ME_SET_CLUB] 580 ME_SET_CGLB, // [ME_SET_NONE][ME_SET_CGLB] 581 ME_SET_CBB // [ME_SET_NONE][ME_SET_CBB ] 582 }, 583 { 584 ME_SET_VAL , // [ME_SET_VAL ][ME_SET_NONE] 585 ME_SET_VAL , // [ME_SET_VAL ][ME_SET_VAL ] 586 ME_SET_VAL , // [ME_SET_VAL ][ME_SET_CARD] 587 ME_SET_VAL , // [ME_SET_VAL ][ME_SET_LUB ] 588 ME_SET_VAL , // [ME_SET_VAL ][ME_SET_GLB ] 589 ME_SET_VAL , // [ME_SET_VAL ][ME_SET_BB ] 590 ME_SET_VAL , // [ME_SET_VAL ][ME_SET_CLUB] 591 ME_SET_VAL , // [ME_SET_VAL ][ME_SET_CGLB] 592 ME_SET_VAL // [ME_SET_VAL ][ME_SET_CBB ] 593 }, 594 { 595 ME_SET_CARD, // [ME_SET_CARD][ME_SET_NONE] 596 ME_SET_VAL , // [ME_SET_CARD][ME_SET_VAL ] 597 ME_SET_CARD, // [ME_SET_CARD][ME_SET_CARD] 598 ME_SET_CLUB, // [ME_SET_CARD][ME_SET_LUB ] 599 ME_SET_CGLB, // [ME_SET_CARD][ME_SET_GLB ] 600 ME_SET_CBB , // [ME_SET_CARD][ME_SET_BB ] 601 ME_SET_CLUB, // [ME_SET_CARD][ME_SET_CLUB] 602 ME_SET_CGLB, // [ME_SET_CARD][ME_SET_CGLB] 603 ME_SET_CBB // [ME_SET_CARD][ME_SET_CBB ] 604 }, 605 { 606 ME_SET_LUB , // [ME_SET_LUB ][ME_SET_NONE] 607 ME_SET_VAL , // [ME_SET_LUB ][ME_SET_VAL ] 608 ME_SET_CLUB, // [ME_SET_LUB ][ME_SET_CARD] 609 ME_SET_LUB , // [ME_SET_LUB ][ME_SET_LUB ] 610 ME_SET_BB , // [ME_SET_LUB ][ME_SET_GLB ] 611 ME_SET_BB , // [ME_SET_LUB ][ME_SET_BB ] 612 ME_SET_CLUB, // [ME_SET_LUB ][ME_SET_CLUB] 613 ME_SET_CBB , // [ME_SET_LUB ][ME_SET_CGLB] 614 ME_SET_CBB // [ME_SET_LUB ][ME_SET_CBB ] 615 }, 616 { 617 ME_SET_GLB , // [ME_SET_GLB ][ME_SET_NONE] 618 ME_SET_VAL , // [ME_SET_GLB ][ME_SET_VAL ] 619 ME_SET_CGLB, // [ME_SET_GLB ][ME_SET_CARD] 620 ME_SET_BB , // [ME_SET_GLB ][ME_SET_LUB ] 621 ME_SET_GLB , // [ME_SET_GLB ][ME_SET_GLB ] 622 ME_SET_BB , // [ME_SET_GLB ][ME_SET_BB ] 623 ME_SET_CBB , // [ME_SET_GLB ][ME_SET_CLUB] 624 ME_SET_CGLB, // [ME_SET_GLB ][ME_SET_CGLB] 625 ME_SET_CBB // [ME_SET_GLB ][ME_SET_CBB ] 626 }, 627 { 628 ME_SET_BB , // [ME_SET_BB ][ME_SET_NONE] 629 ME_SET_VAL , // [ME_SET_BB ][ME_SET_VAL ] 630 ME_SET_CBB , // [ME_SET_BB ][ME_SET_CARD] 631 ME_SET_BB , // [ME_SET_BB ][ME_SET_LUB ] 632 ME_SET_BB , // [ME_SET_BB ][ME_SET_GLB ] 633 ME_SET_BB , // [ME_SET_BB ][ME_SET_BB ] 634 ME_SET_CBB , // [ME_SET_BB ][ME_SET_CLUB] 635 ME_SET_CBB , // [ME_SET_BB ][ME_SET_CGLB] 636 ME_SET_CBB // [ME_SET_BB ][ME_SET_CBB ] 637 }, 638 { 639 ME_SET_CLUB, // [ME_SET_CLUB][ME_SET_NONE] 640 ME_SET_VAL , // [ME_SET_CLUB][ME_SET_VAL ] 641 ME_SET_CLUB, // [ME_SET_CLUB][ME_SET_CARD] 642 ME_SET_CLUB, // [ME_SET_CLUB][ME_SET_LUB ] 643 ME_SET_CBB , // [ME_SET_CLUB][ME_SET_GLB ] 644 ME_SET_CBB , // [ME_SET_CLUB][ME_SET_BB ] 645 ME_SET_CLUB, // [ME_SET_CLUB][ME_SET_CLUB] 646 ME_SET_CBB , // [ME_SET_CLUB][ME_SET_CGLB] 647 ME_SET_CBB // [ME_SET_CLUB][ME_SET_CBB ] 648 }, 649 { 650 ME_SET_CGLB, // [ME_SET_CGLB][ME_SET_NONE] 651 ME_SET_VAL , // [ME_SET_CGLB][ME_SET_VAL ] 652 ME_SET_CGLB, // [ME_SET_CGLB][ME_SET_CARD] 653 ME_SET_CBB , // [ME_SET_CGLB][ME_SET_LUB ] 654 ME_SET_CGLB, // [ME_SET_CGLB][ME_SET_GLB ] 655 ME_SET_CBB , // [ME_SET_CGLB][ME_SET_BB ] 656 ME_SET_CBB , // [ME_SET_CGLB][ME_SET_CLUB] 657 ME_SET_CGLB, // [ME_SET_CGLB][ME_SET_CGLB] 658 ME_SET_CBB // [ME_SET_CGLB][ME_SET_CBB ] 659 }, 660 { 661 ME_SET_CBB , // [ME_SET_CBB ][ME_SET_NONE] 662 ME_SET_VAL , // [ME_SET_CBB ][ME_SET_VAL ] 663 ME_SET_CBB , // [ME_SET_CBB ][ME_SET_CARD] 664 ME_SET_CBB , // [ME_SET_CBB ][ME_SET_LUB ] 665 ME_SET_CBB , // [ME_SET_CBB ][ME_SET_GLB ] 666 ME_SET_CBB , // [ME_SET_CBB ][ME_SET_BB ] 667 ME_SET_CBB , // [ME_SET_CBB ][ME_SET_CLUB] 668 ME_SET_CBB , // [ME_SET_CBB ][ME_SET_CGLB] 669 ME_SET_CBB // [ME_SET_CBB ][ME_SET_CBB ] 670 } 671 }; 672 return me_c[me1][me2]; 673 } 674 forceinline bool med_update(Gecode::ModEventDelta & med,Gecode::ModEvent me)675 SetVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) { 676 switch (me) { 677 case ME_SET_NONE: 678 return false; 679 case ME_SET_VAL: 680 { 681 Gecode::ModEventDelta med_set = med & med_mask; 682 if (med_set == (ME_SET_VAL << med_fst)) 683 return false; 684 med ^= med_set; 685 med ^= ME_SET_VAL << med_fst; 686 break; 687 } 688 case ME_SET_CARD: 689 { 690 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = { 691 (ME_SET_NONE ^ ME_SET_CARD) << med_fst, 692 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst, 693 (ME_SET_CARD ^ ME_SET_CARD) << med_fst, 694 (ME_SET_LUB ^ ME_SET_CLUB) << med_fst, 695 (ME_SET_GLB ^ ME_SET_CGLB) << med_fst, 696 (ME_SET_BB ^ ME_SET_CBB ) << med_fst, 697 (ME_SET_CLUB ^ ME_SET_CLUB) << med_fst, 698 (ME_SET_CGLB ^ ME_SET_CGLB) << med_fst, 699 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst 700 }; 701 Gecode::ModEvent me_o = (med & med_mask) >> med_fst; 702 Gecode::ModEventDelta med_n = me_c[me_o]; 703 if (med_n == 0) 704 return false; 705 med ^= med_n; 706 break; 707 } 708 case ME_SET_LUB: 709 { 710 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = { 711 (ME_SET_NONE ^ ME_SET_LUB ) << med_fst, 712 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst, 713 (ME_SET_CARD ^ ME_SET_CLUB) << med_fst, 714 (ME_SET_LUB ^ ME_SET_LUB ) << med_fst, 715 (ME_SET_GLB ^ ME_SET_BB ) << med_fst, 716 (ME_SET_BB ^ ME_SET_BB ) << med_fst, 717 (ME_SET_CLUB ^ ME_SET_CLUB) << med_fst, 718 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst, 719 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst 720 }; 721 Gecode::ModEvent me_o = (med & med_mask) >> med_fst; 722 Gecode::ModEventDelta med_n = me_c[me_o]; 723 if (med_n == 0) 724 return false; 725 med ^= med_n; 726 break; 727 } 728 case ME_SET_GLB: 729 { 730 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = { 731 (ME_SET_NONE ^ ME_SET_GLB ) << med_fst, 732 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst, 733 (ME_SET_CARD ^ ME_SET_CGLB) << med_fst, 734 (ME_SET_LUB ^ ME_SET_BB ) << med_fst, 735 (ME_SET_GLB ^ ME_SET_GLB ) << med_fst, 736 (ME_SET_BB ^ ME_SET_BB ) << med_fst, 737 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst, 738 (ME_SET_CGLB ^ ME_SET_CGLB) << med_fst, 739 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst 740 }; 741 Gecode::ModEvent me_o = (med & med_mask) >> med_fst; 742 Gecode::ModEventDelta med_n = me_c[me_o]; 743 if (med_n == 0) 744 return false; 745 med ^= med_n; 746 break; 747 } 748 case ME_SET_BB: 749 { 750 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = { 751 (ME_SET_NONE ^ ME_SET_BB ) << med_fst, 752 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst, 753 (ME_SET_CARD ^ ME_SET_CBB ) << med_fst, 754 (ME_SET_LUB ^ ME_SET_BB ) << med_fst, 755 (ME_SET_GLB ^ ME_SET_BB ) << med_fst, 756 (ME_SET_BB ^ ME_SET_BB ) << med_fst, 757 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst, 758 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst, 759 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst 760 }; 761 Gecode::ModEvent me_o = (med & med_mask) >> med_fst; 762 Gecode::ModEventDelta med_n = me_c[me_o]; 763 if (med_n == 0) 764 return false; 765 med ^= med_n; 766 break; 767 } 768 case ME_SET_CLUB: 769 { 770 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = { 771 (ME_SET_NONE ^ ME_SET_CLUB) << med_fst, 772 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst, 773 (ME_SET_CARD ^ ME_SET_CLUB) << med_fst, 774 (ME_SET_LUB ^ ME_SET_CLUB) << med_fst, 775 (ME_SET_GLB ^ ME_SET_CBB ) << med_fst, 776 (ME_SET_BB ^ ME_SET_CBB ) << med_fst, 777 (ME_SET_CLUB ^ ME_SET_CLUB) << med_fst, 778 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst, 779 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst 780 }; 781 Gecode::ModEvent me_o = (med & med_mask) >> med_fst; 782 Gecode::ModEventDelta med_n = me_c[me_o]; 783 if (med_n == 0) 784 return false; 785 med ^= med_n; 786 break; 787 } 788 case ME_SET_CGLB: 789 { 790 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = { 791 (ME_SET_NONE ^ ME_SET_CGLB) << med_fst, 792 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst, 793 (ME_SET_CARD ^ ME_SET_CGLB) << med_fst, 794 (ME_SET_LUB ^ ME_SET_CBB ) << med_fst, 795 (ME_SET_GLB ^ ME_SET_CGLB) << med_fst, 796 (ME_SET_BB ^ ME_SET_CBB ) << med_fst, 797 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst, 798 (ME_SET_CGLB ^ ME_SET_CGLB) << med_fst, 799 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst 800 }; 801 Gecode::ModEvent me_o = (med & med_mask) >> med_fst; 802 Gecode::ModEventDelta med_n = me_c[me_o]; 803 if (med_n == 0) 804 return false; 805 med ^= med_n; 806 break; 807 } 808 case ME_SET_CBB: 809 { 810 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = { 811 (ME_SET_NONE ^ ME_SET_CBB ) << med_fst, 812 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst, 813 (ME_SET_CARD ^ ME_SET_CBB ) << med_fst, 814 (ME_SET_LUB ^ ME_SET_CBB ) << med_fst, 815 (ME_SET_GLB ^ ME_SET_CBB ) << med_fst, 816 (ME_SET_BB ^ ME_SET_CBB ) << med_fst, 817 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst, 818 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst, 819 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst 820 }; 821 Gecode::ModEvent me_o = (med & med_mask) >> med_fst; 822 Gecode::ModEventDelta med_n = me_c[me_o]; 823 if (med_n == 0) 824 return false; 825 med ^= med_n; 826 break; 827 } 828 default: GECODE_NEVER; 829 } 830 return true; 831 } 832 833 }} 834 #endif 835 #ifdef GECODE_HAS_FLOAT_VARS 836 namespace Gecode { namespace Float { 837 forceinline Gecode::ModEvent me_combine(Gecode::ModEvent me1,Gecode::ModEvent me2)838 FloatVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) { 839 static const Gecode::ModEvent me_c = ( 840 ( 841 (ME_FLOAT_NONE << 0) | // [ME_FLOAT_NONE][ME_FLOAT_NONE] 842 (ME_FLOAT_VAL << 2) | // [ME_FLOAT_NONE][ME_FLOAT_VAL ] 843 (ME_FLOAT_BND << 4) // [ME_FLOAT_NONE][ME_FLOAT_BND ] 844 ) | 845 ( 846 (ME_FLOAT_VAL << 8) | // [ME_FLOAT_VAL ][ME_FLOAT_NONE] 847 (ME_FLOAT_VAL << 10) | // [ME_FLOAT_VAL ][ME_FLOAT_VAL ] 848 (ME_FLOAT_VAL << 12) // [ME_FLOAT_VAL ][ME_FLOAT_BND ] 849 ) | 850 ( 851 (ME_FLOAT_BND << 16) | // [ME_FLOAT_BND ][ME_FLOAT_NONE] 852 (ME_FLOAT_VAL << 18) | // [ME_FLOAT_BND ][ME_FLOAT_VAL ] 853 (ME_FLOAT_BND << 20) // [ME_FLOAT_BND ][ME_FLOAT_BND ] 854 ) 855 ); 856 return ((me_c >> (me2 << 3)) >> (me1 << 1)) & 3; 857 } 858 forceinline bool med_update(Gecode::ModEventDelta & med,Gecode::ModEvent me)859 FloatVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) { 860 switch (me) { 861 case ME_FLOAT_NONE: 862 return false; 863 case ME_FLOAT_VAL: 864 { 865 Gecode::ModEventDelta med_float = med & med_mask; 866 if (med_float == (ME_FLOAT_VAL << med_fst)) 867 return false; 868 med ^= med_float; 869 med ^= ME_FLOAT_VAL << med_fst; 870 break; 871 } 872 case ME_FLOAT_BND: 873 { 874 Gecode::ModEventDelta med_float = med & med_mask; 875 if (med_float != 0) 876 return false; 877 med |= ME_FLOAT_BND << med_fst; 878 break; 879 } 880 default: GECODE_NEVER; 881 } 882 return true; 883 } 884 885 }} 886 #endif 887 namespace Gecode { 888 forceinline ModEventDelta med_combine(ModEventDelta med1,ModEventDelta med2)889 AllVarConf::med_combine(ModEventDelta med1, ModEventDelta med2) { 890 #ifdef GECODE_HAS_INT_VARS 891 (void) Gecode::Int::IntVarImpConf::med_update(med1,(med2 & Gecode::Int::IntVarImpConf::med_mask) >> Gecode::Int::IntVarImpConf::med_fst); 892 #endif 893 #ifdef GECODE_HAS_INT_VARS 894 (void) Gecode::Int::BoolVarImpConf::med_update(med1,(med2 & Gecode::Int::BoolVarImpConf::med_mask) >> Gecode::Int::BoolVarImpConf::med_fst); 895 #endif 896 #ifdef GECODE_HAS_SET_VARS 897 (void) Gecode::Set::SetVarImpConf::med_update(med1,(med2 & Gecode::Set::SetVarImpConf::med_mask) >> Gecode::Set::SetVarImpConf::med_fst); 898 #endif 899 #ifdef GECODE_HAS_FLOAT_VARS 900 (void) Gecode::Float::FloatVarImpConf::med_update(med1,(med2 & Gecode::Float::FloatVarImpConf::med_mask) >> Gecode::Float::FloatVarImpConf::med_fst); 901 #endif 902 return med1; 903 } 904 } 905 906 // STATISTICS: kernel-var 907