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
00044 #ifdef GECODE_HAS_INT_VARS
00045 namespace Gecode { namespace Int {
00051
00052 const Gecode::ModEvent ME_INT_FAILED = Gecode::ME_GEN_FAILED;
00054 const Gecode::ModEvent ME_INT_NONE = Gecode::ME_GEN_NONE;
00056 const Gecode::ModEvent ME_INT_VAL = Gecode::ME_GEN_ASSIGNED;
00065 const Gecode::ModEvent ME_INT_BND = Gecode::ME_GEN_ASSIGNED + 1;
00072 const Gecode::ModEvent ME_INT_DOM = Gecode::ME_GEN_ASSIGNED + 2;
00074 const Gecode::PropCond PC_INT_NONE = Gecode::PC_GEN_NONE;
00082 const Gecode::PropCond PC_INT_VAL = Gecode::PC_GEN_ASSIGNED;
00091 const Gecode::PropCond PC_INT_BND = Gecode::PC_GEN_ASSIGNED + 1;
00100 const Gecode::PropCond PC_INT_DOM = Gecode::PC_GEN_ASSIGNED + 2;
00102 }}
00103 #endif
00104 #ifdef GECODE_HAS_INT_VARS
00105 namespace Gecode { namespace Int {
00111
00112 const Gecode::ModEvent ME_BOOL_FAILED = Gecode::ME_GEN_FAILED;
00114 const Gecode::ModEvent ME_BOOL_NONE = Gecode::ME_GEN_NONE;
00116 const Gecode::ModEvent ME_BOOL_VAL = Gecode::ME_GEN_ASSIGNED;
00118 const Gecode::PropCond PC_BOOL_NONE = Gecode::PC_GEN_NONE;
00126 const Gecode::PropCond PC_BOOL_VAL = Gecode::PC_GEN_ASSIGNED;
00128 }}
00129 #endif
00130 #ifdef GECODE_HAS_SET_VARS
00131 namespace Gecode { namespace Set {
00137
00138 const Gecode::ModEvent ME_SET_FAILED = Gecode::ME_GEN_FAILED;
00140 const Gecode::ModEvent ME_SET_NONE = Gecode::ME_GEN_NONE;
00142 const Gecode::ModEvent ME_SET_VAL = Gecode::ME_GEN_ASSIGNED;
00148 const Gecode::ModEvent ME_SET_CARD = Gecode::ME_GEN_ASSIGNED + 1;
00156 const Gecode::ModEvent ME_SET_LUB = Gecode::ME_GEN_ASSIGNED + 2;
00164 const Gecode::ModEvent ME_SET_GLB = Gecode::ME_GEN_ASSIGNED + 3;
00172 const Gecode::ModEvent ME_SET_BB = Gecode::ME_GEN_ASSIGNED + 4;
00179 const Gecode::ModEvent ME_SET_CLUB = Gecode::ME_GEN_ASSIGNED + 5;
00186 const Gecode::ModEvent ME_SET_CGLB = Gecode::ME_GEN_ASSIGNED + 6;
00197 const Gecode::ModEvent ME_SET_CBB = Gecode::ME_GEN_ASSIGNED + 7;
00199 const Gecode::PropCond PC_SET_NONE = Gecode::PC_GEN_NONE;
00207 const Gecode::PropCond PC_SET_VAL = Gecode::PC_GEN_ASSIGNED;
00216 const Gecode::PropCond PC_SET_CARD = Gecode::PC_GEN_ASSIGNED + 1;
00227 const Gecode::PropCond PC_SET_CLUB = Gecode::PC_GEN_ASSIGNED + 2;
00238 const Gecode::PropCond PC_SET_CGLB = Gecode::PC_GEN_ASSIGNED + 3;
00248 const Gecode::PropCond PC_SET_ANY = Gecode::PC_GEN_ASSIGNED + 4;
00250 }}
00251 #endif
00252 #ifdef GECODE_HAS_INT_VARS
00253 namespace Gecode { namespace Int {
00255 class IntVarImpConf {
00256 public:
00258 static const int idx_c = 0;
00260 static const int idx_d = -1;
00262 static const Gecode::PropCond pc_max = PC_INT_DOM;
00264 static const int free_bits = 0;
00266 static const int med_fst = 0;
00268 static const int med_lst = med_fst + 2;
00270 static const int med_mask = ((1 << 2) - 1) << med_fst;
00272 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2);
00274 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me);
00275 };
00276 }}
00277 #else
00278 namespace Gecode { namespace Int {
00280 class IntVarImpConf {
00281 public:
00283 static const int idx_c = -1;
00285 static const int idx_d = -1;
00287 static const int med_lst = 0;
00288 };
00289 }}
00290 #endif
00291 #ifdef GECODE_HAS_INT_VARS
00292 namespace Gecode { namespace Int {
00294 class BoolVarImpConf {
00295 public:
00297 static const int idx_c = Gecode::Int::IntVarImpConf::idx_c+1;
00299 static const int idx_d = Gecode::Int::IntVarImpConf::idx_d;
00301 static const Gecode::PropCond pc_max = PC_BOOL_VAL;
00303 static const int free_bits = 2;
00305 static const int med_fst = Gecode::Int::IntVarImpConf::med_lst;
00307 static const int med_lst = med_fst + 1;
00309 static const int med_mask = ((1 << 1) - 1) << med_fst;
00311 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2);
00313 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me);
00314 };
00315 }}
00316 #else
00317 namespace Gecode { namespace Int {
00319 class BoolVarImpConf {
00320 public:
00322 static const int idx_c = Gecode::Int::IntVarImpConf::idx_c;
00324 static const int idx_d = Gecode::Int::IntVarImpConf::idx_d;
00326 static const int med_lst = Gecode::Int::IntVarImpConf::med_lst;
00327 };
00328 }}
00329 #endif
00330 #ifdef GECODE_HAS_SET_VARS
00331 namespace Gecode { namespace Set {
00333 class SetVarImpConf {
00334 public:
00336 static const int idx_c = Gecode::Int::BoolVarImpConf::idx_c+1;
00338 static const int idx_d = Gecode::Int::BoolVarImpConf::idx_d;
00340 static const Gecode::PropCond pc_max = PC_SET_ANY;
00342 static const int free_bits = 0;
00344 static const int med_fst = Gecode::Int::BoolVarImpConf::med_lst;
00346 static const int med_lst = med_fst + 4;
00348 static const int med_mask = ((1 << 4) - 1) << med_fst;
00350 static Gecode::ModEvent me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2);
00352 static bool med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me);
00353 };
00354 }}
00355 #else
00356 namespace Gecode { namespace Set {
00358 class SetVarImpConf {
00359 public:
00361 static const int idx_c = Gecode::Int::BoolVarImpConf::idx_c;
00363 static const int idx_d = Gecode::Int::BoolVarImpConf::idx_d;
00365 static const int med_lst = Gecode::Int::BoolVarImpConf::med_lst;
00366 };
00367 }}
00368 #endif
00369
00370 namespace Gecode {
00371
00373 class AllVarConf {
00374 public:
00376 static const int idx_c = Gecode::Set::SetVarImpConf::idx_c+1;
00378 static const int idx_d = Gecode::Set::SetVarImpConf::idx_d+1;
00380 static ModEventDelta med_combine(ModEventDelta med1, ModEventDelta med2);
00381 };
00382
00383 }
00384
00385 #ifdef GECODE_HAS_INT_VARS
00386 namespace Gecode { namespace Int {
00387 forceinline Gecode::ModEvent
00388 IntVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) {
00389 static const Gecode::ModEvent me_c = (
00390 (
00391 (ME_INT_NONE << 0) |
00392 (ME_INT_VAL << 2) |
00393 (ME_INT_BND << 4) |
00394 (ME_INT_DOM << 6)
00395 ) |
00396 (
00397 (ME_INT_VAL << 8) |
00398 (ME_INT_VAL << 10) |
00399 (ME_INT_VAL << 12) |
00400 (ME_INT_VAL << 14)
00401 ) |
00402 (
00403 (ME_INT_BND << 16) |
00404 (ME_INT_VAL << 18) |
00405 (ME_INT_BND << 20) |
00406 (ME_INT_BND << 22)
00407 ) |
00408 (
00409 (ME_INT_DOM << 24) |
00410 (ME_INT_VAL << 26) |
00411 (ME_INT_BND << 28) |
00412 (ME_INT_DOM << 30)
00413 )
00414 );
00415 return ((me_c >> (me2 << 3)) >> (me1 << 1)) & 3;
00416 }
00417 forceinline bool
00418 IntVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) {
00419 switch (me) {
00420 case ME_INT_NONE:
00421 return false;
00422 case ME_INT_VAL:
00423 {
00424 Gecode::ModEventDelta med_int = med & med_mask;
00425 if (med_int == (ME_INT_VAL << med_fst))
00426 return false;
00427 med ^= med_int;
00428 med ^= ME_INT_VAL << med_fst;
00429 break;
00430 }
00431 case ME_INT_BND:
00432 {
00433 static const Gecode::ModEvent me_c = (
00434 ((ME_INT_NONE ^ ME_INT_BND ) << 0) |
00435 ((ME_INT_VAL ^ ME_INT_VAL ) << 4) |
00436 ((ME_INT_BND ^ ME_INT_BND ) << 8) |
00437 ((ME_INT_DOM ^ ME_INT_BND ) << 12)
00438 );
00439 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00440 Gecode::ModEvent me_n = (me_c >> (me_o << 2)) & (med_mask >> med_fst);
00441 if (me_n == 0)
00442 return false;
00443 med ^= me_n << med_fst;
00444 break;
00445 }
00446 case ME_INT_DOM:
00447 {
00448 Gecode::ModEventDelta med_int = med & med_mask;
00449 if (med_int != 0)
00450 return false;
00451 med |= ME_INT_DOM << med_fst;
00452 break;
00453 }
00454 default: GECODE_NEVER;
00455 }
00456 return true;
00457 }
00458
00459 }}
00460 #endif
00461 #ifdef GECODE_HAS_INT_VARS
00462 namespace Gecode { namespace Int {
00463 forceinline Gecode::ModEvent
00464 BoolVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) {
00465 return me1 | me2;
00466 }
00467 forceinline bool
00468 BoolVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) {
00469 switch (me) {
00470 case ME_BOOL_NONE:
00471 return false;
00472 case ME_BOOL_VAL:
00473 if ((med & (ME_BOOL_VAL << med_fst)) != 0)
00474 return false;
00475 med |= ME_BOOL_VAL << med_fst;
00476 break;
00477 default: GECODE_NEVER;
00478 }
00479 return true;
00480 }
00481
00482 }}
00483 #endif
00484 #ifdef GECODE_HAS_SET_VARS
00485 namespace Gecode { namespace Set {
00486 forceinline Gecode::ModEvent
00487 SetVarImpConf::me_combine(Gecode::ModEvent me1, Gecode::ModEvent me2) {
00488 static const Gecode::ModEvent me_c[ME_SET_CBB+1][ME_SET_CBB+1] = {
00489 {
00490 ME_SET_NONE,
00491 ME_SET_VAL ,
00492 ME_SET_CARD,
00493 ME_SET_LUB ,
00494 ME_SET_GLB ,
00495 ME_SET_BB ,
00496 ME_SET_CLUB,
00497 ME_SET_CGLB,
00498 ME_SET_CBB
00499 },
00500 {
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 ME_SET_VAL
00510 },
00511 {
00512 ME_SET_CARD,
00513 ME_SET_VAL ,
00514 ME_SET_CARD,
00515 ME_SET_CLUB,
00516 ME_SET_CGLB,
00517 ME_SET_CBB ,
00518 ME_SET_CLUB,
00519 ME_SET_CGLB,
00520 ME_SET_CBB
00521 },
00522 {
00523 ME_SET_LUB ,
00524 ME_SET_VAL ,
00525 ME_SET_CLUB,
00526 ME_SET_LUB ,
00527 ME_SET_BB ,
00528 ME_SET_BB ,
00529 ME_SET_CLUB,
00530 ME_SET_CBB ,
00531 ME_SET_CBB
00532 },
00533 {
00534 ME_SET_GLB ,
00535 ME_SET_VAL ,
00536 ME_SET_CGLB,
00537 ME_SET_BB ,
00538 ME_SET_GLB ,
00539 ME_SET_BB ,
00540 ME_SET_CBB ,
00541 ME_SET_CGLB,
00542 ME_SET_CBB
00543 },
00544 {
00545 ME_SET_BB ,
00546 ME_SET_VAL ,
00547 ME_SET_CBB ,
00548 ME_SET_BB ,
00549 ME_SET_BB ,
00550 ME_SET_BB ,
00551 ME_SET_CBB ,
00552 ME_SET_CBB ,
00553 ME_SET_CBB
00554 },
00555 {
00556 ME_SET_CLUB,
00557 ME_SET_VAL ,
00558 ME_SET_CLUB,
00559 ME_SET_CLUB,
00560 ME_SET_CBB ,
00561 ME_SET_CBB ,
00562 ME_SET_CLUB,
00563 ME_SET_CBB ,
00564 ME_SET_CBB
00565 },
00566 {
00567 ME_SET_CGLB,
00568 ME_SET_VAL ,
00569 ME_SET_CGLB,
00570 ME_SET_CBB ,
00571 ME_SET_CGLB,
00572 ME_SET_CBB ,
00573 ME_SET_CBB ,
00574 ME_SET_CGLB,
00575 ME_SET_CBB
00576 },
00577 {
00578 ME_SET_CBB ,
00579 ME_SET_VAL ,
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 ME_SET_CBB
00587 }
00588 };
00589 return me_c[me1][me2];
00590 }
00591 forceinline bool
00592 SetVarImpConf::med_update(Gecode::ModEventDelta& med, Gecode::ModEvent me) {
00593 switch (me) {
00594 case ME_SET_NONE:
00595 return false;
00596 case ME_SET_VAL:
00597 {
00598 Gecode::ModEventDelta med_set = med & med_mask;
00599 if (med_set == (ME_SET_VAL << med_fst))
00600 return false;
00601 med ^= med_set;
00602 med ^= ME_SET_VAL << med_fst;
00603 break;
00604 }
00605 case ME_SET_CARD:
00606 {
00607 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00608 (ME_SET_NONE ^ ME_SET_CARD) << med_fst,
00609 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00610 (ME_SET_CARD ^ ME_SET_CARD) << med_fst,
00611 (ME_SET_LUB ^ ME_SET_CLUB) << med_fst,
00612 (ME_SET_GLB ^ ME_SET_CGLB) << med_fst,
00613 (ME_SET_BB ^ ME_SET_CBB ) << med_fst,
00614 (ME_SET_CLUB ^ ME_SET_CLUB) << med_fst,
00615 (ME_SET_CGLB ^ ME_SET_CGLB) << med_fst,
00616 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00617 };
00618 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00619 Gecode::ModEventDelta med_n = me_c[me_o];
00620 if (med_n == 0)
00621 return false;
00622 med ^= med_n;
00623 break;
00624 }
00625 case ME_SET_LUB:
00626 {
00627 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00628 (ME_SET_NONE ^ ME_SET_LUB ) << med_fst,
00629 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00630 (ME_SET_CARD ^ ME_SET_CLUB) << med_fst,
00631 (ME_SET_LUB ^ ME_SET_LUB ) << med_fst,
00632 (ME_SET_GLB ^ ME_SET_BB ) << med_fst,
00633 (ME_SET_BB ^ ME_SET_BB ) << med_fst,
00634 (ME_SET_CLUB ^ ME_SET_CLUB) << med_fst,
00635 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst,
00636 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00637 };
00638 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00639 Gecode::ModEventDelta med_n = me_c[me_o];
00640 if (med_n == 0)
00641 return false;
00642 med ^= med_n;
00643 break;
00644 }
00645 case ME_SET_GLB:
00646 {
00647 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00648 (ME_SET_NONE ^ ME_SET_GLB ) << med_fst,
00649 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00650 (ME_SET_CARD ^ ME_SET_CGLB) << med_fst,
00651 (ME_SET_LUB ^ ME_SET_BB ) << med_fst,
00652 (ME_SET_GLB ^ ME_SET_GLB ) << med_fst,
00653 (ME_SET_BB ^ ME_SET_BB ) << med_fst,
00654 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst,
00655 (ME_SET_CGLB ^ ME_SET_CGLB) << med_fst,
00656 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00657 };
00658 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00659 Gecode::ModEventDelta med_n = me_c[me_o];
00660 if (med_n == 0)
00661 return false;
00662 med ^= med_n;
00663 break;
00664 }
00665 case ME_SET_BB:
00666 {
00667 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00668 (ME_SET_NONE ^ ME_SET_BB ) << med_fst,
00669 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00670 (ME_SET_CARD ^ ME_SET_CBB ) << med_fst,
00671 (ME_SET_LUB ^ ME_SET_BB ) << med_fst,
00672 (ME_SET_GLB ^ ME_SET_BB ) << med_fst,
00673 (ME_SET_BB ^ ME_SET_BB ) << med_fst,
00674 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst,
00675 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst,
00676 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00677 };
00678 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00679 Gecode::ModEventDelta med_n = me_c[me_o];
00680 if (med_n == 0)
00681 return false;
00682 med ^= med_n;
00683 break;
00684 }
00685 case ME_SET_CLUB:
00686 {
00687 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00688 (ME_SET_NONE ^ ME_SET_CLUB) << med_fst,
00689 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00690 (ME_SET_CARD ^ ME_SET_CLUB) << med_fst,
00691 (ME_SET_LUB ^ ME_SET_CLUB) << med_fst,
00692 (ME_SET_GLB ^ ME_SET_CBB ) << med_fst,
00693 (ME_SET_BB ^ ME_SET_CBB ) << med_fst,
00694 (ME_SET_CLUB ^ ME_SET_CLUB) << med_fst,
00695 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst,
00696 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00697 };
00698 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00699 Gecode::ModEventDelta med_n = me_c[me_o];
00700 if (med_n == 0)
00701 return false;
00702 med ^= med_n;
00703 break;
00704 }
00705 case ME_SET_CGLB:
00706 {
00707 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00708 (ME_SET_NONE ^ ME_SET_CGLB) << med_fst,
00709 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00710 (ME_SET_CARD ^ ME_SET_CGLB) << med_fst,
00711 (ME_SET_LUB ^ ME_SET_CBB ) << med_fst,
00712 (ME_SET_GLB ^ ME_SET_CGLB) << med_fst,
00713 (ME_SET_BB ^ ME_SET_CBB ) << med_fst,
00714 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst,
00715 (ME_SET_CGLB ^ ME_SET_CGLB) << med_fst,
00716 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00717 };
00718 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00719 Gecode::ModEventDelta med_n = me_c[me_o];
00720 if (med_n == 0)
00721 return false;
00722 med ^= med_n;
00723 break;
00724 }
00725 case ME_SET_CBB:
00726 {
00727 static const Gecode::ModEventDelta me_c[ME_SET_CBB+1] = {
00728 (ME_SET_NONE ^ ME_SET_CBB ) << med_fst,
00729 (ME_SET_VAL ^ ME_SET_VAL ) << med_fst,
00730 (ME_SET_CARD ^ ME_SET_CBB ) << med_fst,
00731 (ME_SET_LUB ^ ME_SET_CBB ) << med_fst,
00732 (ME_SET_GLB ^ ME_SET_CBB ) << med_fst,
00733 (ME_SET_BB ^ ME_SET_CBB ) << med_fst,
00734 (ME_SET_CLUB ^ ME_SET_CBB ) << med_fst,
00735 (ME_SET_CGLB ^ ME_SET_CBB ) << med_fst,
00736 (ME_SET_CBB ^ ME_SET_CBB ) << med_fst
00737 };
00738 Gecode::ModEvent me_o = (med & med_mask) >> med_fst;
00739 Gecode::ModEventDelta med_n = me_c[me_o];
00740 if (med_n == 0)
00741 return false;
00742 med ^= med_n;
00743 break;
00744 }
00745 default: GECODE_NEVER;
00746 }
00747 return true;
00748 }
00749
00750 }}
00751 #endif
00752 namespace Gecode {
00753 forceinline ModEventDelta
00754 AllVarConf::med_combine(ModEventDelta med1, ModEventDelta med2) {
00755 #ifdef GECODE_HAS_INT_VARS
00756 (void) Gecode::Int::IntVarImpConf::med_update(med1,(med2 & Gecode::Int::IntVarImpConf::med_mask) >> Gecode::Int::IntVarImpConf::med_fst);
00757 #endif
00758 #ifdef GECODE_HAS_INT_VARS
00759 (void) Gecode::Int::BoolVarImpConf::med_update(med1,(med2 & Gecode::Int::BoolVarImpConf::med_mask) >> Gecode::Int::BoolVarImpConf::med_fst);
00760 #endif
00761 #ifdef GECODE_HAS_SET_VARS
00762 (void) Gecode::Set::SetVarImpConf::med_update(med1,(med2 & Gecode::Set::SetVarImpConf::med_mask) >> Gecode::Set::SetVarImpConf::med_fst);
00763 #endif
00764 return med1;
00765 }
00766 }
00767
00768