Generated on Fri Aug 24 2012 04:52:08 for Gecode by doxygen 1.8.1.2
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  * Guido Tack <tack@gecode.org>
5  * Christian Schulte <schulte@gecode.org>
6  *
7  * Contributing authors:
8  * Gabor Szokoli <szokoli@gecode.org>
9  *
10  * Copyright:
11  * Guido Tack, 2004
12  * Christian Schulte, 2004
13  * Gabor Szokoli, 2004
14  *
15  * Last modified:
16  * $Date: 2011-05-11 20:44:17 +1000 (Wed, 11 May 2011) $ by $Author: tack $
17  * $Revision: 12001 $
18  *
19  * This file is part of Gecode, the generic constraint
20  * development environment:
21  * http://www.gecode.org
22  *
23  * Permission is hereby granted, free of charge, to any person obtaining
24  * a copy of this software and associated documentation files (the
25  * "Software"), to deal in the Software without restriction, including
26  * without limitation the rights to use, copy, modify, merge, publish,
27  * distribute, sublicense, and/or sell copies of the Software, and to
28  * permit persons to whom the Software is furnished to do so, subject to
29  * the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be
32  * included in all copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
38  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
39  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41  *
42  */
43 
44 #ifndef __GECODE_SET_BRANCH_HH__
45 #define __GECODE_SET_BRANCH_HH__
46 
47 #include <gecode/set.hh>
48 
54 namespace Gecode { namespace Set { namespace Branch {
55 
56  /*
57  * Value selection classes
58  *
59  */
60 
61 
69  template<bool inc>
70  class ValMin : public ValSelBase<SetView,int> {
71  public:
73  ValMin(void);
75  ValMin(Space& home, const ValBranchOptions& vbo);
77  int val(Space& home, SetView x) const;
79  ModEvent tell(Space& home, unsigned int a, SetView x, int v);
80  };
81 
89  template<bool inc>
90  class ValMed : public ValSelBase<SetView,int> {
91  public:
93  ValMed(void);
95  ValMed(Space& home, const ValBranchOptions& vbo);
97  int val(Space& home, SetView x) const;
99  ModEvent tell(Space& home, unsigned int a, SetView x, int v);
100  };
101 
109  template<bool inc>
110  class ValMax : public ValSelBase<SetView,int> {
111  public:
113  ValMax(void);
115  ValMax(Space& home, const ValBranchOptions& vbo);
117  int val(Space& home, SetView x) const;
119  ModEvent tell(Space& home, unsigned int a, SetView x, int v);
120  };
121 
129  template<bool inc>
130  class ValRnd {
131  protected:
134  public:
136  typedef SetView View;
138  typedef int Val;
142  static const unsigned int alternatives = 2;
144  ValRnd(void);
146  ValRnd(Space& home, const ValBranchOptions& vbo);
148  int val(Space& home, SetView x);
150  ModEvent tell(Space& home, unsigned int a, SetView x, int n);
152  Choice choice(Space& home);
154  Choice choice(const Space& home, Archive& e);
156  void commit(Space& home, const Choice& c, unsigned a);
158  void update(Space& home, bool share, ValRnd& vs);
160  void dispose(Space& home);
161  };
162 
164  template<bool inc>
165  class AssignValMin : public ValMin<inc> {
166  public:
168  static const unsigned int alternatives = 1;
170  AssignValMin(void);
172  AssignValMin(Space& home, const ValBranchOptions& vbo);
173  };
174 
176  template<bool inc>
177  class AssignValMed : public ValMed<inc> {
178  public:
180  static const unsigned int alternatives = 1;
182  AssignValMed(void);
184  AssignValMed(Space& home, const ValBranchOptions& vbo);
185  };
186 
188  template<bool inc>
189  class AssignValMax : public ValMax<inc> {
190  public:
192  static const unsigned int alternatives = 1;
194  AssignValMax(void);
196  AssignValMax(Space& home, const ValBranchOptions& vbo);
197  };
198 
200  template<bool inc>
201  class AssignValRnd : public ValRnd<inc> {
202  public:
204  static const unsigned int alternatives = 1;
206  AssignValRnd(void);
208  AssignValRnd(Space& home, const ValBranchOptions& vbo);
209  };
210 
211  /*
212  * View selection classes
213  *
214  */
215 
222  class ByMinMin : public ViewSelBase<SetView> {
223  private:
225  int min;
226  public:
228  ByMinMin(void);
230  ByMinMin(Space& home, const VarBranchOptions& vbo);
232  ViewSelStatus init(Space& home, SetView x);
234  ViewSelStatus select(Space& home, SetView x);
235  };
236 
243  class ByMinMax : public ViewSelBase<SetView> {
244  private:
246  int min;
247  public:
249  ByMinMax(void);
251  ByMinMax(Space& home, const VarBranchOptions& vbo);
253  ViewSelStatus init(Space& home, SetView x);
255  ViewSelStatus select(Space& home, SetView x);
256  };
257 
264  class ByMaxMin : public ViewSelBase<SetView> {
265  private:
267  int max;
268  public:
270  ByMaxMin(void);
272  ByMaxMin(Space& home, const VarBranchOptions& vbo);
274  ViewSelStatus init(Space& home, SetView x);
276  ViewSelStatus select(Space& home, SetView x);
277  };
278 
285  class ByMaxMax : public ViewSelBase<SetView> {
286  private:
288  int max;
289  public:
291  ByMaxMax(void);
293  ByMaxMax(Space& home, const VarBranchOptions& vbo);
295  ViewSelStatus init(Space& home, SetView x);
297  ViewSelStatus select(Space& home, SetView x);
298  };
299 
306  class BySizeMin : public ViewSelBase<SetView> {
307  private:
309  unsigned int size;
310  public:
312  BySizeMin(void);
314  BySizeMin(Space& home, const VarBranchOptions& vbo);
316  ViewSelStatus init(Space& home, SetView x);
318  ViewSelStatus select(Space& home, SetView x);
319  };
320 
327  class BySizeMax : public ViewSelBase<SetView> {
328  private:
330  unsigned int size;
331  public:
333  BySizeMax(void);
335  BySizeMax(Space& home, const VarBranchOptions& vbo);
337  ViewSelStatus init(Space& home, SetView x);
339  ViewSelStatus select(Space& home, SetView x);
340  };
341 
349  class BySizeDegreeMin : public ViewSelBase<SetView> {
350  protected:
352  double sizedegree;
353  public:
355  BySizeDegreeMin(void);
357  BySizeDegreeMin(Space& home, const VarBranchOptions& vbo);
359  ViewSelStatus init(Space& home, SetView x);
361  ViewSelStatus select(Space& home, SetView x);
362  };
363 
371  class BySizeDegreeMax : public ViewSelBase<SetView> {
372  protected:
374  double sizedegree;
375  public:
377  BySizeDegreeMax(void);
379  BySizeDegreeMax(Space& home, const VarBranchOptions& vbo);
381  ViewSelStatus init(Space& home, SetView x);
383  ViewSelStatus select(Space& home, SetView x);
384  };
385 
393  class BySizeAfcMin : public ViewSelBase<SetView> {
394  protected:
396  double sizeafc;
397  public:
399  BySizeAfcMin(void);
401  BySizeAfcMin(Space& home, const VarBranchOptions& vbo);
403  ViewSelStatus init(Space& home, SetView x);
405  ViewSelStatus select(Space& home, SetView x);
406  };
407 
415  class BySizeAfcMax : public ViewSelBase<SetView> {
416  protected:
418  double sizeafc;
419  public:
421  BySizeAfcMax(void);
423  BySizeAfcMax(Space& home, const VarBranchOptions& vbo);
425  ViewSelStatus init(Space& home, SetView x);
427  ViewSelStatus select(Space& home, SetView x);
428  };
429 
430 }}}
431 
435 
436 #endif
437 // STATISTICS: set-branch
438