Generated on for Gecode by doxygen 1.18.0
float.hh
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.dev>
5 * Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
6 * Vincent Barichard <Vincent.Barichard@univ-angers.fr>
7 *
8 * Copyright:
9 * Christian Schulte, 2005
10 * Mikael Zayenz Lagerkvist, 2006
11 * Vincent Barichard, 2012
12 *
13 * This file is part of Gecode, the generic constraint
14 * development environment:
15 * http://www.gecode.dev
16 *
17 * Permission is hereby granted, free of charge, to any person obtaining
18 * a copy of this software and associated documentation files (the
19 * "Software"), to deal in the Software without restriction, including
20 * without limitation the rights to use, copy, modify, merge, publish,
21 * distribute, sublicense, and/or sell copies of the Software, and to
22 * permit persons to whom the Software is furnished to do so, subject to
23 * the following conditions:
24 *
25 * The above copyright notice and this permission notice shall be
26 * included in all copies or substantial portions of the Software.
27 *
28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 *
36 */
37
38#ifndef GECODE_TEST_FLOAT_HH
39#define GECODE_TEST_FLOAT_HH
40
41#include "test/test.hh"
42
43#include <gecode/float.hh>
44
45/* Configure linking, as for the Gecode variable libraries. */
46#if !defined(GECODE_STATIC_LIBS) && \
47 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
48#ifdef GECODE_BUILD_TESTFLOAT
49#define GECODE_TESTFLOAT_EXPORT __declspec( dllexport )
50#else
51#define GECODE_TESTFLOAT_EXPORT __declspec( dllimport )
52#endif
53#elif defined(GECODE_GCC_HAS_CLASS_VISIBILITY)
54#define GECODE_TESTFLOAT_EXPORT __attribute__ ((visibility("default")))
55#else
56#define GECODE_TESTFLOAT_EXPORT
57#endif
58
59namespace Test {
60
62 namespace Float {
63
65 enum MaybeType {
66 MT_FALSE = 0, //< Does hold
67 MT_TRUE, //< Does not hold
68 MT_MAYBE //< Might or might not hold
69 };
70
73
80
82
87
93
95 protected:
96 int n;
98 public:
100 Assignment(int n0, const Gecode::FloatVal& d0);
102 virtual bool has_more(void) const = 0;
104 virtual void next(Gecode::Support::RandomGenerator& rand) = 0;
106 virtual Gecode::FloatVal operator[](int i) const = 0;
108 virtual void set(int i, const Gecode::FloatVal& val) = 0;
110 int size(void) const;
112 virtual ~Assignment(void);
113 };
114
117 protected:
120 public:
124 virtual bool has_more(void) const;
128 virtual Gecode::FloatVal operator[](int i) const;
130 virtual void set(int i, const Gecode::FloatVal& val);
132 virtual ~CpltAssignment(void);
133 };
134
137 protected:
138 const Test* curPb;
141 public:
143 ExtAssignment(int n, const Gecode::FloatVal& d, Gecode::FloatNum s, const Test* pb,
146 virtual bool has_more(void) const;
150 virtual Gecode::FloatVal operator[](int i) const;
152 virtual void set(int i, const Gecode::FloatVal& val);
154 virtual ~ExtAssignment(void);
155 };
156
157
160 protected:
162 int a;
165 public:
169 virtual bool has_more(void) const;
173 virtual Gecode::FloatVal operator[](int i) const;
175 virtual void set(int i, const Gecode::FloatVal& val);
177 virtual ~RandomAssignment(void);
178 };
179
254
260 protected:
262 int arity;
272 int rms;
280
281
282 bool eqv(void) const;
284 bool imp(void) const;
286 bool pmi(void) const;
288 public:
296 Test(const std::string& s, int a, const Gecode::FloatVal& d,
298 bool r);
300 Test(TestTags tags, const std::string& s, int a,
302 AssignmentType at, bool r);
310 Test(const std::string& s, int a,
313 bool r);
315 Test(TestTags tags, const std::string& s, int a,
317 Gecode::FloatNum st, AssignmentType at, bool r);
319 virtual Assignment* assignment(void) const;
322 virtual bool extendAssignment(Assignment& a) const;
324 virtual MaybeType solution(const Assignment&) const = 0;
327 bool subsumed(const TestSpace& ts) const;
329 virtual bool ignore(const Assignment& a) const;
331 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) = 0;
334 Gecode::Reify r);
336 virtual bool run(void);
338
339
340 static std::string str(Gecode::FloatRelType frt);
342 static std::string str(Gecode::FloatNum f);
344 static std::string str(Gecode::FloatVal f);
346 static std::string str(const Gecode::FloatValArgs& f);
348
350
356 bool flip(void);
358 };
359
360
363 private:
365 static const Gecode::FloatRelType frts[6];
367 int i;
368 public:
370 FloatRelTypes(void);
372 void reset(void);
374 bool operator()(void) const;
376 void operator++(void);
378 Gecode::FloatRelType frt(void) const;
379 };
380
381 }
382}
383
388GECODE_TESTFLOAT_EXPORT std::ostream& operator<<(std::ostream& os, const Test::Float::Assignment& a);
389
390#include "test/float.hpp"
391
392#endif
393
394// STATISTICS: test-float
Passing float arguments.
Definition float.hh:948
Float value type.
Definition float.hh:329
Float variable array.
Definition float.hh:1030
Reification specification.
Definition int.hh:1176
Computation spaces.
Definition core.hpp:1787
Base(std::string s)
Create and register a standard test with name s.
TestTags tags(void) const
Return tags for test.
Definition test.hpp:95
Base class for assignments
Definition float.hh:94
int n
Number of variables.
Definition float.hh:96
Assignment(int n0, const Gecode::FloatVal &d0)
Initialize assignments for n0 variables and values d0.
Definition float.hpp:45
virtual void next(Gecode::Support::RandomGenerator &rand)=0
Move to next assignment.
Gecode::FloatVal d
Domain for each variable.
Definition float.hh:97
virtual bool has_more(void) const =0
Test whether all assignments have been iterated.
virtual Gecode::FloatVal operator[](int i) const =0
Return value for variable i.
virtual void set(int i, const Gecode::FloatVal &val)=0
Set assignment to value val for variable i.
int size(void) const
Return number of variables.
Definition float.hpp:48
virtual Gecode::FloatVal operator[](int i) const
Return value for variable i.
Definition float.hpp:68
Gecode::FloatNum step
Step for next assignment.
Definition float.hh:119
virtual void next(Gecode::Support::RandomGenerator &rand)
Move to next assignment.
Gecode::FloatVal * dsv
Iterator for each variable.
Definition float.hh:118
virtual bool has_more(void) const
Test whether all assignments have been iterated.
Definition float.hpp:64
virtual void set(int i, const Gecode::FloatVal &val)
Set assignment to value val for variable i.
Definition float.hpp:73
CpltAssignment(int n, const Gecode::FloatVal &d, Gecode::FloatNum s)
Initialize assignments for n variables and values d with step s.
Definition float.hpp:55
virtual void next(Gecode::Support::RandomGenerator &rand)
Move to next assignment.
virtual bool has_more(void) const
Test whether all assignments have been iterated.
Definition float.hpp:94
virtual void set(int i, const Gecode::FloatVal &val)
Set assignment to value val for variable i.
Definition float.hpp:103
Gecode::FloatVal * dsv
Iterator for each variable.
Definition float.hh:139
virtual Gecode::FloatVal operator[](int i) const
Return value for variable i.
Definition float.hpp:98
Gecode::FloatNum step
Step for next assignment.
Definition float.hh:140
const Test * curPb
Current problem used to complete assignment.
Definition float.hh:138
ExtAssignment(int n, const Gecode::FloatVal &d, Gecode::FloatNum s, const Test *pb, Gecode::Support::RandomGenerator &rand)
Initialize assignments for n variables and values d with step s.
Definition float.hpp:83
void operator++(void)
Increment to next relation type.
Definition float.hpp:313
Gecode::FloatRelType frt(void) const
Return current relation type.
Definition float.hpp:317
FloatRelTypes(void)
Initialize iterator.
Definition float.hpp:302
bool operator()(void) const
Test whether iterator is done.
Definition float.hpp:309
void reset(void)
Reset iterator.
Definition float.hpp:305
virtual void next(Gecode::Support::RandomGenerator &rand)
Move to next assignment.
virtual Gecode::FloatVal operator[](int i) const
Return value for variable i.
Definition float.hpp:142
virtual void set(int i, const Gecode::FloatVal &val)
Set assignment to value val for variable i.
Definition float.hpp:147
RandomAssignment(int n, const Gecode::FloatVal &d, int a0, Gecode::Support::RandomGenerator &rand)
Initialize for a assignments for n variables and values d.
Definition float.hpp:131
Gecode::FloatNum randval(Gecode::Support::RandomGenerator &rand)
Definition float.hpp:113
Gecode::FloatVal * vals
The current values for the variables.
Definition float.hh:161
int a
How many assignments still to be generated Generate new value according to domain.
Definition float.hh:162
virtual bool has_more(void) const
Test whether all assignments have been iterated.
Definition float.hpp:138
Space for executing tests.
Definition float.hh:181
TestSpace(int n, Gecode::FloatVal &d, Gecode::FloatNum s, Test *t, Gecode::ReifyMode rm)
Create test space.
void bound(Gecode::Support::RandomGenerator &rand)
Assign a random variable to a random bound.
void prune(int i, Gecode::Support::RandomGenerator &rand)
Prune some random values from variable i.
Gecode::FloatVarArray x
Variables to be tested.
Definition float.hh:188
bool prune(const Assignment &a, bool testfix, Gecode::Support::RandomGenerator &rand)
Prune values but not those in assignment a.
Gecode::FloatNum cut(int *cutDirections)
Cut the bigger variable to an half sized interval. It returns the new size of the cut interval....
bool matchAssignment(const Assignment &a) const
Test whether all variables match assignment a.
Gecode::Reify r
Reification information.
Definition float.hh:190
virtual void dropUntil(const Assignment &a)
Add constraints to skip solutions to the a assignment.
unsigned int propagators(void)
Return the number of propagators.
void disable(void)
Disable propagators in space and compute fixpoint (make all idle).
void rel(bool sol)
Perform Boolean tell on b.
Gecode::FloatVal d
Initial domain.
Definition float.hh:184
void post(void)
Post propagator.
TestSpace(int n, Gecode::FloatVal &d, Gecode::FloatNum s, Test *t)
Create test space.
virtual Gecode::Space * copy(void)
Copy space during cloning.
Test * test
The test currently run.
Definition float.hh:192
bool reified
Whether the test is for a reified propagator.
Definition float.hh:194
void enable(void)
Enable propagators in space.
bool failed(void)
Compute a fixpoint and check for failure.
bool assigned(void) const
Test whether all variables are assigned.
Gecode::FloatNum step
Step for going to next solution.
Definition float.hh:186
void assign(const Assignment &a, MaybeType &sol, bool skip, Gecode::Support::RandomGenerator &rand)
Assign all (or all but one, if skip is true) variables to values in a If assignment of a variable is ...
void rel(int i, Gecode::FloatRelType frt, Gecode::FloatVal n)
Perform integer tell operation on x[i].
TestSpace(TestSpace &s)
Constructor for cloning s.
void prune(Gecode::Support::RandomGenerator &rand)
Prune some random values for some random variable.
int rms
Supported reification modes, encoded as a bit mask of 1 << Gecode::RM_*.
Definition float.hh:272
static MaybeType eq(Gecode::FloatVal x, Gecode::FloatVal y)
Whether x and y are equal.
Definition float.hpp:281
virtual bool ignore(const Assignment &a) const
Whether to ignore assignment for reification.
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, Gecode::Reify r)
Post reified constraint.
bool testsubsumed
Whether to test for subsumption.
Definition float.hh:278
bool testfix
Whether to perform fixpoint test.
Definition float.hh:276
bool eqv(void) const
Test whether equivalence as reification mode is supported.
Definition float.hpp:161
int arity
Number of variables.
Definition float.hh:262
virtual bool run(void)
Perform test.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)=0
Post constraint.
static std::string str(Gecode::FloatRelType frt)
Map float relation to string.
Definition float.hpp:207
bool flip(void)
Flip a coin and return true or false randomly.
Definition float.hpp:286
Gecode::FloatNum step
Step for going to next solution.
Definition float.hh:266
AssignmentType assignmentType
Gives the type of assignment to use.
Definition float.hh:268
bool pmi(void) const
Test whether reverse implication as reification mode is supported.
Definition float.hpp:169
virtual Assignment * assignment(void) const
Create assignment.
bool subsumed(const TestSpace &ts) const
Test if ts is subsumed or not (i.e. if there is no more propagator unless the assignment is an extend...
bool reified
Does the constraint also exist as reified constraint.
Definition float.hh:270
virtual bool extendAssignment(Assignment &a) const
Complete the current assignment to get a feasible one (which satisfies all constraint)....
bool testsearch
Whether to perform search test.
Definition float.hh:274
virtual MaybeType solution(const Assignment &) const =0
Check an interval assignment using MT_TRUE, MT_FALSE, or MT_MAYBE; see cmp().
Gecode::FloatVal dom
Domain of variables.
Definition float.hh:264
bool imp(void) const
Test whether implication as reification mode is supported.
Definition float.hpp:165
Set of test tags.
Definition test.hh:105
LinearCongruentialGenerator< 2147483647, 48271, 44488, 3399 > RandomGenerator
Default values for linear congruential generator.
Definition random.hpp:183
double FloatNum
Floating point number base type.
Definition float.hh:106
FloatRelType
Relation types for floats.
Definition float.hh:1070
ReifyMode
Mode for reification.
Definition int.hh:1148
Testing domain floats.
Definition float.hh:62
AssignmentType
Assignment possible types.
Definition float.hh:75
@ RANDOM_ASSIGNMENT
Definition float.hh:77
@ EXTEND_ASSIGNMENT
Definition float.hh:78
@ CPLT_ASSIGNMENT
Definition float.hh:76
MaybeType operator&(MaybeType a, MaybeType b)
Three-valued conjunction of MaybeType.
Definition float.hpp:291
MaybeType
Type for comparisons and solutions.
Definition float.hh:65
General test support.
Definition assign.hh:52
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const Dictionary &d)
Print statistics summary.
Definition scowl.hpp:13625
#define GECODE_TESTFLOAT_EXPORT
Definition float.hh:56