Generated on Wed Jan 1 2020 10:37:59 for Gecode by doxygen 1.8.16
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  * 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 namespace Gecode { namespace Int { namespace Branch {
35 
36  template<class View>
38  EqNGL<View>::EqNGL(Space& home, View x, int n)
39  : ViewValNGL<View,int,PC_INT_VAL>(home,x,n) {}
40  template<class View>
43  : ViewValNGL<View,int,PC_INT_VAL>(home,ngl) {}
44  template<class View>
45  NGL*
47  return new (home) EqNGL<View>(home,*this);
48  }
49  template<class View>
51  EqNGL<View>::status(const Space&) const {
52  if (x.assigned())
53  return (x.val() == n) ? NGL::SUBSUMED : NGL::FAILED;
54  else
55  return x.in(n) ? NGL::NONE : NGL::FAILED;
56  }
57  template<class View>
60  return me_failed(x.nq(home,n)) ? ES_FAILED : ES_OK;
61  }
62 
63 
64  template<class View>
66  NqNGL<View>::NqNGL(Space& home, View x, int n)
67  : ViewValNGL<View,int,PC_INT_DOM>(home,x,n) {}
68  template<class View>
71  : ViewValNGL<View,int,PC_INT_DOM>(home,ngl) {}
72  template<class View>
73  NGL*
75  return new (home) NqNGL<View>(home,*this);
76  }
77  template<class View>
79  NqNGL<View>::status(const Space&) const {
80  if (x.assigned())
81  return (x.val() == n) ? NGL::FAILED : NGL::SUBSUMED;
82  else
83  return x.in(n) ? NGL::NONE : NGL::SUBSUMED;
84  }
85  template<class View>
88  return me_failed(x.eq(home,n)) ? ES_FAILED : ES_OK;
89  }
90 
91 
92  template<class View>
94  LqNGL<View>::LqNGL(Space& home, View x, int n)
95  : ViewValNGL<View,int,PC_INT_BND>(home,x,n) {}
96  template<class View>
99  : ViewValNGL<View,int,PC_INT_BND>(home,ngl) {}
100  template<class View>
101  NGL*
103  return new (home) LqNGL<View>(home,*this);
104  }
105  template<class View>
107  LqNGL<View>::status(const Space&) const {
108  if (x.max() <= n)
109  return NGL::SUBSUMED;
110  else if (x.min() > n)
111  return NGL::FAILED;
112  else
113  return NGL::NONE;
114  }
115  template<class View>
116  ExecStatus
118  return me_failed(x.gr(home,n)) ? ES_FAILED : ES_OK;
119  }
120 
121 
122  template<class View>
124  GqNGL<View>::GqNGL(Space& home, View x, int n)
125  : ViewValNGL<View,int,PC_INT_BND>(home,x,n) {}
126  template<class View>
129  : ViewValNGL<View,int,PC_INT_BND>(home,ngl) {}
130  template<class View>
131  NGL*
133  return new (home) GqNGL<View>(home,*this);
134  }
135  template<class View>
137  GqNGL<View>::status(const Space&) const {
138  if (x.min() >= n)
139  return NGL::SUBSUMED;
140  else if (x.max() < n)
141  return NGL::FAILED;
142  else
143  return NGL::NONE;
144  }
145  template<class View>
146  ExecStatus
148  return me_failed(x.le(home,n)) ? ES_FAILED : ES_OK;
149  }
150 
151 }}}
152 
153 // STATISTICS: int-branch
Post propagator for SetVar x
Definition: set.hh:767
The literal is failed.
Definition: core.hpp:1347
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition: modevent.hpp:54
NqNGL(Space &home, View x, int n)
Constructor for creation.
Definition: ngl.hpp:66
virtual NGL * copy(Space &home)
Create copy.
Definition: ngl.hpp:132
Computation spaces.
Definition: core.hpp:1742
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.hpp:79
bool assigned(void) const
Test whether view is assigned.
Definition: var.hpp:111
EqNGL(Space &home, View x, int n)
Constructor for creation.
Definition: ngl.hpp:38
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.hpp:117
virtual NGL * copy(Space &home)
Create copy.
Definition: ngl.hpp:102
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.hpp:137
No-good literal for less or equal.
Definition: branch.hh:447
Gecode toplevel namespace
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.hpp:147
No-good literal for greater or equal.
Definition: branch.hh:465
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.hpp:51
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.hpp:59
The literal is neither failed nor subsumed.
Definition: core.hpp:1349
No-good literal for equality.
Definition: branch.hh:411
View-value no-good literal.
Definition: view-val.hpp:61
LqNGL(Space &home, View x, int n)
Constructor for creation.
Definition: ngl.hpp:94
virtual NGL * copy(Space &home)
Create copy.
Definition: ngl.hpp:46
GqNGL(Space &home, View x, int n)
Constructor for creation.
Definition: ngl.hpp:124
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.hpp:107
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:82
#define forceinline
Definition: config.hpp:185
The literal is subsumed.
Definition: core.hpp:1348
virtual NGL * copy(Space &home)
Create copy.
Definition: ngl.hpp:74
No-good literal recorded during search.
Definition: core.hpp:1340
No-good literal for disequality.
Definition: branch.hh:429
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Status
The status of a no-good literal.
Definition: core.hpp:1346
Execution has resulted in failure.
Definition: core.hpp:474
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition: var-type.hpp:100
Execution is okay.
Definition: core.hpp:476
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.hpp:87
ExecStatus
Definition: core.hpp:472