Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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
34namespace 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>
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>
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>
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>
148 return me_failed(x.le(home,n)) ? ES_FAILED : ES_OK;
149 }
150
151}}}
152
153// STATISTICS: int-branch
int n
Number of negative literals for node type.
No-good literal for equality.
Definition branch.hh:411
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition ngl.hpp:51
virtual NGL * copy(Space &home)
Create copy.
Definition ngl.hpp:46
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition ngl.hpp:59
EqNGL(Space &home, View x, int n)
Constructor for creation.
Definition ngl.hpp:38
No-good literal for greater or equal.
Definition branch.hh:465
virtual NGL * copy(Space &home)
Create copy.
Definition ngl.hpp:132
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition ngl.hpp:137
GqNGL(Space &home, View x, int n)
Constructor for creation.
Definition ngl.hpp:124
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition ngl.hpp:147
No-good literal for less or equal.
Definition branch.hh:447
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:107
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition ngl.hpp:117
LqNGL(Space &home, View x, int n)
Constructor for creation.
Definition ngl.hpp:94
No-good literal for disequality.
Definition branch.hh:429
NqNGL(Space &home, View x, int n)
Constructor for creation.
Definition ngl.hpp:66
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition ngl.hpp:87
virtual NGL * copy(Space &home)
Create copy.
Definition ngl.hpp:74
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition ngl.hpp:79
No-good literal recorded during search.
Definition core.hpp:1340
Status
The status of a no-good literal.
Definition core.hpp:1346
@ SUBSUMED
The literal is subsumed.
Definition core.hpp:1348
@ FAILED
The literal is failed.
Definition core.hpp:1347
@ NONE
The literal is neither failed nor subsumed.
Definition core.hpp:1349
Computation spaces.
Definition core.hpp:1742
bool assigned(void) const
Test whether view is assigned.
Definition var.hpp:111
View-value no-good literal.
Definition view-val.hpp:61
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition modevent.hpp:54
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition var-type.hpp:82
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition var-type.hpp:91
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition var-type.hpp:100
Gecode toplevel namespace
ExecStatus
Definition core.hpp:472
@ ES_OK
Execution is okay.
Definition core.hpp:476
@ ES_FAILED
Execution has resulted in failure.
Definition core.hpp:474
Post propagator for SetVar x
Definition set.hh:767
#define forceinline
Definition config.hpp:187