Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
int.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 *
7 * Copyright:
8 * Christian Schulte, 2005
9 * Mikael Lagerkvist, 2006
10 *
11 * This file is part of Gecode, the generic constraint
12 * development environment:
13 * http://www.gecode.org
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining
16 * a copy of this software and associated documentation files (the
17 * "Software"), to deal in the Software without restriction, including
18 * without limitation the rights to use, copy, modify, merge, publish,
19 * distribute, sublicense, and/or sell copies of the Software, and to
20 * permit persons to whom the Software is furnished to do so, subject to
21 * the following conditions:
22 *
23 * The above copyright notice and this permission notice shall be
24 * included in all copies or substantial portions of the Software.
25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 *
34 */
35
36#ifndef __GECODE_TEST_INT_HH__
37#define __GECODE_TEST_INT_HH__
38
39#include "test/test.hh"
40
41#include <gecode/int.hh>
42
43namespace Test {
44
46 namespace Int {
47
59 class Assignment {
60 protected:
61 int n;
63 public:
65 Assignment(int n0, const Gecode::IntSet& d0);
67 virtual bool operator()(void) const = 0;
69 virtual void operator++(void) = 0;
71 virtual int operator[](int i) const = 0;
73 int size(void) const;
75 virtual ~Assignment(void);
76 };
77
79 class CpltAssignment : public Assignment {
80 protected:
82 public:
84 CpltAssignment(int n, const Gecode::IntSet& d);
86 virtual bool operator()(void) const;
88 virtual void operator++(void);
90 virtual int operator[](int i) const;
92 virtual ~CpltAssignment(void);
93 };
94
97 protected:
98 int* vals;
99 int a;
101 int randval(void);
102 public:
104 RandomAssignment(int n, const Gecode::IntSet& d, int a);
106 virtual bool operator()(void) const;
108 virtual void operator++(void);
110 virtual int operator[](int i) const;
112 virtual ~RandomAssignment(void);
113 };
114
117 protected:
118 int* vals;
119 int a;
120 int _n1;
123 int randval(const Gecode::IntSet& d);
124 public:
126 RandomMixAssignment(int n0, const Gecode::IntSet& d0,
127 int n1, const Gecode::IntSet& d1, int a0);
129 virtual bool operator()(void) const;
131 virtual void operator++(void);
133 virtual int operator[](int i) const;
135 virtual ~RandomMixAssignment(void);
136 };
137
145
146 class Test;
147
149 class TestSpace : public Gecode::Space {
150 public:
161
168 TestSpace(int n, Gecode::IntSet& d, Test* t);
180 virtual Gecode::Space* copy(void);
182 bool assigned(void) const;
184 void post(void);
186 bool failed(void);
188 int rndvar(void);
190 void rndrel(const Assignment& a, int i, Gecode::IntRelType& irt, int& v);
192 void rel(int i, Gecode::IntRelType irt, int n);
194 void rel(bool sol);
196 void assign(const Assignment& a, bool skip=false);
198 void bound(void);
204 void prune(int i, bool bounds_only);
206 void prune(void);
208 bool prune(const Assignment& a, bool testfix);
210 void disable(void);
212 void enable(void);
214 bool disabled(const Assignment& a, TestSpace& c, bool testfix);
216 unsigned int propagators(void);
217 };
218
223 class Test : public Base {
224 protected:
226 int arity;
232 int rms;
242
243
244 bool eqv(void) const;
246 bool imp(void) const;
248 bool pmi(void) const;
250 public:
259 Test(const std::string& p, const std::string& s,
260 int a, const Gecode::IntSet& d, bool r=false,
270 Test(const std::string& s,
271 int a, const Gecode::IntSet& d, bool r=false,
281 Test(const std::string& p, const std::string& s,
282 int a, int min, int max, bool r=false,
292 Test(const std::string& s,
293 int a, int min, int max, bool r=false,
296 virtual Assignment* assignment(void) const;
298 virtual bool solution(const Assignment&) const = 0;
300 virtual bool ignore(const Assignment&) const;
302 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) = 0;
304 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
307 virtual bool run(void);
309
310
311 static std::string str(Gecode::IntPropLevel ipl);
313 static std::string str(Gecode::IntRelType irl);
315 static std::string str(Gecode::BoolOpType bot);
317 static std::string str(bool b);
319 static std::string str(int i);
321 static std::string str(const Gecode::IntArgs& i);
323
325
326 template<class T> static bool cmp(T x, Gecode::IntRelType r, T y);
328 };
330
333 private:
335 static const Gecode::IntPropLevel ipls[3];
337 int i;
338 public:
340 IntPropLevels(void);
342 bool operator()(void) const;
344 void operator++(void);
346 Gecode::IntPropLevel ipl(void) const;
347 };
348
351 private:
353 static const Gecode::IntPropLevel ipls[3];
355 int i;
356 public:
360 bool operator()(void) const;
362 void operator++(void);
364 Gecode::IntPropLevel ipl(void) const;
365 };
366
369 private:
371 static const Gecode::IntRelType irts[6];
373 int i;
374 public:
376 IntRelTypes(void);
378 void reset(void);
380 bool operator()(void) const;
382 void operator++(void);
384 Gecode::IntRelType irt(void) const;
385 };
386
389 private:
391 static const Gecode::BoolOpType bots[5];
393 int i;
394 public:
396 BoolOpTypes(void);
398 bool operator()(void) const;
400 void operator++(void);
402 Gecode::BoolOpType bot(void) const;
403 };
404
405 }
406}
407
412std::ostream& operator<<(std::ostream& os, const Test::Int::Assignment& a);
413
414#include "test/int.hpp"
415
416#endif
417
418// STATISTICS: test-int
419
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
NodeType t
Type of node.
int p
Number of positive literals for node type.
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 integer arguments.
Definition int.hh:628
Value iterator for integer sets.
Definition int.hh:333
Integer sets.
Definition int.hh:174
Integer variable array.
Definition int.hh:763
Reification specification.
Definition int.hh:876
Computation spaces.
Definition core.hpp:1742
struct Gecode::Space::@61::@63 c
Data available only during copying.
Base class for all tests to be run
Definition test.hh:103
Base class for assignments
Definition int.hh:59
Gecode::IntSet d
Domain for each variable.
Definition int.hh:62
int n
Number of variables.
Definition int.hh:61
virtual ~Assignment(void)
Destructor.
Definition int.hpp:50
Assignment(int n0, const Gecode::IntSet &d0)
Initialize assignments for n0 variables and values d0.
Definition int.hpp:43
virtual void operator++(void)=0
Move to next assignment.
int size(void) const
Return number of variables.
Definition int.hpp:46
virtual bool operator()(void) const =0
Test whether all assignments have been iterated.
virtual int operator[](int i) const =0
Return value for variable i.
Iterator for Boolean operation types.
Definition int.hh:388
Generate all assignments.
Definition int.hh:79
CpltAssignment(int n, const Gecode::IntSet &d)
Initialize assignments for n0 variables and values d0.
Definition int.hpp:54
virtual int operator[](int i) const
Return value for variable i.
Definition int.hpp:65
virtual ~CpltAssignment(void)
Destructor.
Definition int.hpp:70
virtual bool operator()(void) const
Test whether all assignments have been iterated.
Definition int.hpp:61
Gecode::IntSetValues * dsv
Iterator for each variable.
Definition int.hh:81
virtual void operator++(void)
Move to next assignment.
Definition int.cpp:48
Iterator for basic and advanced integer propagation levels.
Definition int.hh:350
Iterator for simple integer propagation levels.
Definition int.hh:332
Iterator for integer relation types.
Definition int.hh:368
Generate random selection of assignments.
Definition int.hh:96
virtual int operator[](int i) const
Return value for variable i.
Definition int.hpp:99
virtual ~RandomAssignment(void)
Destructor.
Definition int.hpp:104
RandomAssignment(int n, const Gecode::IntSet &d, int a)
Initialize for a assignments for n0 variables and values d0.
Definition int.hpp:88
int a
How many assigments still to be generated Generate new value according to domain.
Definition int.hh:99
int * vals
The current values for the variables.
Definition int.hh:98
virtual bool operator()(void) const
Test whether all assignments have been iterated.
Definition int.hpp:95
virtual void operator++(void)
Move to next assignment.
Definition int.cpp:63
Generate random selection of assignments.
Definition int.hh:116
int _n1
How many variables in the second set.
Definition int.hh:120
RandomMixAssignment(int n0, const Gecode::IntSet &d0, int n1, const Gecode::IntSet &d1, int a0)
Initialize for a assignments for n0 variables and values d0.
Definition int.hpp:121
Gecode::IntSet _d1
Domain for second set of variables Generate new value according to domain d.
Definition int.hh:121
virtual int operator[](int i) const
Return value for variable i.
Definition int.hpp:138
virtual bool operator()(void) const
Test whether all assignments have been iterated.
Definition int.hpp:133
virtual ~RandomMixAssignment(void)
Destructor.
Definition int.hpp:144
int a
How many assigments still to be generated.
Definition int.hh:119
int * vals
The current values for the variables.
Definition int.hh:118
virtual void operator++(void)
Move to next assignment.
Definition int.cpp:70
int randval(const Gecode::IntSet &d)
Definition int.hpp:109
Space for executing tests.
Definition int.hh:149
Gecode::Reify r
Reification information.
Definition int.hh:156
TestSpace(int n, Gecode::IntSet &d, Test *t)
Create test space without reification.
Definition int.cpp:91
Gecode::IntSet d
Initial domain.
Definition int.hh:152
void rndrel(const Assignment &a, int i, Gecode::IntRelType &irt, int &v)
Randomly select a pruning rel for variable i.
Definition int.cpp:181
Test * test
The test currently run.
Definition int.hh:158
virtual Gecode::Space * copy(void)
Copy space during cloning.
Definition int.cpp:132
void post(void)
Post propagator.
Definition int.cpp:145
bool assigned(void) const
Test whether all variables are assigned.
Definition int.cpp:137
void prune(void)
Prune some random values for some random variable.
Definition int.cpp:316
void bound(void)
Assing a random variable to a random bound.
Definition int.cpp:272
void assign(const Assignment &a, bool skip=false)
Assign all (or all but one, if skip is true) variables to values in a.
Definition int.cpp:259
bool failed(void)
Compute a fixpoint and check for failure.
Definition int.cpp:158
bool reified
Whether the test is for a reified propagator.
Definition int.hh:160
int rndvar(void)
Randomly select an unassigned variable.
Definition int.cpp:170
bool disabled(const Assignment &a, TestSpace &c, bool testfix)
Prune values also in a space c with disabled propagators, but not those in assignment a.
Definition int.cpp:373
void disable(void)
Disable propagators in space and compute fixpoint (make all idle)
Definition int.cpp:367
Gecode::IntVarArray x
Variables to be tested.
Definition int.hh:154
void enable(void)
Enable propagators in space.
Definition int.cpp:362
void rel(int i, Gecode::IntRelType irt, int n)
Perform integer tell operation on x[i].
Definition int.cpp:233
unsigned int propagators(void)
Return the number of propagators.
Definition int.cpp:421
bool reified
Does the constraint also exist as reified constraint.
Definition int.hh:230
bool testsearch
Whether to perform search test.
Definition int.hh:238
bool testfix
Whether to perform fixpoint test.
Definition int.hh:240
int rms
Which reification modes are supported.
Definition int.hh:232
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)=0
Post constraint.
Gecode::IntPropLevel ipl
Propagation level.
Definition int.hh:234
int arity
Number of variables.
Definition int.hh:226
virtual bool solution(const Assignment &) const =0
Check for solution.
Gecode::IntSet dom
Domain of variables.
Definition int.hh:228
ConTestLevel contest
Whether to test for certain consistency.
Definition int.hh:236
IntRelType
Relation types for integers.
Definition int.hh:925
ReifyMode
Mode for reification.
Definition int.hh:848
BoolOpType
Operation types for Booleans.
Definition int.hh:950
IntPropLevel
Propagation levels for integer propagators.
Definition int.hh:974
@ IPL_DEF
Simple propagation levels.
Definition int.hh:976
ConTestLevel
Level of consistency to test for.
Definition int.hh:139
@ CTL_BOUNDS_Z
Test for bounds(z)-consistency.
Definition int.hh:143
@ CTL_BOUNDS_D
Test for bounds(d)-consistency.
Definition int.hh:142
@ CTL_NONE
No consistency-test.
Definition int.hh:140
@ CTL_DOMAIN
Test for domain-consistency.
Definition int.hh:141
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