Generated on Thu Feb 14 2013 20:59:31 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, 2002
8  *
9  * Last modified:
10  * $Date: 2011-05-11 20:44:17 +1000 (Wed, 11 May 2011) $ by $Author: tack $
11  * $Revision: 12001 $
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 
50  /*
51  * Value selection classes
52  *
53  */
54 
62  template<class View>
63  class ValMin : public ValSelBase<View,int> {
64  public:
66  ValMin(void);
68  ValMin(Space& home, const ValBranchOptions& vbo);
70  int val(Space& home, View x) const;
72  ModEvent tell(Space& home, unsigned int a, View x, int n);
73  };
74 
82  template<class View>
83  class ValMed : public ValSelBase<View,int> {
84  public:
86  ValMed(void);
88  ValMed(Space& home, const ValBranchOptions& vbo);
90  int val(Space& home, View x) const;
92  ModEvent tell(Space& home, unsigned int a, View x, int n);
93  };
94 
102  template<class _View>
103  class ValRnd {
104  protected:
107  public:
109  typedef _View View;
111  typedef int Val;
115  static const unsigned int alternatives = 2;
117  ValRnd(void);
119  ValRnd(Space& home, const ValBranchOptions& vbo);
121  int val(Space& home, _View x);
123  ModEvent tell(Space& home, unsigned int a, _View x, int n);
125  Choice choice(Space& home);
127  Choice choice(const Space& home, Archive& e);
129  void commit(Space& home, const Choice& c, unsigned a);
131  void update(Space& home, bool share, ValRnd& vs);
133  void dispose(Space& home);
134  };
135 
144  template<class View>
145  class ValSplitMin : public ValSelBase<View,int> {
146  public:
148  ValSplitMin(void);
150  ValSplitMin(Space& home, const ValBranchOptions& vbo);
152  int val(Space& home, View x) const;
154  ModEvent tell(Space& home, unsigned int a, View x, int n);
155  };
156 
157 
166  template<class View>
167  class ValRangeMin : public ValSelBase<View,int> {
168  public:
170  ValRangeMin(void);
172  ValRangeMin(Space& home, const ValBranchOptions& vbo);
174  int val(Space& home, View x) const;
176  ModEvent tell(Space& home, unsigned int a, View x, int n);
177  };
178 
179 
181  class NoValue {};
182 
183 }}}
184 
185 namespace Gecode {
186  forceinline Archive&
188  return e;
189  }
190  forceinline Archive&
192  return e;
193  }
194 }
195 
196 namespace Gecode { namespace Int { namespace Branch {
197 
205  template<class View>
206  class ValZeroOne : public ValSelBase<View,NoValue> {
207  public:
209  ValZeroOne(void);
211  ValZeroOne(Space& home, const ValBranchOptions& vbo);
213  NoValue val(Space& home, View x) const;
215  ModEvent tell(Space& home, unsigned int a, View x, NoValue n);
216  };
217 
218 
223  template<class ViewSel, class View>
224  class ViewValuesBrancher : public ViewBrancher<ViewSel> {
225  protected:
229  ViewValuesBrancher(Space& home, bool share, ViewValuesBrancher& b);
232  ViewSel& vi_s, BranchFilter bf);
233  public:
235  virtual const Choice* choice(Space& home);
237  virtual const Choice* choice(const Space& home, Archive& e);
239  virtual ExecStatus commit(Space& home, const Choice& c, unsigned int a);
241  virtual Actor* copy(Space& home, bool share);
243  static void post(Home home, ViewArray<typename ViewSel::View>& x,
244  ViewSel& vi_s, BranchFilter bf=NULL);
245  };
246 
247 
249  template<class View>
250  class AssignValMin : public ValMin<View> {
251  public:
253  static const unsigned int alternatives = 1;
255  AssignValMin(void);
257  AssignValMin(Space& home, const ValBranchOptions& vbo);
258  };
259 
261  template<class View>
262  class AssignValMed : public ValMed<View> {
263  public:
265  static const unsigned int alternatives = 1;
267  AssignValMed(void);
269  AssignValMed(Space& home, const ValBranchOptions& vbo);
270  };
271 
273  template<class View>
274  class AssignValRnd : public ValRnd<View> {
275  public:
277  static const unsigned int alternatives = 1;
279  AssignValRnd(void);
281  AssignValRnd(Space& home, const ValBranchOptions& vbo);
282  };
283 
285  template<class View>
286  class AssignValZero : public ValZeroOne<View> {
287  public:
289  static const unsigned int alternatives = 1;
291  AssignValZero(void);
293  AssignValZero(Space& home, const ValBranchOptions& vbo);
294  };
295 
296  /*
297  * Variable selection classes
298  *
299  */
300 
307  class ByMinMin : public ViewSelBase<IntView> {
308  protected:
310  int min;
311  public:
313  ByMinMin(void);
315  ByMinMin(Space& home, const VarBranchOptions& vbo);
317  ViewSelStatus init(Space& home, IntView x);
319  ViewSelStatus select(Space& home, IntView x);
320  };
321 
328  class ByMinMax : public ViewSelBase<IntView> {
329  protected:
331  int min;
332  public:
334  ByMinMax(void);
336  ByMinMax(Space& home, const VarBranchOptions& vbo);
338  ViewSelStatus init(Space& home, IntView x);
340  ViewSelStatus select(Space& home, IntView x);
341  };
342 
349  class ByMaxMin : public ViewSelBase<IntView> {
350  protected:
352  int max;
353  public:
355  ByMaxMin(void);
357  ByMaxMin(Space& home, const VarBranchOptions& vbo);
359  ViewSelStatus init(Space& home, IntView x);
361  ViewSelStatus select(Space& home, IntView x);
362  };
363 
370  class ByMaxMax : public ViewSelBase<IntView> {
371  protected:
373  int max;
374  public:
376  ByMaxMax(void);
378  ByMaxMax(Space& home, const VarBranchOptions& vbo);
380  ViewSelStatus init(Space& home, IntView x);
382  ViewSelStatus select(Space& home, IntView x);
383  };
384 
391  class BySizeMin : public ViewSelBase<IntView> {
392  protected:
394  unsigned int size;
395  public:
397  BySizeMin(void);
399  BySizeMin(Space& home, const VarBranchOptions& vbo);
401  ViewSelStatus init(Space& home, IntView x);
403  ViewSelStatus select(Space& home, IntView x);
404  };
405 
412  class BySizeMax : public ViewSelBase<IntView> {
413  protected:
415  unsigned int size;
416  public:
418  BySizeMax(void);
420  BySizeMax(Space& home, const VarBranchOptions& vbo);
422  ViewSelStatus init(Space& home, IntView x);
424  ViewSelStatus select(Space& home, IntView x);
425  };
426 
434  class BySizeDegreeMin : public ViewSelBase<IntView> {
435  protected:
437  double sizedegree;
438  public:
440  BySizeDegreeMin(void);
442  BySizeDegreeMin(Space& home, const VarBranchOptions& vbo);
444  ViewSelStatus init(Space& home, IntView x);
446  ViewSelStatus select(Space& home, IntView x);
447  };
448 
456  class BySizeDegreeMax : public ViewSelBase<IntView> {
457  protected:
459  double sizedegree;
460  public:
462  BySizeDegreeMax(void);
464  BySizeDegreeMax(Space& home, const VarBranchOptions& vbo);
466  ViewSelStatus init(Space& home, IntView x);
468  ViewSelStatus select(Space& home, IntView x);
469  };
470 
477  class BySizeAfcMin : public ViewSelBase<IntView> {
478  protected:
480  double sizeafc;
481  public:
483  BySizeAfcMin(void);
485  BySizeAfcMin(Space& home, const VarBranchOptions& vbo);
487  ViewSelStatus init(Space& home, IntView x);
489  ViewSelStatus select(Space& home, IntView x);
490  };
491 
498  class BySizeAfcMax : public ViewSelBase<IntView> {
499  protected:
501  double sizeafc;
502  public:
504  BySizeAfcMax(void);
506  BySizeAfcMax(Space& home, const VarBranchOptions& vbo);
508  ViewSelStatus init(Space& home, IntView x);
510  ViewSelStatus select(Space& home, IntView x);
511  };
512 
519  class ByRegretMinMin : public ViewSelBase<IntView> {
520  protected:
522  unsigned int regret;
523  public:
525  ByRegretMinMin(void);
527  ByRegretMinMin(Space& home, const VarBranchOptions& vbo);
529  ViewSelStatus init(Space& home, IntView x);
531  ViewSelStatus select(Space& home, IntView x);
532  };
533 
540  class ByRegretMinMax : public ViewSelBase<IntView> {
541  protected:
543  unsigned int regret;
544  public:
546  ByRegretMinMax(void);
548  ByRegretMinMax(Space& home, const VarBranchOptions& vbo);
550  ViewSelStatus init(Space& home, IntView x);
552  ViewSelStatus select(Space& home, IntView x);
553  };
554 
561  class ByRegretMaxMin : public ViewSelBase<IntView> {
562  protected:
564  unsigned int regret;
565  public:
567  ByRegretMaxMin(void);
569  ByRegretMaxMin(Space& home, const VarBranchOptions& vbo);
571  ViewSelStatus init(Space& home, IntView x);
573  ViewSelStatus select(Space& home, IntView x);
574  };
575 
582  class ByRegretMaxMax : public ViewSelBase<IntView> {
583  protected:
585  unsigned int regret;
586  public:
588  ByRegretMaxMax(void);
590  ByRegretMaxMax(Space& home, const VarBranchOptions& vbo);
592  ViewSelStatus init(Space& home, IntView x);
594  ViewSelStatus select(Space& home, IntView x);
595  };
596 
597 }}}
598 
604 
605 #endif
606 
607 // STATISTICS: int-branch