Generated on Sat Feb 7 2015 02:01:20 for Gecode by doxygen 1.8.9.1
ngl.hpp
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, 2013
8  *
9  * Last modified:
10  * $Date: 2013-11-08 09:45:57 +0100 (Fri, 08 Nov 2013) $ by $Author: schulte $
11  * $Revision: 14069 $
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 namespace Gecode { namespace Int { namespace Branch {
39 
40  template<class View>
42  EqNGL<View>::EqNGL(Space& home, View x, int n)
43  : ViewValNGL<View,int,PC_INT_VAL>(home,x,n) {}
44  template<class View>
46  EqNGL<View>::EqNGL(Space& home, bool share, EqNGL& ngl)
47  : ViewValNGL<View,int,PC_INT_VAL>(home,share,ngl) {}
48  template<class View>
49  NGL*
50  EqNGL<View>::copy(Space& home, bool share) {
51  return new (home) EqNGL<View>(home,share,*this);
52  }
53  template<class View>
55  EqNGL<View>::status(const Space&) const {
56  if (x.assigned())
57  return (x.val() == n) ? NGL::SUBSUMED : NGL::FAILED;
58  else
59  return x.in(n) ? NGL::NONE : NGL::FAILED;
60  }
61  template<class View>
64  return me_failed(x.nq(home,n)) ? ES_FAILED : ES_OK;
65  }
66 
67 
68  template<class View>
70  NqNGL<View>::NqNGL(Space& home, View x, int n)
71  : ViewValNGL<View,int,PC_INT_DOM>(home,x,n) {}
72  template<class View>
74  NqNGL<View>::NqNGL(Space& home, bool share, NqNGL& ngl)
75  : ViewValNGL<View,int,PC_INT_DOM>(home,share,ngl) {}
76  template<class View>
77  NGL*
78  NqNGL<View>::copy(Space& home, bool share) {
79  return new (home) NqNGL<View>(home,share,*this);
80  }
81  template<class View>
83  NqNGL<View>::status(const Space&) const {
84  if (x.assigned())
85  return (x.val() == n) ? NGL::FAILED : NGL::SUBSUMED;
86  else
87  return x.in(n) ? NGL::NONE : NGL::SUBSUMED;
88  }
89  template<class View>
92  return me_failed(x.eq(home,n)) ? ES_FAILED : ES_OK;
93  }
94 
95 
96  template<class View>
98  LqNGL<View>::LqNGL(Space& home, View x, int n)
99  : ViewValNGL<View,int,PC_INT_BND>(home,x,n) {}
100  template<class View>
102  LqNGL<View>::LqNGL(Space& home, bool share, LqNGL& ngl)
103  : ViewValNGL<View,int,PC_INT_BND>(home,share,ngl) {}
104  template<class View>
105  NGL*
106  LqNGL<View>::copy(Space& home, bool share) {
107  return new (home) LqNGL<View>(home,share,*this);
108  }
109  template<class View>
111  LqNGL<View>::status(const Space&) const {
112  if (x.max() <= n)
113  return NGL::SUBSUMED;
114  else if (x.min() > n)
115  return NGL::FAILED;
116  else
117  return NGL::NONE;
118  }
119  template<class View>
120  ExecStatus
122  return me_failed(x.gr(home,n)) ? ES_FAILED : ES_OK;
123  }
124 
125 
126  template<class View>
128  GqNGL<View>::GqNGL(Space& home, View x, int n)
129  : ViewValNGL<View,int,PC_INT_BND>(home,x,n) {}
130  template<class View>
132  GqNGL<View>::GqNGL(Space& home, bool share, GqNGL& ngl)
133  : ViewValNGL<View,int,PC_INT_BND>(home,share,ngl) {}
134  template<class View>
135  NGL*
136  GqNGL<View>::copy(Space& home, bool share) {
137  return new (home) GqNGL<View>(home,share,*this);
138  }
139  template<class View>
141  GqNGL<View>::status(const Space&) const {
142  if (x.min() >= n)
143  return NGL::SUBSUMED;
144  else if (x.max() < n)
145  return NGL::FAILED;
146  else
147  return NGL::NONE;
148  }
149  template<class View>
150  ExecStatus
152  return me_failed(x.le(home,n)) ? ES_FAILED : ES_OK;
153  }
154 
155 }}}
156 
157 // STATISTICS: int-branch
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.hpp:63
No-good literal for less or equal.
Definition: branch.hh:457
No-good literal for greater or equal.
Definition: branch.hh:475
The literal is neither failed nor subsumed.
Definition: core.hpp:980
NqNGL(Space &home, View x, int n)
Constructor for creation.
Definition: ngl.hpp:70
Status
The status of a no-good literal.
Definition: core.hpp:977
Computation spaces.
Definition: core.hpp:1362
No-good literal for equality.
Definition: branch.hh:421
The literal is subsumed.
Definition: core.hpp:979
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Execution has resulted in failure.
Definition: core.hpp:525
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.hpp:91
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition: var-type.hpp:100
EqNGL(Space &home, View x, int n)
Constructor for creation.
Definition: ngl.hpp:42
virtual NGL * copy(Space &home, bool share)
Create copy.
Definition: ngl.hpp:78
virtual NGL * copy(Space &home, bool share)
Create copy.
Definition: ngl.hpp:106
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.hpp:151
No-good literal for disequality.
Definition: branch.hh:439
GqNGL(Space &home, View x, int n)
Constructor for creation.
Definition: ngl.hpp:128
virtual NGL * copy(Space &home, bool share)
Create copy.
Definition: ngl.hpp:136
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.hpp:55
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
The literal is failed.
Definition: core.hpp:978
LqNGL(Space &home, View x, int n)
Constructor for creation.
Definition: ngl.hpp:98
ExecStatus
Definition: core.hpp:523
#define forceinline
Definition: config.hpp:132
Execution is okay.
Definition: core.hpp:527
View-value no-good literal.
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.hpp:121
Gecode toplevel namespace
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.hpp:141
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.hpp:83
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition: modevent.hpp:58
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:82
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.hpp:111
virtual NGL * copy(Space &home, bool share)
Create copy.
Definition: ngl.hpp:50
No-good literal recorded during search.
Definition: core.hpp:971