Generated on Fri Mar 20 15:56:15 2015 for Gecode by doxygen 1.6.3

branch-var.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2012
00008  *
00009  *  Last modified:
00010  *     $Date: 2013-05-22 21:29:33 +0200 (Wed, 22 May 2013) $ by $Author: tack $
00011  *     $Revision: 13656 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode {
00039 
00049   typedef double (*BranchTbl)(const Space& home, double w, double b);
00050 
00055   class VarBranch {
00056   protected:
00058     BranchTbl _tbl;
00060     Rnd _rnd;
00062     double _decay;
00064     AFC _afc;
00066     Activity _act;
00068     VoidFunction _mf;
00069   public:
00071     VarBranch(BranchTbl t);
00073     VarBranch(Rnd r);
00075     VarBranch(double d, BranchTbl t);
00077     VarBranch(AFC a, BranchTbl t);
00079     VarBranch(Activity a, BranchTbl t);
00081     VarBranch(void (*f)(void), BranchTbl t);
00083     BranchTbl tbl(void) const;
00085     Rnd rnd(void) const;
00087     double decay(void) const;
00089     AFC afc(void) const;
00091     void afc(AFC a);
00093     Activity activity(void) const;
00095     void activity(Activity a);
00097     VoidFunction merit(void) const;
00098   };
00099 
00100   // Variable branching
00101   forceinline 
00102   VarBranch::VarBranch(BranchTbl t)
00103     : _tbl(t), _decay(1.0) {}
00104 
00105   forceinline 
00106   VarBranch::VarBranch(double d, BranchTbl t)
00107     : _tbl(t), _decay(d) {}
00108 
00109   forceinline 
00110   VarBranch::VarBranch(AFC a, BranchTbl t)
00111     : _tbl(t), _decay(1.0), _afc(a) {
00112     if (!_afc.initialized())
00113       throw UninitializedAFC("VarBranch::VarBranch");
00114   }
00115 
00116   forceinline 
00117   VarBranch::VarBranch(Activity a, BranchTbl t)
00118     : _tbl(t), _decay(1.0), _act(a) {
00119     if (!_act.initialized())
00120       throw UninitializedActivity("VarBranch::VarBranch");
00121   }
00122 
00123   forceinline 
00124   VarBranch::VarBranch(Rnd r)
00125     : _tbl(NULL), _rnd(r), _decay(1.0) {
00126     if (!_rnd.initialized())
00127       throw UninitializedRnd("VarBranch::VarBranch");
00128   }
00129 
00130   forceinline 
00131   VarBranch::VarBranch(VoidFunction f, BranchTbl t)
00132     : _tbl(t), _decay(1.0), _mf(f) {}
00133 
00134   forceinline BranchTbl
00135   VarBranch::tbl(void) const {
00136     return _tbl;
00137   }
00138 
00139   inline Rnd
00140   VarBranch::rnd(void) const {
00141     return _rnd;
00142   }
00143 
00144   inline double
00145   VarBranch::decay(void) const {
00146     return _decay;
00147   }
00148 
00149   inline AFC
00150   VarBranch::afc(void) const {
00151     return _afc;
00152   }
00153 
00154   inline void
00155   VarBranch::afc(AFC a) {
00156     _afc=a;
00157   }
00158 
00159   inline Activity
00160   VarBranch::activity(void) const {
00161     return _act;
00162   }
00163 
00164   inline void
00165   VarBranch::activity(Activity a) {
00166     _act=a;
00167   }
00168 
00169   forceinline VoidFunction
00170   VarBranch::merit(void) const {
00171     return _mf;
00172   }
00173 
00174 }
00175 
00176 // STATISTICS: kernel-branch