Generated on Wed Nov 1 15:04:30 2006 for Gecode by doxygen 1.4.5

select-view.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2002
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-08-04 16:03:26 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $
00010  *     $Revision: 3512 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 namespace Gecode { namespace Int { namespace Branch {
00023 
00024   // Select first variable
00025   forceinline ViewSelStatus
00026   ByNone::init(const Space*, IntView) {
00027     return VSS_COMMIT;
00028   }
00029   forceinline ViewSelStatus
00030   ByNone::select(const Space*, IntView) {
00031     GECODE_NEVER;
00032     return VSS_NONE;
00033   }
00034 
00035   // Select variable with smallest min
00036   forceinline ViewSelStatus
00037   ByMinMin::init(const Space*, IntView x) {
00038     min = x.min();
00039     return VSS_SELECT;
00040   }
00041   forceinline ViewSelStatus
00042   ByMinMin::select(const Space*, IntView x) {
00043     if (x.min() < min) {
00044       min = x.min(); return VSS_SELECT;
00045     }
00046     return VSS_NONE;
00047   }
00048 
00049   // Select variable with largest min
00050   forceinline ViewSelStatus
00051   ByMinMax::init(const Space*, IntView x) {
00052     min = x.min();
00053     return VSS_SELECT;
00054   }
00055   forceinline ViewSelStatus
00056   ByMinMax::select(const Space*, IntView x) {
00057     if (x.min() > min) {
00058       min = x.min(); return VSS_SELECT;
00059     }
00060     return VSS_NONE;
00061   }
00062 
00063   // Select variable with smallest max
00064   forceinline ViewSelStatus
00065   ByMaxMin::init(const Space*, IntView x) {
00066     max = x.max();
00067     return VSS_SELECT;
00068   }
00069   forceinline ViewSelStatus
00070   ByMaxMin::select(const Space*, IntView x) {
00071     if (x.max() < max) {
00072       max = x.max(); return VSS_SELECT;
00073     }
00074     return VSS_NONE;
00075   }
00076 
00077   // Select variable with largest max
00078   forceinline ViewSelStatus
00079   ByMaxMax::init(const Space*, IntView x) {
00080     max = x.max();
00081     return VSS_SELECT;
00082   }
00083   forceinline ViewSelStatus
00084   ByMaxMax::select(const Space*, IntView x) {
00085     if (x.max() > max) {
00086       max = x.max(); return VSS_SELECT;
00087     }
00088     return VSS_NONE;
00089   }
00090 
00091   // Select variable with smallest size
00092   forceinline ViewSelStatus
00093   BySizeMin::init(const Space*, IntView x) {
00094     size = x.size();
00095     return (size == 2) ? VSS_COMMIT : VSS_SELECT;
00096   }
00097   forceinline ViewSelStatus
00098   BySizeMin::select(const Space*, IntView x) {
00099     if (x.size() < size) {
00100       size = x.size();
00101       return (size == 2) ? VSS_COMMIT : VSS_SELECT;
00102     }
00103     return VSS_NONE;
00104   }
00105 
00106   // Select variable with largest size
00107   forceinline ViewSelStatus
00108   BySizeMax::init(const Space*, IntView x) {
00109     size = x.size();
00110     return VSS_SELECT;
00111   }
00112   forceinline ViewSelStatus
00113   BySizeMax::select(const Space*, IntView x) {
00114     if (x.size() > size) {
00115       size = x.size(); return VSS_SELECT;
00116     }
00117     return VSS_NONE;
00118   }
00119 
00120   // Select variable with smallest degree (and smallest size in case of ties)
00121   forceinline ViewSelStatus
00122   ByDegreeMin::init(const Space*, IntView x) {
00123     degree = x.degree(); size = x.size();
00124     return VSS_SELECT;
00125   }
00126   forceinline ViewSelStatus
00127   ByDegreeMin::select(const Space*, IntView x) {
00128     if (x.degree() < degree) {
00129       degree = x.degree();
00130       size   = x.size();
00131       return VSS_SELECT;
00132     } else if ((x.degree() == degree) && (x.size() < size)) {
00133       size = x.size();
00134       return VSS_SELECT;
00135     }
00136     return VSS_NONE;
00137   }
00138 
00139   // Select variable with smallest degree (and smallest size in case of ties)
00140   forceinline ViewSelStatus
00141   ByDegreeMax::init(const Space*, IntView x) {
00142     degree = x.degree(); size = x.size();
00143     return VSS_SELECT;
00144   }
00145   forceinline ViewSelStatus
00146   ByDegreeMax::select(const Space*, IntView x) {
00147     if (x.degree() > degree) {
00148       degree = x.degree();
00149       size   = x.size();
00150       return VSS_SELECT;
00151     } else if ((x.degree() == degree) && (x.size() < size)) {
00152       size = x.size();
00153       return VSS_SELECT;
00154     }
00155     return VSS_NONE;
00156   }
00157 
00158   // Select variable with smallest min-regret
00159   forceinline ViewSelStatus
00160   ByRegretMinMin::init(const Space*, IntView x) {
00161     regret = x.regret_min();
00162     return (regret == 1) ? VSS_COMMIT : VSS_SELECT;
00163   }
00164   forceinline ViewSelStatus
00165   ByRegretMinMin::select(const Space*, IntView x) {
00166     if (x.regret_min() < regret) {
00167       regret = x.regret_min();
00168       return (regret == 1) ? VSS_COMMIT : VSS_SELECT;
00169     }
00170     return VSS_NONE;
00171   }
00172 
00173   // Select variable with largest min-regret
00174   forceinline ViewSelStatus
00175   ByRegretMinMax::init(const Space*, IntView x) {
00176     regret = x.regret_min();
00177     return VSS_SELECT;
00178   }
00179   forceinline ViewSelStatus
00180   ByRegretMinMax::select(const Space*, IntView x) {
00181     if (x.regret_min() > regret) {
00182       regret = x.regret_min(); return VSS_SELECT;
00183     }
00184     return VSS_NONE;
00185   }
00186 
00187   // Select variable with smallest max-regret
00188   forceinline ViewSelStatus
00189   ByRegretMaxMin::init(const Space*, IntView x) {
00190     regret = x.regret_max();
00191     return (regret == 1) ? VSS_COMMIT : VSS_SELECT;
00192   }
00193   forceinline ViewSelStatus
00194   ByRegretMaxMin::select(const Space*, IntView x) {
00195     if (x.regret_max() < regret) {
00196       regret = x.regret_max();
00197       return (regret == 1) ? VSS_COMMIT : VSS_SELECT;
00198     }
00199     return VSS_NONE;
00200   }
00201 
00202   // Select variable with smallest min-regret
00203   forceinline ViewSelStatus
00204   ByRegretMaxMax::init(const Space*, IntView x) {
00205     regret = x.regret_max();
00206     return VSS_SELECT;
00207   }
00208   forceinline ViewSelStatus
00209   ByRegretMaxMax::select(const Space*, IntView x) {
00210     if (x.regret_max() > regret) {
00211       regret = x.regret_max(); return VSS_SELECT;
00212     }
00213     return VSS_NONE;
00214   }
00215 
00216 }}}
00217 
00218 // STATISTICS: int-branch
00219