Generated on Sat May 25 2013 18:00:33 for Gecode by doxygen 1.8.3.1
branch.hh
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2012
8  *
9  * Last modified:
10  * $Date: 2013-03-05 20:51:24 +0100 (Tue, 05 Mar 2013) $ by $Author: schulte $
11  * $Revision: 13438 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef __GECODE_INT_BRANCH_HH__
39 #define __GECODE_INT_BRANCH_HH__
40 
41 #include <gecode/int.hh>
42 
48 namespace Gecode { namespace Int { namespace Branch {
49 
68  template<class View>
69  class MeritMin : public MeritBase<View,int> {
70  public:
72  MeritMin(Space& home, const VarBranch& vb);
74  MeritMin(Space& home, bool shared, MeritMin& m);
76  int operator ()(const Space& home, View x, int i);
77  };
78 
85  template<class View>
86  class MeritMax : public MeritBase<View,int> {
87  public:
89  MeritMax(Space& home, const VarBranch& vb);
91  MeritMax(Space& home, bool shared, MeritMax& m);
93  int operator ()(const Space& home, View x, int i);
94  };
95 
102  template<class View>
103  class MeritSize : public MeritBase<View,unsigned int> {
104  public:
106  MeritSize(Space& home, const VarBranch& vb);
108  MeritSize(Space& home, bool shared, MeritSize& m);
110  unsigned int operator ()(const Space& home, View x, int i);
111  };
112 
119  template<class View>
120  class MeritDegreeSize : public MeritBase<View,double> {
121  public:
123  MeritDegreeSize(Space& home, const VarBranch& vb);
125  MeritDegreeSize(Space& home, bool shared, MeritDegreeSize& m);
127  double operator ()(const Space& home, View x, int i);
128  };
129 
136  template<class View>
137  class MeritAFCSize : public MeritBase<View,double> {
138  protected:
141  public:
143  MeritAFCSize(Space& home, const VarBranch& vb);
145  MeritAFCSize(Space& home, bool shared, MeritAFCSize& m);
147  double operator ()(const Space& home, View x, int i);
149  bool notice(void) const;
151  void dispose(Space& home);
152  };
153 
160  template<class View>
161  class MeritActivitySize : public MeritBase<View,double> {
162  protected:
165  public:
167  MeritActivitySize(Space& home, const VarBranch& vb);
171  double operator ()(const Space& home, View x, int i);
173  bool notice(void) const;
175  void dispose(Space& home);
176  };
177 
184  template<class View>
185  class MeritRegretMin : public MeritBase<View,unsigned int> {
186  public:
188  MeritRegretMin(Space& home, const VarBranch& vb);
190  MeritRegretMin(Space& home, bool shared, MeritRegretMin& m);
192  unsigned int operator ()(const Space& home, View x, int i);
193  };
194 
201  template<class View>
202  class MeritRegretMax : public MeritBase<View,unsigned int> {
203  public:
205  MeritRegretMax(Space& home, const VarBranch& vb);
207  MeritRegretMax(Space& home, bool shared, MeritRegretMax& m);
209  unsigned int operator ()(const Space& home, View x, int i);
210  };
211 
212 }}}
213 
215 
216 namespace Gecode { namespace Int { namespace Branch {
217 
220  ViewSel<IntView>* viewselint(Space& home, const IntVarBranch& ivb);
223  ViewSel<BoolView>* viewselbool(Space& home, const IntVarBranch& ivb);
224 
225 }}}
226 
227 namespace Gecode { namespace Int { namespace Branch {
228 
247  template<class View>
248  class ValSelMin : public ValSel<View,int> {
249  public:
251  ValSelMin(Space& home, const ValBranch& vb);
253  ValSelMin(Space& home, bool shared, ValSelMin& vs);
255  int val(const Space& home, View x, int i);
256  };
257 
264  template<class View>
265  class ValSelMax : public ValSel<View,int> {
266  public:
268  ValSelMax(Space& home, const ValBranch& vb);
270  ValSelMax(Space& home, bool shared, ValSelMax& vs);
272  int val(const Space& home, View x, int i);
273  };
274 
281  template<class View>
282  class ValSelMed : public ValSel<View,int> {
283  public:
285  ValSelMed(Space& home, const ValBranch& vb);
287  ValSelMed(Space& home, bool shared, ValSelMed& vs);
289  int val(const Space& home, View x, int i);
290  };
291 
298  template<class View>
299  class ValSelAvg : public ValSel<View,int> {
300  public:
302  ValSelAvg(Space& home, const ValBranch& vb);
304  ValSelAvg(Space& home, bool shared, ValSelAvg& vs);
306  int val(const Space& home, View x, int i);
307  };
308 
315  template<class View>
316  class ValSelRnd : public ValSel<View,int> {
317  protected:
320  public:
322  ValSelRnd(Space& home, const ValBranch& vb);
324  ValSelRnd(Space& home, bool shared, ValSelRnd& vs);
326  int val(const Space& home, View x, int i);
328  bool notice(void) const;
330  void dispose(Space& home);
331  };
332 
339  class ValSelRangeMin : public ValSel<IntView,int> {
340  public:
342  ValSelRangeMin(Space& home, const ValBranch& vb);
344  ValSelRangeMin(Space& home, bool shared, ValSelRangeMin& vs);
346  int val(const Space& home, IntView x, int i);
347  };
348 
355  class ValSelRangeMax : public ValSel<IntView,int> {
356  public:
358  ValSelRangeMax(Space& home, const ValBranch& vb);
360  ValSelRangeMax(Space& home, bool shared, ValSelRangeMax& vs);
362  int val(const Space& home, IntView x, int i);
363  };
364 
371  template<class View, bool min>
372  class ValSelNearMinMax : public ValSel<View,int> {
373  protected:
376  public:
378  ValSelNearMinMax(Space& home, const ValBranch& vb);
380  ValSelNearMinMax(Space& home, bool shared, ValSelNearMinMax& vs);
382  int val(const Space& home, View x, int i);
384  bool notice(void) const;
386  void dispose(Space& home);
387  };
388 
395  template<class View, bool inc>
396  class ValSelNearIncDec : public ValSel<View,int> {
397  protected:
400  public:
402  ValSelNearIncDec(Space& home, const ValBranch& vb);
404  ValSelNearIncDec(Space& home, bool shared, ValSelNearIncDec& vs);
406  int val(const Space& home, View x, int i);
408  bool notice(void) const;
410  void dispose(Space& home);
411  };
412 
413 }}}
414 
416 
417 namespace Gecode { namespace Int { namespace Branch {
418 
437  template<class View>
438  class ValCommitEq : public ValCommit<View,int> {
439  public:
441  ValCommitEq(Space& home, const ValBranch& vb);
443  ValCommitEq(Space& home, bool shared, ValCommitEq& vc);
445  ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
446  };
447 
454  template<class View>
455  class ValCommitLq : public ValCommit<View,int> {
456  public:
458  ValCommitLq(Space& home, const ValBranch& vb);
460  ValCommitLq(Space& home, bool shared, ValCommitLq& vc);
462  ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
463  };
464 
471  template<class View>
472  class ValCommitGq : public ValCommit<View,int> {
473  public:
475  ValCommitGq(Space& home, const ValBranch& vb);
477  ValCommitGq(Space& home, bool shared, ValCommitGq& vc);
479  ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
480  };
481 
488  template<class View>
489  class ValCommitGr : public ValCommit<View,int> {
490  public:
492  ValCommitGr(Space& home, const ValBranch& vb);
494  ValCommitGr(Space& home, bool shared, ValCommitGr& vc);
496  ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
497  };
498 
499 }}}
500 
502 
503 namespace Gecode { namespace Int { namespace Branch {
504 
507  ValSelCommitBase<IntView,int>*
508  valselcommitint(Space& home, int n, const IntValBranch& ivb);
509 
512  ValSelCommitBase<BoolView,int>*
513  valselcommitbool(Space& home, int n, const IntValBranch& ivb);
514 
517  ValSelCommitBase<IntView,int>*
518  valselcommitint(Space& home, const IntAssign& ia);
519 
522  ValSelCommitBase<BoolView,int>*
523  valselcommitbool(Space& home, const IntAssign& ia);
524 
525 }}}
526 
527 namespace Gecode { namespace Int { namespace Branch {
528 
533  template<int n, bool min>
534  class ViewValuesBrancher : public ViewBrancher<IntView,n> {
535  typedef typename ViewBrancher<IntView,n>::BranchFilter BranchFilter;
536  protected:
542  ViewSel<IntView>* vs[n], BranchFilter bf);
543  public:
545  virtual const Choice* choice(Space& home);
547  virtual const Choice* choice(const Space& home, Archive& e);
549  virtual ExecStatus commit(Space& home, const Choice& c, unsigned int a);
551  virtual Actor* copy(Space& home, bool share);
553  static BrancherHandle post(Home home, ViewArray<IntView>& x,
554  ViewSel<IntView>* vs[n], BranchFilter bf);
555  };
556 
557 }}}
558 
560 
561 #endif
562 
563 // STATISTICS: int-branch