Generated on for Gecode by doxygen 1.17.0
consumer-smoke.cpp
Go to the documentation of this file.
1#include <test/int.hh>
2#ifdef GECODE_PACKAGE_HAS_SET
3#include <test/set.hh>
4#endif
5#ifdef GECODE_PACKAGE_HAS_FLOAT
6#include <test/float.hh>
7#endif
8
9#include <gecode/int.hh>
10#ifdef GECODE_PACKAGE_HAS_SET
11#include <gecode/set.hh>
12#endif
13#ifdef GECODE_PACKAGE_HAS_FLOAT
14#include <gecode/float.hh>
15#endif
16
17namespace {
18
19void post_equal(Gecode::Space& home, Gecode::IntVar x, Gecode::IntVar y) {
20 Gecode::rel(home, x, Gecode::IRT_EQ, y);
21}
22
23class EqualityTest final : public ::Test::Int::Test {
24public:
25 EqualityTest()
26 : ::Test::Int::Test("Package::Equality", 2, 0, 1) {}
27
28 bool solution(const ::Test::Int::Assignment& assignment) const override {
29 return assignment[0] == assignment[1];
30 }
31
32 void post(Gecode::Space& home, Gecode::IntVarArray& x) override {
33 post_equal(home, x[0], x[1]);
34 }
35} equality_test;
36
37#ifdef GECODE_PACKAGE_HAS_SET
38class SingletonSetTest final : public ::Test::Set::SetTest {
39public:
40 SingletonSetTest()
41 : ::Test::Set::SetTest("Package::Singleton", 1, Gecode::IntSet(0, 1)) {}
42
43 bool solution(const ::Test::Set::SetAssignment& assignment) const override {
44 return assignment[0] == 1;
45 }
46
47 void post(Gecode::Space& home, Gecode::SetVarArray& x,
48 Gecode::IntVarArray&) override {
49 Gecode::dom(home, x[0], Gecode::SRT_EQ, Gecode::IntSet(0, 0));
50 }
51} singleton_set_test;
52#endif
53
54#ifdef GECODE_PACKAGE_HAS_FLOAT
55class FloatEqualityTest final : public ::Test::Float::Test {
56public:
57 FloatEqualityTest()
58 : ::Test::Float::Test("Package::Equality", 2, 0.0, 1.0, 1.0,
59 ::Test::Float::CPLT_ASSIGNMENT, false) {}
60
62 solution(const ::Test::Float::Assignment& assignment) const override {
63 return cmp(assignment[0], Gecode::FRT_EQ, assignment[1]);
64 }
65
66 void post(Gecode::Space& home, Gecode::FloatVarArray& x) override {
67 Gecode::rel(home, x[0], Gecode::FRT_EQ, x[1]);
68 }
69} float_equality_test;
70#endif
71
72} // namespace
73
74int main(int argc, char* argv[]) {
75 if (Test::TestTags::all().empty())
76 return 1;
77 return Test::run_registered_tests(argc, argv);
78}
Integer variables.
Definition int.hh:390
Computation spaces.
Definition core.hpp:1787
Base class for tests with float constraints
Definition float.hh:259
static MaybeType cmp(Gecode::FloatVal x, Gecode::FloatRelType r, Gecode::FloatVal y)
Compare x and y with respect to r.
Definition float.hpp:248
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)=0
Post constraint.
virtual MaybeType solution(const Assignment &) const =0
Check an interval assignment using MT_TRUE, MT_FALSE, or MT_MAYBE; see cmp().
Base class for tests with integer constraints
Definition int.hh:270
Base class for tests with set constraints
Definition set.hh:287
virtual void post(Gecode::Space &home, Gecode::SetVarArray &x, Gecode::IntVarArray &y)=0
Post propagator.
virtual bool solution(const SetAssignment &) const =0
Check for solution.
static TestTags all(void)
Return set with all known tags.
Definition test.cpp:70
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition post.cpp:238
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Definition rel.cpp:68
@ FRT_EQ
Equality ( ).
Definition float.hh:1071
@ IRT_EQ
Equality ( ).
Definition int.hh:1226
@ SRT_EQ
Equality ( ).
Definition set.hh:651
int main(void)
Definition main.cpp:15
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition dom.cpp:40
@ CPLT_ASSIGNMENT
Definition float.hh:76
MaybeType
Type for comparisons and solutions.
Definition float.hh:65
int run_registered_tests(int argc, char *argv[])
Definition test.cpp:603