Generated on Sun Aug 9 2020 05:34:08 for Gecode by doxygen 1.8.18
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  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 #include <gecode/int/ldsb.hh>
35 #include <gecode/int/branch.hh>
36 
37 namespace Gecode { namespace Int { namespace LDSB {
39  template <>
40  ArgArray<Literal>
43  (void) x;
44  if (indices.valid(l._variable) && indices.get(l._variable)) {
45  int n = 0;
47  n++;
48  ArgArray<Literal> lits(n);
49  int j = 0;
51  lits[j++] = Literal(i.val(), l._value);
52  return lits;
53  } else {
54  return ArgArray<Literal>(0);
55  }
56  }
58  template <>
62  (void) x;
63  if (indices.valid(l._variable) && indices.get(l._variable)) {
64  int n = 0;
66  n++;
67  ArgArray<Literal> lits(n);
68  int j = 0;
70  lits[j++] = Literal(i.val(), l._value);
71  return lits;
72  } else {
73  return ArgArray<Literal>(0);
74  }
75  }
76 
78  template <>
82  (void) x;
83  if (values.valid(l._value) && values.get(l._value)) {
84  int n = 0;
86  n++;
87  ArgArray<Literal> lits(n);
88  int j = 0;
90  lits[j++] = Literal(l._variable, i.val());
91  return lits;
92  } else {
93  return ArgArray<Literal>(0);
94  }
95  }
97  template <>
101  (void) x;
102  if (values.valid(l._value) && values.get(l._value)) {
103  int n = 0;
105  n++;
106  ArgArray<Literal> lits(n);
107  int j = 0;
109  lits[j++] = Literal(l._variable, i.val());
110  return lits;
111  } else {
112  return ArgArray<Literal>(0);
113  }
114  }
115 
117  template <>
121  (void) x;
122  Region region;
124  std::pair<int,int> location = findVar(values, n_values, seq_size, l._value);
125  if (location.first == -1) return dynamicStackToArgArray(s);
126  unsigned int seqNum = location.first;
127  unsigned int seqPos = location.second;
128  if (! dead_sequences.get(seqNum)) {
129  for (unsigned int seq = 0 ; seq < n_seqs ; seq++) {
130  if (seq == seqNum) continue;
131  if (dead_sequences.get(seq)) continue;
132  s.push(Literal(l._variable, getVal(seq,seqPos)));
133  }
134  }
135  return dynamicStackToArgArray(s);
136  }
138  template <>
142  (void) x;
143  Region region;
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  if (! dead_sequences.get(seqNum)) {
150  for (unsigned int seq = 0 ; seq < n_seqs ; seq++) {
151  if (seq == seqNum) continue;
152  if (dead_sequences.get(seq)) continue;
153  s.push(Literal(l._variable, getVal(seq,seqPos)));
154  }
155  }
156  return dynamicStackToArgArray(s);
157  }
158 
159 }}}
160 
161 // STATISTICS: int-branch
void values(Home home, const IntVarArgs &x, IntSet y, IntPropLevel ipl)
Post constraint .
Definition: aliases.hpp:143
Post propagator for SetVar x
Definition: set.hh:767
virtual ArgArray< Literal > symmetric(Literal, const ViewArray< View > &) const
Compute symmetric literals.
Gecode toplevel namespace
void push(const T &x)
Push element x on top of stack.
virtual ArgArray< Literal > symmetric(Literal, const ViewArray< View > &) const
Compute symmetric literals.
Argument array for non-primitive types.
Definition: array.hpp:656
Value iterator for values in an offset bitset.
Handle to region.
Definition: region.hpp:55
A Literal is a pair of variable index and value.
Definition: ldsb.hh:46
NNF * l
Left subtree.
Definition: bool-expr.cpp:240
virtual ArgArray< Literal > symmetric(Literal, const ViewArray< View > &) const
Compute symmetric literals.
Stack with arbitrary number of elements.
std::pair< int, int > findVar(int *indices, unsigned int n_values, unsigned int seq_size, int index)
Find the location of an integer in a collection of sequences.
Definition: ldsb.cpp:42
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Gecode::IntArgs i({1, 2, 3, 4})
Bitsets with index offset.
ArgArray< T > dynamicStackToArgArray(const Support::DynamicStack< T, A > &s)
Convert a DynamicStack<T,A> into an ArgArray<T>
Definition: sym-imp.hpp:39