select-view.icc
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Guido Tack <tack@gecode.org> 00004 * Christian Schulte <schulte@gecode.org> 00005 * 00006 * Contributing authors: 00007 * Gabor Szokoli <szokoli@gecode.org> 00008 * 00009 * Copyright: 00010 * Guido Tack, 2004 00011 * Christian Schulte, 2004 00012 * Gabor Szokoli, 2004 00013 * 00014 * Last modified: 00015 * $Date: 2005-08-05 09:40:23 +0200 (Fri, 05 Aug 2005) $ by $Author: tack $ 00016 * $Revision: 2138 $ 00017 * 00018 * This file is part of Gecode, the generic constraint 00019 * development environment: 00020 * http://www.gecode.org 00021 * 00022 * See the file "LICENSE" for information on usage and 00023 * redistribution of this file, and for a 00024 * DISCLAIMER OF ALL WARRANTIES. 00025 * 00026 */ 00027 00028 namespace Gecode { namespace Set { namespace Branch { 00029 00030 forceinline ViewSelStatus 00031 ByNone::init(SetView) { 00032 return VSS_COMMIT; 00033 } 00034 forceinline ViewSelStatus 00035 ByNone::select(SetView) { 00036 assert(false); 00037 return VSS_NONE; 00038 } 00039 00040 forceinline ViewSelStatus 00041 ByMinCard::init(SetView x) { 00042 minCard = x.unknownSize(); 00043 return (minCard == 1) ? VSS_COMMIT : VSS_SELECT; 00044 } 00045 forceinline ViewSelStatus 00046 ByMinCard::select(SetView x) { 00047 unsigned int us = x.unknownSize(); 00048 if (us < minCard) { 00049 minCard = us; 00050 return (minCard == 1) ? VSS_COMMIT : VSS_SELECT; 00051 } 00052 return VSS_NONE; 00053 } 00054 00055 forceinline ViewSelStatus 00056 ByMaxCard::init(SetView x) { 00057 maxCard = x.unknownSize(); 00058 return VSS_SELECT; 00059 } 00060 forceinline ViewSelStatus 00061 ByMaxCard::select(SetView x) { 00062 unsigned int us = x.unknownSize(); 00063 if (us > maxCard) { 00064 maxCard = us; return VSS_SELECT; 00065 } 00066 return VSS_NONE; 00067 } 00068 00069 forceinline ViewSelStatus 00070 ByMinUnknown::init(SetView x) { 00071 UnknownRanges<SetView> unknown(x); 00072 minUnknown = unknown.min(); 00073 return VSS_SELECT; 00074 } 00075 forceinline ViewSelStatus 00076 ByMinUnknown::select(SetView x) { 00077 UnknownRanges<SetView> unknown(x); 00078 int um = unknown.min(); 00079 if (um < minUnknown) { 00080 minUnknown = um; return VSS_SELECT; 00081 } 00082 return VSS_NONE; 00083 } 00084 00085 forceinline ViewSelStatus 00086 ByMaxUnknown::init (SetView x) { 00087 UnknownRanges<SetView> unknown(x); 00088 do { 00089 maxUnknown = unknown.max(); 00090 ++unknown; 00091 } while(unknown()); 00092 return VSS_SELECT; 00093 } 00094 forceinline ViewSelStatus 00095 ByMaxUnknown::select(SetView x) { 00096 UnknownRanges<SetView> unknown(x); 00097 int um = 0; 00098 assert(unknown()); 00099 do { 00100 um = unknown.max(); 00101 ++unknown; 00102 } while(unknown()); 00103 if (um > maxUnknown) { 00104 maxUnknown = um; return VSS_SELECT; 00105 } 00106 return VSS_NONE; 00107 } 00108 00109 }}} 00110 00111 // STATISTICS: set-branch 00112