Generated on Mon Sep 17 2012 22:20:36 for Gecode by doxygen 1.8.1.1
branch.cpp
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: 2010-03-12 08:16:29 +1100 (Fri, 12 Mar 2010) $ by $Author: schulte $
11  * $Revision: 10418 $
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 #include <gecode/set/branch.hh>
39 
40 namespace Gecode {
41 
42  void
43  assign(Home home, const SetVarArgs& x, SetAssign vals,
44  const ValBranchOptions& o_vals) {
45  using namespace Set;
46  if (home.failed()) return;
47  ViewArray<SetView> xv(home,x);
49  switch (vals) {
50  case SET_ASSIGN_MIN_INC:
51  {
52  Branch::AssignValMin<true> a(home,o_vals);
54  ::post(home,xv,v,a);
55  }
56  break;
57  case SET_ASSIGN_MIN_EXC:
58  {
59  Branch::AssignValMin<false> a(home,o_vals);
61  ::post(home,xv,v,a);
62  }
63  break;
64  case SET_ASSIGN_MED_INC:
65  {
66  Branch::AssignValMed<true> a(home,o_vals);
68  ::post(home,xv,v,a);
69  }
70  break;
71  case SET_ASSIGN_MED_EXC:
72  {
73  Branch::AssignValMed<false> a(home,o_vals);
75  ::post(home,xv,v,a);
76  }
77  break;
78  case SET_ASSIGN_MAX_INC:
79  {
80  Branch::AssignValMax<true> a(home,o_vals);
82  ::post(home,xv,v,a);
83  }
84  break;
85  case SET_ASSIGN_MAX_EXC:
86  {
87  Branch::AssignValMax<false> a(home,o_vals);
89  ::post(home,xv,v,a);
90  }
91  break;
92  case SET_ASSIGN_RND_INC:
93  {
94  Branch::AssignValRnd<true> a(home,o_vals);
96  ::post(home,xv,v,a);
97  }
98  break;
99  case SET_ASSIGN_RND_EXC:
100  {
101  Branch::AssignValRnd<false> a(home,o_vals);
103  ::post(home,xv,v,a);
104  }
105  break;
106  default:
107  throw UnknownBranching("Set::assign");
108  }
109  }
110 
111  void
113  const ValBranchOptions& o_vals) {
114  SetVarArgs xv(1); xv[0]=x;
115  branch(home, xv, SET_VAR_NONE, vals, VarBranchOptions::def, o_vals);
116  }
117 
118  void
119  assign(Home home, SetVar x, SetAssign vals,
120  const ValBranchOptions& o_vals) {
121  SetVarArgs xv(1); xv[0]=x;
122  assign(home, xv, vals, o_vals);
123  }
124 
125 }
126 
127 // STATISTICS: set-branch
128