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
00042
00043 #ifdef GECODE_HAS_INT_VARS
00044 namespace Gecode { namespace Int {
00050
00051 const Gecode::ModEvent ME_INT_FAILED = Gecode::ME_GEN_FAILED;
00053 const Gecode::ModEvent ME_INT_NONE = Gecode::ME_GEN_NONE;
00055 const Gecode::ModEvent ME_INT_VAL = Gecode::ME_GEN_ASSIGNED;
00064 const Gecode::ModEvent ME_INT_BND = Gecode::ME_GEN_ASSIGNED + 1;
00071 const Gecode::ModEvent ME_INT_DOM = Gecode::ME_GEN_ASSIGNED + 2;
00073 const Gecode::PropCond PC_INT_NONE = Gecode::PC_GEN_NONE;
00081 const Gecode::PropCond PC_INT_VAL = Gecode::PC_GEN_ASSIGNED;
00090 const Gecode::PropCond PC_INT_BND = Gecode::PC_GEN_ASSIGNED + 1;
00099 const Gecode::PropCond PC_INT_DOM = Gecode::PC_GEN_ASSIGNED + 2;
00101 }}
00102 #endif
00103 #ifdef GECODE_HAS_INT_VARS
00104 namespace Gecode { namespace Int {
00110
00111 const Gecode::ModEvent ME_BOOL_FAILED = Gecode::ME_GEN_FAILED;
00113 const Gecode::ModEvent ME_BOOL_NONE = Gecode::ME_GEN_NONE;
00115 const Gecode::ModEvent ME_BOOL_VAL = Gecode::ME_GEN_ASSIGNED;
00117 const Gecode::PropCond PC_BOOL_NONE = Gecode::PC_GEN_NONE;
00125 const Gecode::PropCond PC_BOOL_VAL = Gecode::PC_GEN_ASSIGNED;
00127 }}
00128 #endif
00129 #ifdef GECODE_HAS_SET_VARS
00130 namespace Gecode { namespace Set {
00136
00137 const Gecode::ModEvent ME_SET_FAILED = Gecode::ME_GEN_FAILED;
00139 const Gecode::ModEvent ME_SET_NONE = Gecode::ME_GEN_NONE;
00141 const Gecode::ModEvent ME_SET_VAL = Gecode::ME_GEN_ASSIGNED;
00147 const Gecode::ModEvent ME_SET_CARD = Gecode::ME_GEN_ASSIGNED + 1;
00155 const Gecode::ModEvent ME_SET_LUB = Gecode::ME_GEN_ASSIGNED + 2;
00163 const Gecode::ModEvent ME_SET_GLB = Gecode::ME_GEN_ASSIGNED + 3;
00171 const Gecode::ModEvent ME_SET_BB = Gecode::ME_GEN_ASSIGNED + 4;
00178 const Gecode::ModEvent ME_SET_CLUB = Gecode::ME_GEN_ASSIGNED + 5;
00185 const Gecode::ModEvent ME_SET_CGLB = Gecode::ME_GEN_ASSIGNED + 6;
00196 const Gecode::ModEvent ME_SET_CBB = Gecode::ME_GEN_ASSIGNED + 7;
00198 const Gecode::PropCond PC_SET_NONE = Gecode::PC_GEN_NONE;
00206 const Gecode::PropCond PC_SET_VAL = Gecode::PC_GEN_ASSIGNED;
00215 const Gecode::PropCond PC_SET_CARD = Gecode::PC_GEN_ASSIGNED + 1;
00226 const Gecode::PropCond PC_SET_CLUB = Gecode::PC_GEN_ASSIGNED + 2;
00237 const Gecode::PropCond PC_SET_CGLB = Gecode::PC_GEN_ASSIGNED + 3;
00247 const Gecode::PropCond PC_SET_ANY = Gecode::PC_GEN_ASSIGNED + 4;
00249 }}
00250 #endif
00251 #ifdef GECODE_HAS_INT_VARS
00252 namespace Gecode { namespace Int {
00254 class IntVarImpConf {
00255 public:
00257 static const int idx_c = 0;
00259 static const int idx_d = -1;
00261 static const Gecode::PropCond pc_max = PC_INT_DOM;
00263 static const int free_bits = 0;
00265 static const int med_fst = 0;
00267 static const int med_lst = med_fst + 2;
00269 static const int med_mask = ((1 << 2) - 1) << med_fst;
00271 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2);
00273 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me);
00274 };
00275 }}
00276 #else
00277 namespace Gecode { namespace Int {
00279 class IntVarImpConf {
00280 public:
00282 static const int idx_c = -1;
00284 static const int idx_d = -1;
00286 static const int med_lst = 0;
00287 };
00288 }}
00289 #endif
00290 #ifdef GECODE_HAS_INT_VARS
00291 namespace Gecode { namespace Int {
00293 class BoolVarImpConf {
00294 public:
00296 static const int idx_c = Gecode::Int::IntVarImpConf::idx_c+1;
00298 static const int idx_d = Gecode::Int::IntVarImpConf::idx_d;
00300 static const Gecode::PropCond pc_max = PC_BOOL_VAL;
00302 static const int free_bits = 2;
00304 static const int med_fst = Gecode::Int::IntVarImpConf::med_lst;
00306 static const int med_lst = med_fst + 1;
00308 static const int med_mask = ((1 << 1) - 1) << med_fst;
00310 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2);
00312 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me);
00313 };
00314 }}
00315 #else
00316 namespace Gecode { namespace Int {
00318 class BoolVarImpConf {
00319 public:
00321 static const int idx_c = Gecode::Int::IntVarImpConf::idx_c;
00323 static const int idx_d = Gecode::Int::IntVarImpConf::idx_d;
00325 static const int med_lst = Gecode::Int::IntVarImpConf::med_lst;
00326 };
00327 }}
00328 #endif
00329 #ifdef GECODE_HAS_SET_VARS
00330 namespace Gecode { namespace Set {
00332 class SetVarImpConf {
00333 public:
00335 static const int idx_c = Gecode::Int::BoolVarImpConf::idx_c+1;
00337 static const int idx_d = Gecode::Int::BoolVarImpConf::idx_d;
00339 static const Gecode::PropCond pc_max = PC_SET_ANY;
00341 static const int free_bits = 0;
00343 static const int med_fst = Gecode::Int::BoolVarImpConf::med_lst;
00345 static const int med_lst = med_fst + 4;
00347 static const int med_mask = ((1 << 4) - 1) << med_fst;
00349 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2);
00351 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me);
00352 };
00353 }}
00354 #else
00355 namespace Gecode { namespace Set {
00357 class SetVarImpConf {
00358 public:
00360 static const int idx_c = Gecode::Int::BoolVarImpConf::idx_c;
00362 static const int idx_d = Gecode::Int::BoolVarImpConf::idx_d;
00364 static const int med_lst = Gecode::Int::BoolVarImpConf::med_lst;
00365 };
00366 }}
00367 #endif
00368
00369 namespace Gecode {
00370
00372 class AllVarConf {
00373 public:
00375 static const int idx_c = Gecode::Set::SetVarImpConf::idx_c+1;
00377 static const int idx_d = Gecode::Set::SetVarImpConf::idx_d+1;
00379 static ModEventDelta med_combine(ModEventDelta med1, ModEventDelta med2);
00380 };
00381
00382 }
00383
00384 #ifdef GECODE_HAS_INT_VARS
00385 namespace Gecode { namespace Int {
00386 forceinline Gecode::ModEvent
00387 IntVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) {
00388 static const Gecode::ModEvent me_c = (
00389 (
00390 (ME_INT_NONE << 0) |
00391 (ME_INT_VAL << 2) |
00392 (ME_INT_BND << 4) |
00393 (ME_INT_DOM << 6)
00394 ) |
00395 (
00396 (ME_INT_VAL << 8) |
00397 (ME_INT_VAL << 10) |
00398 (ME_INT_VAL << 12) |
00399 (ME_INT_VAL << 14)
00400 ) |
00401 (
00402 (ME_INT_BND << 16) |
00403 (ME_INT_VAL << 18) |
00404 (ME_INT_BND << 20) |
00405 (ME_INT_BND << 22)
00406 ) |
00407 (
00408 (ME_INT_DOM << 24) |
00409 (ME_INT_VAL << 26) |
00410 (ME_INT_BND << 28) |
00411 (ME_INT_DOM << 30)
00412 )
00413 );
00414 return ((me_c >> (me2 << 3)) >> (me1 << 1)) & 3;
00415 }
00416 forceinline bool
00417 IntVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) {
00418 switch (me) {
00419 case ME_INT_NONE:
00420 return false;
00421 case ME_INT_VAL:
00422 {
00423 Gecode::ModEventDelta med_int = med & med_mask;
00424 if (med_int == (ME_INT_VAL << med_fst))
00425 return false;
00426 med ^= med_int;
00427 med ^= ME_INT_VAL << med_fst;
00428 break;
00429 }
00430 case ME_INT_BND:
00431 {
00432 static const Gecode::ModEvent me_c = (
00433 ((ME_INT_NONE ^ ME_INT_BND ) << 0) |
00434 ((ME_INT_VAL ^ ME_INT_VAL ) << 4) |
00435 ((ME_INT_BND ^ ME_INT_BND ) << 8) |
00436 ((ME_INT_DOM ^ ME_INT_BND ) << 12)
00437 );
00438 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00439 Gecode::ModEvent me_n = (me_c >> (me_o << 2)) & (med_mask >> med_fst);
00440 if (me_n == 0)
00441 return false;
00442 med ^= me_n << med_fst;
00443 break;
00444 }
00445 case ME_INT_DOM:
00446 {
00447 Gecode::ModEventDelta med_int = med & med_mask;
00448 if (med_int != 0)
00449 return false;
00450 med |= ME_INT_DOM << med_fst;
00451 break;
00452 }
00453 default: GECODE_NEVER;
00454 }
00455 return true;
00456 }
00457
00458 }}
00459 #endif
00460 #ifdef GECODE_HAS_INT_VARS
00461 namespace Gecode { namespace Int {
00462 forceinline Gecode::ModEvent
00463 BoolVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) {
00464 return me1 | me2;
00465 }
00466 forceinline bool
00467 BoolVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) {
00468 switch (me) {
00469 case ME_BOOL_NONE:
00470 return false;
00471 case ME_BOOL_VAL:
00472 if ((med & (ME_BOOL_VAL << med_fst)) != 0)
00473 return false;
00474 med |= ME_BOOL_VAL << med_fst;
00475 break;
00476 default: GECODE_NEVER;
00477 }
00478 return true;
00479 }
00480
00481 }}
00482 #endif
00483 #ifdef GECODE_HAS_SET_VARS
00484 namespace Gecode { namespace Set {
00485 forceinline Gecode::ModEvent
00486 SetVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) {
00487 static const Gecode::ModEvent me_c[ME_SET_CBB+1][ME_SET_CBB+1] = {
00488 {
00489 ME_SET_NONE,
00490 ME_SET_VAL ,
00491 ME_SET_CARD,
00492 ME_SET_LUB ,
00493 ME_SET_GLB ,
00494 ME_SET_BB ,
00495 ME_SET_CLUB,
00496 ME_SET_CGLB,
00497 ME_SET_CBB
00498 },
00499 {
00500 ME_SET_VAL ,
00501 ME_SET_VAL ,
00502 ME_SET_VAL ,
00503 ME_SET_VAL ,
00504 ME_SET_VAL ,
00505 ME_SET_VAL ,
00506 ME_SET_VAL ,
00507 ME_SET_VAL ,
00508 ME_SET_VAL
00509 },
00510 {
00511 ME_SET_CARD,
00512 ME_SET_VAL ,
00513 ME_SET_CARD,
00514 ME_SET_CLUB,
00515 ME_SET_CGLB,
00516 ME_SET_CBB ,
00517 ME_SET_CLUB,
00518 ME_SET_CGLB,
00519 ME_SET_CBB
00520 },
00521 {
00522 ME_SET_LUB ,
00523 ME_SET_VAL ,
00524 ME_SET_CLUB,
00525 ME_SET_LUB ,
00526 ME_SET_BB ,
00527 ME_SET_BB ,
00528 ME_SET_CLUB,
00529 ME_SET_CBB ,
00530 ME_SET_CBB
00531 },
00532 {
00533 ME_SET_GLB ,
00534 ME_SET_VAL ,
00535 ME_SET_CGLB,
00536 ME_SET_BB ,
00537 ME_SET_GLB ,
00538 ME_SET_BB ,
00539 ME_SET_CBB ,
00540 ME_SET_CGLB,
00541 ME_SET_CBB
00542 },
00543 {
00544 ME_SET_BB ,
00545 ME_SET_VAL ,
00546 ME_SET_CBB ,
00547 ME_SET_BB ,
00548 ME_SET_BB ,
00549 ME_SET_BB ,
00550 ME_SET_CBB ,
00551 ME_SET_CBB ,
00552 ME_SET_CBB
00553 },
00554 {
00555 ME_SET_CLUB,
00556 ME_SET_VAL ,
00557 ME_SET_CLUB,
00558 ME_SET_CLUB,
00559 ME_SET_CBB ,
00560 ME_SET_CBB ,
00561 ME_SET_CLUB,
00562 ME_SET_CBB ,
00563 ME_SET_CBB
00564 },
00565 {
00566 ME_SET_CGLB,
00567 ME_SET_VAL ,
00568 ME_SET_CGLB,
00569 ME_SET_CBB ,
00570 ME_SET_CGLB,
00571 ME_SET_CBB ,
00572 ME_SET_CBB ,
00573 ME_SET_CGLB,
00574 ME_SET_CBB
00575 },
00576 {
00577 ME_SET_CBB ,
00578 ME_SET_VAL ,
00579 ME_SET_CBB ,
00580 ME_SET_CBB ,
00581 ME_SET_CBB ,
00582 ME_SET_CBB ,
00583 ME_SET_CBB ,
00584 ME_SET_CBB ,
00585 ME_SET_CBB
00586 }
00587 };
00588 return me_c[me1][me2];
00589 }
00590 forceinline bool
00591 SetVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) {
00592 switch (me) {
00593 case ME_SET_NONE:
00594 return false;
00595 case ME_SET_VAL:
00596 {
00597 Gecode::ModEventDelta med_set = med & med_mask;
00598 if (med_set == (ME_SET_VAL << med_fst))
00599 return false;
00600 med ^= med_set;
00601 med ^= ME_SET_VAL << med_fst;
00602 break;
00603 }
00604 case ME_SET_CARD:
00605 {
00606 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00607 (ME_SET_NONE ^ ME_SET_CARD) << med_fst,
00608 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00609 (ME_SET_CARD ^ ME_SET_CARD) << med_fst,
00610 (ME_SET_LUB ^ ME_SET_CLUB) << med_fst,
00611 (ME_SET_GLB ^ ME_SET_CGLB) << med_fst,
00612 (ME_SET_BB ^ ME_SET_CBB ) << med_fst,
00613 (ME_SET_CLUB ^ ME_SET_CLUB) << med_fst,
00614 (ME_SET_CGLB ^ ME_SET_CGLB) << med_fst,
00615 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00616 };
00617 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00618 Gecode::ModEventDelta med_n = me_c[me_o];
00619 if (med_n == 0)
00620 return false;
00621 med ^= med_n;
00622 break;
00623 }
00624 case ME_SET_LUB:
00625 {
00626 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00627 (ME_SET_NONE ^ ME_SET_LUB ) << med_fst,
00628 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00629 (ME_SET_CARD ^ ME_SET_CLUB) << med_fst,
00630 (ME_SET_LUB ^ ME_SET_LUB ) << med_fst,
00631 (ME_SET_GLB ^ ME_SET_BB ) << med_fst,
00632 (ME_SET_BB ^ ME_SET_BB ) << med_fst,
00633 (ME_SET_CLUB ^ ME_SET_CLUB) << med_fst,
00634 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst,
00635 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00636 };
00637 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00638 Gecode::ModEventDelta med_n = me_c[me_o];
00639 if (med_n == 0)
00640 return false;
00641 med ^= med_n;
00642 break;
00643 }
00644 case ME_SET_GLB:
00645 {
00646 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00647 (ME_SET_NONE ^ ME_SET_GLB ) << med_fst,
00648 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00649 (ME_SET_CARD ^ ME_SET_CGLB) << med_fst,
00650 (ME_SET_LUB ^ ME_SET_BB ) << med_fst,
00651 (ME_SET_GLB ^ ME_SET_GLB ) << med_fst,
00652 (ME_SET_BB ^ ME_SET_BB ) << med_fst,
00653 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst,
00654 (ME_SET_CGLB ^ ME_SET_CGLB) << med_fst,
00655 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00656 };
00657 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00658 Gecode::ModEventDelta med_n = me_c[me_o];
00659 if (med_n == 0)
00660 return false;
00661 med ^= med_n;
00662 break;
00663 }
00664 case ME_SET_BB:
00665 {
00666 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00667 (ME_SET_NONE ^ ME_SET_BB ) << med_fst,
00668 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00669 (ME_SET_CARD ^ ME_SET_CBB ) << med_fst,
00670 (ME_SET_LUB ^ ME_SET_BB ) << med_fst,
00671 (ME_SET_GLB ^ ME_SET_BB ) << med_fst,
00672 (ME_SET_BB ^ ME_SET_BB ) << med_fst,
00673 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst,
00674 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst,
00675 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00676 };
00677 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00678 Gecode::ModEventDelta med_n = me_c[me_o];
00679 if (med_n == 0)
00680 return false;
00681 med ^= med_n;
00682 break;
00683 }
00684 case ME_SET_CLUB:
00685 {
00686 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00687 (ME_SET_NONE ^ ME_SET_CLUB) << med_fst,
00688 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00689 (ME_SET_CARD ^ ME_SET_CLUB) << med_fst,
00690 (ME_SET_LUB ^ ME_SET_CLUB) << med_fst,
00691 (ME_SET_GLB ^ ME_SET_CBB ) << med_fst,
00692 (ME_SET_BB ^ ME_SET_CBB ) << med_fst,
00693 (ME_SET_CLUB ^ ME_SET_CLUB) << med_fst,
00694 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst,
00695 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00696 };
00697 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00698 Gecode::ModEventDelta med_n = me_c[me_o];
00699 if (med_n == 0)
00700 return false;
00701 med ^= med_n;
00702 break;
00703 }
00704 case ME_SET_CGLB:
00705 {
00706 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00707 (ME_SET_NONE ^ ME_SET_CGLB) << med_fst,
00708 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00709 (ME_SET_CARD ^ ME_SET_CGLB) << med_fst,
00710 (ME_SET_LUB ^ ME_SET_CBB ) << med_fst,
00711 (ME_SET_GLB ^ ME_SET_CGLB) << med_fst,
00712 (ME_SET_BB ^ ME_SET_CBB ) << med_fst,
00713 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst,
00714 (ME_SET_CGLB ^ ME_SET_CGLB) << med_fst,
00715 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00716 };
00717 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00718 Gecode::ModEventDelta med_n = me_c[me_o];
00719 if (med_n == 0)
00720 return false;
00721 med ^= med_n;
00722 break;
00723 }
00724 case ME_SET_CBB:
00725 {
00726 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00727 (ME_SET_NONE ^ ME_SET_CBB ) << med_fst,
00728 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00729 (ME_SET_CARD ^ ME_SET_CBB ) << med_fst,
00730 (ME_SET_LUB ^ ME_SET_CBB ) << med_fst,
00731 (ME_SET_GLB ^ ME_SET_CBB ) << med_fst,
00732 (ME_SET_BB ^ ME_SET_CBB ) << med_fst,
00733 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst,
00734 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst,
00735 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00736 };
00737 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00738 Gecode::ModEventDelta med_n = me_c[me_o];
00739 if (med_n == 0)
00740 return false;
00741 med ^= med_n;
00742 break;
00743 }
00744 default: GECODE_NEVER;
00745 }
00746 return true;
00747 }
00748
00749 }}
00750 #endif
00751 namespace Gecode {
00752 forceinline ModEventDelta
00753 AllVarConf::med_combine(ModEventDelta med1, ModEventDelta med2) {
00754 #ifdef GECODE_HAS_INT_VARS
00755 (void) Gecode::Int::IntVarImpConf::med_update(med1,(med2 & Gecode::Int::IntVarImpConf::med_mask) >> Gecode::Int::IntVarImpConf::med_fst);
00756 #endif
00757 #ifdef GECODE_HAS_INT_VARS
00758 (void) Gecode::Int::BoolVarImpConf::med_update(med1,(med2 & Gecode::Int::BoolVarImpConf::med_mask) >> Gecode::Int::BoolVarImpConf::med_fst);
00759 #endif
00760 #ifdef GECODE_HAS_SET_VARS
00761 (void) Gecode::Set::SetVarImpConf::med_update(med1,(med2 & Gecode::Set::SetVarImpConf::med_mask) >> Gecode::Set::SetVarImpConf::med_fst);
00762 #endif
00763 return med1;
00764 }
00765 }
00766
00767