common.hpp
Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 00002 /* 00003 * Main authors: 00004 * Guido Tack <tack@gecode.org> 00005 * Christian Schulte <schulte@gecode.org> 00006 * 00007 * Contributing authors: 00008 * Gabor Szokoli <szokoli@gecode.org> 00009 * 00010 * Copyright: 00011 * Guido Tack, 2004 00012 * Christian Schulte, 2004 00013 * Gabor Szokoli, 2004 00014 * 00015 * Last modified: 00016 * $Date: 2010-06-02 11:00:04 +0200 (Wed, 02 Jun 2010) $ by $Author: schulte $ 00017 * $Revision: 11004 $ 00018 * 00019 * This file is part of Gecode, the generic constraint 00020 * development environment: 00021 * http://www.gecode.org 00022 * 00023 * Permission is hereby granted, free of charge, to any person obtaining 00024 * a copy of this software and associated documentation files (the 00025 * "Software"), to deal in the Software without restriction, including 00026 * without limitation the rights to use, copy, modify, merge, publish, 00027 * distribute, sublicense, and/or sell copies of the Software, and to 00028 * permit persons to whom the Software is furnished to do so, subject to 00029 * the following conditions: 00030 * 00031 * The above copyright notice and this permission notice shall be 00032 * included in all copies or substantial portions of the Software. 00033 * 00034 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00035 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00036 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00037 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00038 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00039 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00040 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00041 * 00042 */ 00043 00044 #define GECODE_SET_ME_CHECK_VAL(p,f) { \ 00045 ModEvent __me__ ## __LINE__ = (p); \ 00046 if (me_failed(__me__ ## __LINE__)) return ES_FAILED; \ 00047 if (ME_GEN_ASSIGNED==(__me__ ## __LINE__))f=true; } 00048 00049 #define GECODE_SET_ME_CHECK_VAL_B(modified, tell, f) \ 00050 { \ 00051 ModEvent me = (tell); \ 00052 modified |= me_modified(me); \ 00053 if (ME_GEN_ASSIGNED==(me))f=true; \ 00054 GECODE_ME_CHECK(me); \ 00055 } 00056 00057 namespace Gecode { namespace Set { namespace Rel { 00058 00059 forceinline 00060 bool subsumesME(ModEvent me0, ModEvent me1, ModEvent me2, ModEvent me) { 00061 ModEvent cme = SetVarImp::me_combine(me0,SetVarImp::me_combine(me1, me2)); 00062 return SetVarImp::me_combine(cme, me)==cme; 00063 } 00064 forceinline 00065 bool subsumesME(ModEvent me0, ModEvent me1, ModEvent me) { 00066 ModEvent cme = SetVarImp::me_combine(me0, me1); 00067 return SetVarImp::me_combine(cme, me)==cme; 00068 } 00069 forceinline 00070 bool subsumesME(ModEvent me0, ModEvent me) { 00071 return SetVarImp::me_combine(me0, me)==me0; 00072 } 00073 00074 forceinline 00075 bool testSetEventLB(ModEvent me0, ModEvent me1, ModEvent me2) { 00076 return subsumesME(me0, me1, me2, ME_SET_GLB); 00077 } 00078 forceinline 00079 bool testSetEventUB(ModEvent me0, ModEvent me1, ModEvent me2) { 00080 return subsumesME(me0, me1, me2, ME_SET_LUB); 00081 } 00082 forceinline 00083 bool testSetEventAnyB(ModEvent me0, ModEvent me1, ModEvent me2) { 00084 return ( me0!=ME_SET_CARD || me1!=ME_SET_CARD || me2!=ME_SET_CARD ); 00085 } 00086 forceinline 00087 bool testSetEventCard(ModEvent me0, ModEvent me1, ModEvent me2) { 00088 return subsumesME(me0, me1, me2, ME_SET_CARD); 00089 } 00090 forceinline 00091 bool testSetEventLB(ModEvent me0, ModEvent me1) { 00092 return subsumesME(me0, me1, ME_SET_GLB); 00093 } 00094 forceinline 00095 bool testSetEventUB(ModEvent me0, ModEvent me1) { 00096 return subsumesME(me0, me1, ME_SET_LUB); 00097 } 00098 forceinline 00099 bool testSetEventAnyB(ModEvent me0, ModEvent me1) { 00100 return ( me0!=ME_SET_CARD || me1!=ME_SET_CARD ); 00101 } 00102 forceinline 00103 bool testSetEventCard(ModEvent me0, ModEvent me1) { 00104 return subsumesME(me0, me1, ME_SET_CARD); 00105 } 00106 forceinline 00107 bool testSetEventLB(ModEvent me0) { 00108 return subsumesME(me0, ME_SET_GLB); 00109 } 00110 forceinline 00111 bool testSetEventUB(ModEvent me0) { 00112 return subsumesME(me0, ME_SET_LUB); 00113 } 00114 forceinline 00115 bool testSetEventAnyB(ModEvent me0) { 00116 return ( me0!=ME_SET_CARD ); 00117 } 00118 forceinline 00119 bool testSetEventCard(ModEvent me0) { 00120 return subsumesME(me0, ME_SET_CARD); 00121 } 00122 00123 }}} 00124 00125 // STATISTICS: set-prop