Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.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.org>
5 * Mikael Lagerkvist <lagerkvist@gecode.org>
6 * Vincent Barichard <Vincent.Barichard@univ-angers.fr>
7 *
8 * Copyright:
9 * Christian Schulte, 2005
10 * Mikael Lagerkvist, 2006
11 * Vincent Barichard, 2012
12 *
13 * This file is part of Gecode, the generic constraint
14 * development environment:
15 * http://www.gecode.org
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
45namespace Test {
46
48 namespace Float {
49
51 enum MaybeType {
52 MT_FALSE = 0, //< Does hold
53 MT_TRUE, //< Does not hold
54 MT_MAYBE //< Might or might not hold
55 };
56
59
66
67 class Test;
68
80 class Assignment {
81 protected:
82 int n;
84 public:
86 Assignment(int n0, const Gecode::FloatVal& d0);
88 virtual bool operator()(void) const = 0;
90 virtual void operator++(void) = 0;
92 virtual Gecode::FloatVal operator[](int i) const = 0;
94 virtual void set(int i, const Gecode::FloatVal& val) = 0;
96 int size(void) const;
98 virtual ~Assignment(void);
99 };
100
102 class CpltAssignment : public Assignment {
103 protected:
106 public:
110 virtual bool operator()(void) const;
112 virtual void operator++(void);
114 virtual Gecode::FloatVal operator[](int i) const;
116 virtual void set(int i, const Gecode::FloatVal& val);
118 virtual ~CpltAssignment(void);
119 };
120
122 class ExtAssignment : public Assignment {
123 protected:
124 const Test* curPb;
127 public:
129 ExtAssignment(int n, const Gecode::FloatVal& d, Gecode::FloatNum s, const Test * pb);
131 virtual bool operator()(void) const;
133 virtual void operator++(void);
135 virtual Gecode::FloatVal operator[](int i) const;
137 virtual void set(int i, const Gecode::FloatVal& val);
139 virtual ~ExtAssignment(void);
140 };
141
142
145 protected:
147 int a;
150 public:
152 RandomAssignment(int n, const Gecode::FloatVal& d, int a);
154 virtual bool operator()(void) const;
156 virtual void operator++(void);
158 virtual Gecode::FloatVal operator[](int i) const;
160 virtual void set(int i, const Gecode::FloatVal& val);
162 virtual ~RandomAssignment(void);
163 };
164
166 class TestSpace : public Gecode::Space {
167 public:
180
201 virtual Gecode::Space* copy(void);
203 virtual void dropUntil(const Assignment& a);
205 bool assigned(void) const;
207 bool matchAssignment(const Assignment& a) const;
209 void post(void);
211 bool failed(void);
213 void rel(int i, Gecode::FloatRelType frt, Gecode::FloatVal n);
215 void rel(bool sol);
219 void assign(const Assignment& a, MaybeType& sol, bool skip=false);
221 void bound(void);
225 Gecode::FloatNum cut(int* cutDirections);
227 void prune(int i);
229 void prune(void);
231 bool prune(const Assignment& a, bool testfix);
233 void disable(void);
235 void enable(void);
237 unsigned int propagators(void);
238 };
239
244 class Test : public Base {
245 protected:
247 int arity;
257 int rms;
265
266
267 bool eqv(void) const;
269 bool imp(void) const;
271 bool pmi(void) const;
273 public:
281 Test(const std::string& s, int a, const Gecode::FloatVal& d,
283 bool r);
291 Test(const std::string& s, int a,
294 bool r);
296 virtual Assignment* assignment(void) const;
299 virtual bool extendAssignement(Assignment& a) const;
301 virtual MaybeType solution(const Assignment&) const = 0;
304 bool subsumed(const TestSpace& ts) const;
306 virtual bool ignore(const Assignment& a) const;
308 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) = 0;
310 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x,
313 virtual bool run(void);
315
316
317 static std::string str(Gecode::FloatRelType frt);
319 static std::string str(Gecode::FloatNum f);
321 static std::string str(Gecode::FloatVal f);
323 static std::string str(const Gecode::FloatValArgs& f);
325
327
333 bool flip(void);
335 };
337
340 private:
342 static const Gecode::FloatRelType frts[6];
344 int i;
345 public:
347 FloatRelTypes(void);
349 void reset(void);
351 bool operator()(void) const;
353 void operator++(void);
355 Gecode::FloatRelType frt(void) const;
356 };
357
358 }
359}
360
365std::ostream& operator<<(std::ostream& os, const Test::Float::Assignment& a);
366
367#include "test/float.hpp"
368
369#endif
370
371// STATISTICS: test-float
372
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
NodeType t
Type of node.
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Node * x
Pointer to corresponding Boolean expression node.
Passing float arguments.
Definition float.hh:950
Float value type.
Definition float.hh:334
Float variable array.
Definition float.hh:1030
Reification specification.
Definition int.hh:876
Computation spaces.
Definition core.hpp:1742
Base class for all tests to be run
Definition test.hh:103
Base class for assignments
Definition float.hh:80
int n
Number of variables.
Definition float.hh:82
virtual bool operator()(void) const =0
Test whether all assignments have been iterated.
Assignment(int n0, const Gecode::FloatVal &d0)
Initialize assignments for n0 variables and values d0.
Definition float.hpp:45
Gecode::FloatVal d
Domain for each variable.
Definition float.hh:83
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 void operator++(void)=0
Move to next assignment.
virtual ~Assignment(void)
Destructor.
Definition float.hpp:52
Generate all assignments.
Definition float.hh:102
virtual void operator++(void)
Move to next assignment.
Definition float.cpp:50
virtual ~CpltAssignment(void)
Destructor.
Definition float.hpp:78
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:105
Gecode::FloatVal * dsv
Iterator for each variable.
Definition float.hh:104
virtual void set(int i, const Gecode::FloatVal &val)
Set assignment to value val for variable i.
Definition float.hpp:73
virtual bool operator()(void) const
Test whether all assignments have been iterated.
Definition float.hpp:64
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
Generate all assignments except the last variable and complete it to get a solution.
Definition float.hh:122
ExtAssignment(int n, const Gecode::FloatVal &d, Gecode::FloatNum s, const Test *pb)
Initialize assignments for n variables and values d with step s.
Definition float.hpp:83
virtual ~ExtAssignment(void)
Destructor.
Definition float.hpp:107
virtual void set(int i, const Gecode::FloatVal &val)
Set assignment to value val for variable i.
Definition float.hpp:102
Gecode::FloatVal * dsv
Iterator for each variable.
Definition float.hh:125
virtual Gecode::FloatVal operator[](int i) const
Return value for variable i.
Definition float.hpp:97
virtual void operator++(void)
Move to next assignment.
Definition float.cpp:67
Gecode::FloatNum step
Step for next assignment.
Definition float.hh:126
const Test * curPb
Current problem used to complete assignment.
Definition float.hh:124
virtual bool operator()(void) const
Test whether all assignments have been iterated.
Definition float.hpp:93
Iterator for float relation types.
Definition float.hh:339
Generate random selection of assignments.
Definition float.hh:144
RandomAssignment(int n, const Gecode::FloatVal &d, int a)
Initialize for a assignments for n variables and values d.
Definition float.hpp:130
virtual Gecode::FloatVal operator[](int i) const
Return value for variable i.
Definition float.hpp:141
virtual void set(int i, const Gecode::FloatVal &val)
Set assignment to value val for variable i.
Definition float.hpp:146
Gecode::FloatNum randval(void)
Definition float.hpp:112
Gecode::FloatVal * vals
The current values for the variables.
Definition float.hh:146
virtual bool operator()(void) const
Test whether all assignments have been iterated.
Definition float.hpp:137
virtual void operator++(void)
Move to next assignment.
Definition float.cpp:89
int a
How many assigments still to be generated Generate new value according to domain.
Definition float.hh:147
virtual ~RandomAssignment(void)
Destructor.
Definition float.hpp:151
Space for executing tests.
Definition float.hh:166
Gecode::FloatVarArray x
Variables to be tested.
Definition float.hh:173
void prune(void)
Prune some random values for some random variable.
Definition float.cpp:348
Gecode::FloatNum cut(int *cutDirections)
Cut the bigger variable to an half sized interval. It returns the new size of the cut interval....
Definition float.cpp:303
bool matchAssignment(const Assignment &a) const
Test whether all variables match assignment a.
Definition float.cpp:211
Gecode::Reify r
Reification information.
Definition float.hh:175
void bound(void)
Assing a random variable to a random bound.
Definition float.cpp:288
unsigned int propagators(void)
Return the number of propagators.
Definition float.cpp:410
void disable(void)
Disable propagators in space and compute fixpoint (make all idle)
Definition float.cpp:191
Gecode::FloatVal d
Initial domain.
Definition float.hh:169
void post(void)
Post propagator.
Definition float.cpp:219
TestSpace(int n, Gecode::FloatVal &d, Gecode::FloatNum s, Test *t)
Create test space.
Definition float.cpp:143
Test * test
The test currently run.
Definition float.hh:177
bool reified
Whether the test is for a reified propagator.
Definition float.hh:179
void enable(void)
Enable propagators in space.
Definition float.cpp:186
bool failed(void)
Compute a fixpoint and check for failure.
Definition float.cpp:232
bool assigned(void) const
Test whether all variables are assigned.
Definition float.cpp:203
virtual void dropUntil(const Assignment &a)
Add constraints to skip solutions to the a assignment.
Definition float.cpp:197
Gecode::FloatNum step
Step for going to next solution.
Definition float.hh:171
void rel(int i, Gecode::FloatRelType frt, Gecode::FloatVal n)
Perform integer tell operation on x[i].
Definition float.cpp:244
void assign(const Assignment &a, MaybeType &sol, bool skip=false)
Assign all (or all but one, if skip is true) variables to values in a If assignment of a variable is ...
Definition float.cpp:270
virtual Gecode::Space * copy(void)
Copy space during cloning.
Definition float.cpp:181
int rms
Which reification modes are supported.
Definition float.hh:257
bool testsubsumed
Whether to test for subsumption.
Definition float.hh:263
bool testfix
Whether to perform fixpoint test.
Definition float.hh:261
int arity
Number of variables.
Definition float.hh:247
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)=0
Post constraint.
Gecode::FloatNum step
Step for going to next solution.
Definition float.hh:251
bool reified
Does the constraint also exist as reified constraint.
Definition float.hh:255
bool testsearch
Whether to perform search test.
Definition float.hh:259
virtual MaybeType solution(const Assignment &) const =0
Check for solution.
AssignmentType assigmentType
Gives the type of assignment to use.
Definition float.hh:253
Gecode::FloatVal dom
Domain of variables.
Definition float.hh:249
double FloatNum
Floating point number base type.
Definition float.hh:106
FloatRelType
Relation types for floats.
Definition float.hh:1068
ReifyMode
Mode for reification.
Definition int.hh:848
AssignmentType
Assignment possible types.
Definition float.hh:61
@ RANDOM_ASSIGNMENT
Definition float.hh:63
@ EXTEND_ASSIGNMENT
Definition float.hh:64
@ CPLT_ASSIGNMENT
Definition float.hh:62
MaybeType operator&(MaybeType a, MaybeType b)
Three-valued conjunction of MaybeType.
Definition float.hpp:278
MaybeType
Type for comparisons and solutions.
Definition float.hh:51
General test support.
Definition afc.cpp:39
Region r
Definition region.cpp:65
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const Dictionary &d)
Print statistics summary.
Definition scowl.hpp:13625