Generated on Tue Jan 19 2021 06:15:49 for Gecode by doxygen 1.8.13
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 
43 namespace Test {
44 
46  namespace Int {
47 
58  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 
96  class RandomAssignment : public Assignment {
97  protected:
98  int* vals;
99  int a;
100  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;
122  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 
144  };
145 
146  class Test;
147 
149  class TestSpace : public Gecode::Space {
150  public:
160  bool reified;
161 
168  TestSpace(int n, Gecode::IntSet& d, Test* t);
178  TestSpace(TestSpace& s);
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;
230  bool reified;
232  int rms;
240  bool testfix;
242 
243  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,
305  Gecode::Reify r);
307  virtual bool run(void);
309 
310  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  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:
358  IntPropBasicAdvanced(void);
360  bool operator()(void) const;
362  void operator++(void);
364  Gecode::IntPropLevel ipl(void) const;
365  };
366 
368  class IntRelTypes {
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 
388  class BoolOpTypes {
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 
412 std::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 
NodeType t
Type of node.
Definition: bool-expr.cpp:230
Gecode::IntSet d
Initial domain.
Definition: int.hh:152
Gecode::IntVarArray x
Variables to be tested.
Definition: int.hh:154
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:238
int size(void) const
Return number of variables.
Definition: int.hpp:46
int a
How many assigments still to be generated Generate new value according to domain. ...
Definition: int.hh:99
BoolOpType
Operation types for Booleans.
Definition: int.hh:950
Gecode::Reify r
Reification information.
Definition: int.hh:156
Gecode::IntSet dom
Domain of variables.
Definition: int.hh:228
Integer variable array.
Definition: int.hh:763
Space for executing tests.
Definition: int.hh:149
ConTestLevel contest
Whether to test for certain consistency.
Definition: int.hh:236
const int max
Largest allowed integer value.
Definition: int.hh:116
int rms
Which reification modes are supported.
Definition: int.hh:232
Computation spaces.
Definition: core.hpp:1701
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition: rel.hpp:264
int _n1
How many variables in the second set.
Definition: int.hh:120
Generate random selection of assignments.
Definition: int.hh:96
const int min
Smallest allowed integer value.
Definition: int.hh:118
Iterator for basic and advanced integer propagation levels.
Definition: int.hh:350
int n
Number of variables.
Definition: int.hh:61
Gecode::IntSet d1(v1, 7)
virtual int operator[](int i) const =0
Return value for variable i.
Gecode::IntSet d
Domain for each variable.
Definition: int.hh:62
Reify imp(BoolVar x)
Use implication for reification.
Definition: reify.hpp:73
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
Gecode::IntArgs i({1, 2, 3, 4})
No consistency-test.
Definition: int.hh:140
Generate random selection of assignments.
Definition: int.hh:116
IntRelType
Relation types for integers.
Definition: int.hh:925
ConTestLevel
Level of consistency to test for.
Definition: int.hh:139
int a
How many assigments still to be generated.
Definition: int.hh:119
Simple propagation levels.
Definition: int.hh:976
int * vals
The current values for the variables.
Definition: int.hh:118
Iterator for integer relation types.
Definition: int.hh:368
virtual void operator++(void)=0
Move to next assignment.
struct Gecode::@593::NNF::@62::@63 b
For binary nodes (and, or, eqv)
Reification specification.
Definition: int.hh:876
Base class for all tests to be run
Definition: test.hh:103
Gecode::IntSetValues * dsv
Iterator for each variable.
Definition: int.hh:81
Test for bounds(z)-consistency.
Definition: int.hh:143
Test for bounds(d)-consistency.
Definition: int.hh:142
Integer sets.
Definition: int.hh:174
Test for domain-consistency.
Definition: int.hh:141
Reify eqv(BoolVar x)
Use equivalence for reification.
Definition: reify.hpp:69
Gecode::IntPropLevel ipl
Propagation level.
Definition: int.hh:234
Passing integer arguments.
Definition: int.hh:628
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const Dictionary &d)
Print statistics summary.
Definition: scowl.hpp:13617
bool testfix
Whether to perform fixpoint test.
Definition: int.hh:240
const int v[7]
Definition: distinct.cpp:259
General test support.
Definition: afc.cpp:39
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:974
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
Gecode::IntSet _d1
Domain for second set of variables Generate new value according to domain d.
Definition: int.hh:121
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:249
Assignment(int n0, const Gecode::IntSet &d0)
Initialize assignments for n0 variables and values d0.
Definition: int.hpp:43
bool testsearch
Whether to perform search test.
Definition: int.hh:238
Region r
Definition: region.cpp:65
Base class for assignments
Definition: int.hh:59
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:43
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:43
Value iterator for integer sets.
Definition: int.hh:333
Iterator for Boolean operation types.
Definition: int.hh:388
int arity
Number of variables.
Definition: int.hh:226
virtual bool operator()(void) const =0
Test whether all assignments have been iterated.
void assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
Definition: branch.cpp:111
virtual ~Assignment(void)
Destructor.
Definition: int.hpp:50
Test * test
The test currently run.
Definition: int.hh:158
ReifyMode
Mode for reification.
Definition: int.hh:848
struct Gecode::@593::NNF::@62::@64 a
For atomic nodes.
bool reified
Does the constraint also exist as reified constraint.
Definition: int.hh:230
Generate all assignments.
Definition: int.hh:79
Iterator for simple integer propagation levels.
Definition: int.hh:332
int * vals
The current values for the variables.
Definition: int.hh:98
Reify pmi(BoolVar x)
Use reverse implication for reification.
Definition: reify.hpp:77
bool reified
Whether the test is for a reified propagator.
Definition: int.hh:160