this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Mikael Lagerkvist <lagerkvist@gecode.org>
5 * Christian Schulte <schulte@gecode.org>
6 *
7 * Contributing authors:
8 * Vincent Barichard <Vincent.Barichard@univ-angers.fr>
9 *
10 * Copyright:
11 * Mikael Lagerkvist, 2006
12 * Christian Schulte, 2009
13 * Vincent Barichard, 2012
14 *
15 * This file is part of Gecode, the generic constraint
16 * development environment:
17 * http://www.gecode.org
18 *
19 * Permission is hereby granted, free of charge, to any person obtaining
20 * a copy of this software and associated documentation files (the
21 * "Software"), to deal in the Software without restriction, including
22 * without limitation the rights to use, copy, modify, merge, publish,
23 * distribute, sublicense, and/or sell copies of the Software, and to
24 * permit persons to whom the Software is furnished to do so, subject to
25 * the following conditions:
26 *
27 * The above copyright notice and this permission notice shall be
28 * included in all copies or substantial portions of the Software.
29 *
30 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 *
38 */
39
40#ifndef GECODE_TEST_BRANCH_HH
41#define GECODE_TEST_BRANCH_HH
42
43#include <gecode/kernel.hh>
44
45#include <gecode/int.hh>
46
47#ifdef GECODE_HAS_SET_VARS
48#include <gecode/set.hh>
49#endif
50
51#ifdef GECODE_HAS_FLOAT_VARS
52#include <gecode/float.hh>
53#endif
54
55#include "test/test.hh"
56
57namespace Test {
58
59 /// Tests for branchings
60 namespace Branch {
61
62 /**
63 * \brief %Base class for tests for branching on integer variables
64 *
65 */
66 class IntTest : public Base {
67 protected:
68 /// Number of variables
69 int arity;
70 /// Domain of variables
71 Gecode::IntSet dom;
72 public:
73 /// Construct and register test
74 IntTest(const std::string& s, int a, const Gecode::IntSet& d);
75 /// Perform test
76 virtual bool run(void);
77 /// Post propagators on variables \a x
78 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) = 0;
79 };
80
81 /**
82 * \brief %Base class for tests for branching on Boolean variables
83 *
84 */
85 class BoolTest : public Base {
86 protected:
87 /// Number of variables
88 int arity;
89 public:
90 /// Construct and register test
91 BoolTest(const std::string& s, int a);
92 /// Perform test
93 virtual bool run(void);
94 /// Post propagators on variables \a x
95 virtual void post(Gecode::Space& home, Gecode::BoolVarArray& x) = 0;
96 };
97
98#ifdef GECODE_HAS_SET_VARS
99 /**
100 * \brief %Base class for tests for branching on set variables
101 *
102 */
103 class SetTest : public Base {
104 protected:
105 /// Number of variables
106 int arity;
107 /// Domain of variables
108 Gecode::IntSet dom;
109 public:
110 /// Construct and register test
111 SetTest(const std::string& s, int a, const Gecode::IntSet& d);
112 /// Perform test
113 virtual bool run(void);
114 /// Post propagators on variables \a x
115 virtual void post(Gecode::Space& home, Gecode::SetVarArray& x) = 0;
116 };
117#endif
118
119#ifdef GECODE_HAS_FLOAT_VARS
120 /**
121 * \brief %Base class for tests for branching on float variables
122 *
123 */
124 class FloatTest : public Base {
125 protected:
126 /// Number of variables
127 int arity;
128 /// Domain of variables
129 Gecode::FloatVal dom;
130 /// Maximum number of solutions searched during solving
131 int nbSols;
132 public:
133 /// Construct and register test
134 FloatTest(const std::string& s, int a, const Gecode::FloatVal& d, int nbs);
135 /// Perform test
136 virtual bool run(void);
137 /// Post propagators on variables \a x
138 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) = 0;
139 };
140#endif
141
142 }
143
144}
145
146#endif
147
148// STATISTICS: test-branch