Generated on Sat Apr 10 2021 00:00:00 for Gecode by doxygen 1.9.1
val-commit.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, 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 namespace Gecode { namespace Int { namespace Branch {
35 
36  template<class View>
39  (Space& home, const ValBranch<ValCommitEq<View>::Var>& vb)
40  : ValCommit<View,int>(home,vb) {}
41  template<class View>
44  : ValCommit<View,int>(home,vc) {}
45  template<class View>
47  ValCommitEq<View>::commit(Space& home, unsigned int a, View x, int, int n) {
48  return (a == 0) ? x.eq(home,n) : x.nq(home,n);
49  }
50  template<class View>
52  ValCommitEq<View>::ngl(Space& home, unsigned int a, View x, int n) const {
53  if (a == 0)
54  return new (home) EqNGL<View>(home,x,n);
55  else
56  return NULL;
57  }
58  template<class View>
59  forceinline void
60  ValCommitEq<View>::print(const Space&, unsigned int a, View, int i,
61  int n, std::ostream& o) const {
62  o << "var[" << i << "] "
63  << ((a == 0) ? "=" : "!=") << " " << n;
64  }
65 
66  template<class View>
69  (Space& home, const ValBranch<ValCommitLq<View>::Var>& vb)
70  : ValCommit<View,int>(home,vb) {}
71  template<class View>
74  : ValCommit<View,int>(home,vc) {}
75  template<class View>
77  ValCommitLq<View>::commit(Space& home, unsigned int a, View x, int, int n) {
78  return (a == 0) ? x.lq(home,n) : x.gr(home,n);
79  }
80  template<class View>
82  ValCommitLq<View>::ngl(Space& home, unsigned int a, View x, int n) const {
83  if (a == 0)
84  return new (home) LqNGL<View>(home,x,n);
85  else
86  return NULL;
87  }
88  template<class View>
89  forceinline void
90  ValCommitLq<View>::print(const Space&, unsigned int a, View, int i,
91  int n, std::ostream& o) const {
92  o << "var[" << i << "] "
93  << ((a == 0) ? "<=" : ">") << " " << n;
94  }
95 
96  template<class View>
99  (Space& home, const ValBranch<ValCommitGq<View>::Var>& vb)
100  : ValCommit<View,int>(home,vb) {}
101  template<class View>
104  : ValCommit<View,int>(home,vc) {}
105  template<class View>
107  ValCommitGq<View>::commit(Space& home, unsigned int a, View x, int, int n) {
108  return (a == 0) ? x.gq(home,n) : x.le(home,n);
109  }
110  template<class View>
112  ValCommitGq<View>::ngl(Space& home, unsigned int a, View x, int n) const {
113  if (a == 0)
114  return new (home) GqNGL<View>(home,x,n);
115  else
116  return NULL;
117  }
118  template<class View>
119  forceinline void
120  ValCommitGq<View>::print(const Space&, unsigned int a, View, int i,
121  int n, std::ostream& o) const {
122  o << "var[" << i << "] "
123  << ((a == 0) ? ">=" : "<") << " " << n;
124  }
125 
126  template<class View>
129  (Space& home, const ValBranch<ValCommitGr<View>::Var>& vb)
130  : ValCommit<View,int>(home,vb) {}
131  template<class View>
134  : ValCommit<View,int>(home,vc) {}
135  template<class View>
137  ValCommitGr<View>::commit(Space& home, unsigned int a, View x, int, int n) {
138  return (a == 0) ? x.gr(home,n) : x.lq(home,n);
139  }
140  template<class View>
142  ValCommitGr<View>::ngl(Space& home, unsigned int a, View x, int n) const {
143  if (a == 0)
144  return new (home) GqNGL<View>(home,x,n+1);
145  else
146  return NULL;
147  }
148  template<class View>
149  forceinline void
150  ValCommitGr<View>::print(const Space&, unsigned int a, View, int i,
151  int n, std::ostream& o) const {
152  o << "var[" << i << "] "
153  << ((a == 0) ? ">" : "<=") << " " << n;
154  }
155 
156 }}}
157 
158 // STATISTICS: int-branch
159 
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:249
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
No-good literal for equality.
Definition: branch.hh:411
No-good literal for greater or equal.
Definition: branch.hh:465
No-good literal for less or equal.
Definition: branch.hh:447
Value commit class for equality.
Definition: branch.hh:506
NGL * ngl(Space &home, unsigned int a, View x, int n) const
Create no-good literal for alternative a.
Definition: val-commit.hpp:52
ModEvent commit(Space &home, unsigned int a, View x, int i, int n)
Commit view x at position i to value n for alternative a.
Definition: val-commit.hpp:47
void print(const Space &home, unsigned int a, View x, int i, int n, std::ostream &o) const
Print on o the alternative with view x at position i and value n.
Definition: val-commit.hpp:60
ValCommitEq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Value commit class for greater or equal.
Definition: branch.hh:552
void print(const Space &home, unsigned int a, View x, int i, int n, std::ostream &o) const
Print on o the alternative with view x at position i and value n.
Definition: val-commit.hpp:120
ValCommitGq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
NGL * ngl(Space &home, unsigned int a, View x, int n) const
Create no-good literal for alternative a.
Definition: val-commit.hpp:112
ModEvent commit(Space &home, unsigned int a, View x, int i, int n)
Commit view x at position i to value n for alternative a.
Definition: val-commit.hpp:107
Value commit class for greater.
Definition: branch.hh:575
ValCommitGr(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
ModEvent commit(Space &home, unsigned int a, View x, int i, int n)
Commit view x at position i to value n for alternative a.
Definition: val-commit.hpp:137
void print(const Space &home, unsigned int a, View x, int i, int n, std::ostream &o) const
Print on o the alternative with view x at position i and value n.
Definition: val-commit.hpp:150
NGL * ngl(Space &home, unsigned int a, View x, int n) const
Create no-good literal for alternative a.
Definition: val-commit.hpp:142
Value commit class for less or equal.
Definition: branch.hh:529
void print(const Space &home, unsigned int a, View x, int i, int n, std::ostream &o) const
Print on o the alternative with view x at position i and value n.
Definition: val-commit.hpp:90
NGL * ngl(Space &home, unsigned int a, View x, int n) const
Create no-good literal for alternative a.
Definition: val-commit.hpp:82
ValCommitLq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
ModEvent commit(Space &home, unsigned int a, View x, int i, int n)
Commit view x at position i to value n for alternative a.
Definition: val-commit.hpp:77
No-good literal recorded during search.
Definition: core.hpp:1340
Computation spaces.
Definition: core.hpp:1742
Value branching information.
Definition: val.hpp:41
Base class for value commit.
Definition: val-commit.hpp:44
View::VarType Var
Corresponding variable type.
Definition: val-commit.hpp:49
int ModEvent
Type for modification events.
Definition: core.hpp:62
Gecode::IntArgs i({1, 2, 3, 4})
#define forceinline
Definition: config.hpp:192