Generated on Sat May 25 2013 18:00:38 for Gecode by doxygen 1.8.3.1
sym-imp.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christopher Mears <chris.mears@monash.edu>
5  *
6  * Copyright:
7  * Christopher Mears, 2012
8  *
9  * Last modified:
10  * $Date: 2013-03-07 17:39:13 +0100 (Thu, 07 Mar 2013) $ by $Author: schulte $
11  * $Revision: 13458 $
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/int/ldsb.hh>
39 #include <gecode/int/branch.hh>
40 
41 namespace Gecode { namespace Int { namespace LDSB {
43  template <>
44  ArgArray<Literal>
47  (void) x;
48  if (indices.valid(l._variable) && indices.get(l._variable)) {
49  int n = 0;
51  n++;
52  ArgArray<Literal> lits(n);
53  int j = 0;
55  lits[j++] = Literal(i.val(), l._value);
56  return lits;
57  } else {
58  return ArgArray<Literal>(0);
59  }
60  }
62  template <>
66  (void) x;
67  if (indices.valid(l._variable) && indices.get(l._variable)) {
68  int n = 0;
70  n++;
71  ArgArray<Literal> lits(n);
72  int j = 0;
74  lits[j++] = Literal(i.val(), l._value);
75  return lits;
76  } else {
77  return ArgArray<Literal>(0);
78  }
79  }
80 
82  template <>
86  (void) x;
87  if (values.valid(l._value) && values.get(l._value)) {
88  int n = 0;
90  n++;
91  ArgArray<Literal> lits(n);
92  int j = 0;
94  lits[j++] = Literal(l._variable, i.val());
95  return lits;
96  } else {
97  return ArgArray<Literal>(0);
98  }
99  }
101  template <>
105  (void) x;
106  if (values.valid(l._value) && values.get(l._value)) {
107  int n = 0;
109  n++;
110  ArgArray<Literal> lits(n);
111  int j = 0;
113  lits[j++] = Literal(l._variable, i.val());
114  return lits;
115  } else {
116  return ArgArray<Literal>(0);
117  }
118  }
119 
121  template <>
125  (void) x;
127  std::pair<int,int> location = findVar(values, n_values, seq_size, l._value);
128  if (location.first == -1) return dynamicStackToArgArray(s);
129  unsigned int seqNum = location.first;
130  unsigned int seqPos = location.second;
131  for (unsigned int seq = 0 ; seq < n_seqs ; seq++) {
132  if (seq == seqNum) continue;
133  if (dead_sequences.get(seq)) continue;
134  s.push(Literal(l._variable, getVal(seq,seqPos)));
135  }
136  return dynamicStackToArgArray(s);
137  }
139  template <>
143  (void) x;
145  std::pair<int,int> location = findVar(values, n_values, seq_size, l._value);
146  if (location.first == -1) return dynamicStackToArgArray(s);
147  unsigned int seqNum = location.first;
148  unsigned int seqPos = location.second;
149  for (unsigned int seq = 0 ; seq < n_seqs ; seq++) {
150  if (seq == seqNum) continue;
151  if (dead_sequences.get(seq)) continue;
152  s.push(Literal(l._variable, getVal(seq,seqPos)));
153  }
154  return dynamicStackToArgArray(s);
155  }
156 
157 }}}
158 
159 // STATISTICS: int-branch