Generated on Sat Feb 7 2015 02:01:24 for Gecode by doxygen 1.8.9.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-05-13 07:50:41 +0200 (Mon, 13 May 2013) $ by $Author: mears $
11  * $Revision: 13633 $
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  if (! dead_sequences.get(seqNum)) {
132  for (unsigned int seq = 0 ; seq < n_seqs ; seq++) {
133  if (seq == seqNum) continue;
134  if (dead_sequences.get(seq)) continue;
135  s.push(Literal(l._variable, getVal(seq,seqPos)));
136  }
137  }
138  return dynamicStackToArgArray(s);
139  }
141  template <>
145  (void) x;
147  std::pair<int,int> location = findVar(values, n_values, seq_size, l._value);
148  if (location.first == -1) return dynamicStackToArgArray(s);
149  unsigned int seqNum = location.first;
150  unsigned int seqPos = location.second;
151  if (! dead_sequences.get(seqNum)) {
152  for (unsigned int seq = 0 ; seq < n_seqs ; seq++) {
153  if (seq == seqNum) continue;
154  if (dead_sequences.get(seq)) continue;
155  s.push(Literal(l._variable, getVal(seq,seqPos)));
156  }
157  }
158  return dynamicStackToArgArray(s);
159  }
160 
161 }}}
162 
163 // STATISTICS: int-branch
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
A Literal is a pair of variable index and value.
Definition: ldsb.hh:50
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:46
int _value
The value of the literal. For int and bool variables, this is the value itself; for set variables...
Definition: ldsb.hh:63
int _variable
Variable index. The ViewArray that the index is meant for is assumed to be known by context...
Definition: ldsb.hh:59
Heap heap
The single global heap.
Definition: heap.cpp:49
virtual ArgArray< Literal > symmetric(Literal, const ViewArray< View > &) const
Compute symmetric literals.
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual ArgArray< Literal > symmetric(Literal, const ViewArray< View > &) const
Compute symmetric literals.
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Argument array for non-primitive types.
Definition: array.hpp:727
virtual ArgArray< Literal > symmetric(Literal, const ViewArray< View > &) const
Compute symmetric literals.
void values(Home home, const IntVarArgs &x, IntSet y, IntConLevel icl=ICL_DEF)
Post constraint .
Definition: minimodel.hh:1869
Value iterator for values in an offset bitset.
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Stack with arbitrary number of elements.
Gecode toplevel namespace
ArgArray< T > dynamicStackToArgArray(const Support::DynamicStack< T, A > &s)
Convert a DynamicStack into an ArgArray
Definition: sym-imp.hpp:43
void push(const T &x)
Push element x on top of stack.
Bitsets with index offset.