Generated on Thu Mar 16 2017 03:24:18 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  * Last modified:
12  * $Date: 2016-08-26 11:14:49 +0200 (Fri, 26 Aug 2016) $ by $Author: schulte $
13  * $Revision: 15156 $
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_INT_HH__
41 #define __GECODE_TEST_INT_HH__
42 
43 #include "test/test.hh"
44 
45 #include <gecode/int.hh>
46 
47 namespace Test {
48 
50  namespace Int {
51 
62  class Assignment {
64  protected:
65  int n;
67  public:
69  Assignment(int n0, const Gecode::IntSet& d0);
71  virtual bool operator()(void) const = 0;
73  virtual void operator++(void) = 0;
75  virtual int operator[](int i) const = 0;
77  int size(void) const;
79  virtual ~Assignment(void);
80  };
81 
83  class CpltAssignment : public Assignment {
84  protected:
86  public:
88  CpltAssignment(int n, const Gecode::IntSet& d);
90  virtual bool operator()(void) const;
92  virtual void operator++(void);
94  virtual int operator[](int i) const;
96  virtual ~CpltAssignment(void);
97  };
98 
100  class RandomAssignment : public Assignment {
101  protected:
102  int* vals;
103  int a;
104  int randval(void);
106  public:
108  RandomAssignment(int n, const Gecode::IntSet& d, int a);
110  virtual bool operator()(void) const;
112  virtual void operator++(void);
114  virtual int operator[](int i) const;
116  virtual ~RandomAssignment(void);
117  };
118 
121  protected:
122  int* vals;
123  int a;
124  int _n1;
126  int randval(const Gecode::IntSet& d);
128  public:
130  RandomMixAssignment(int n0, const Gecode::IntSet& d0,
131  int n1, const Gecode::IntSet& d1, int a0);
133  virtual bool operator()(void) const;
135  virtual void operator++(void);
137  virtual int operator[](int i) const;
139  virtual ~RandomMixAssignment(void);
140  };
141 
148  };
149 
150  class Test;
151 
153  class TestSpace : public Gecode::Space {
154  public:
164  bool reified;
165 
172  TestSpace(int n, Gecode::IntSet& d, Test* t);
182  TestSpace(bool share, TestSpace& s);
184  virtual Gecode::Space* copy(bool share);
186  bool assigned(void) const;
188  void post(void);
190  bool failed(void);
192  int rndvar(void);
194  void rndrel(const Assignment& a, int i, Gecode::IntRelType& irt, int& v);
196  void rel(int i, Gecode::IntRelType irt, int n);
198  void rel(bool sol);
200  void assign(const Assignment& a, bool skip=false);
202  void bound(void);
208  void prune(int i, bool bounds_only);
210  void prune(void);
212  bool prune(const Assignment& a, bool testfix);
214  void disable(void);
216  void enable(void);
218  bool disabled(const Assignment& a, TestSpace& c, bool testfix);
220  unsigned int propagators(void);
221  };
222 
227  class Test : public Base {
228  protected:
230  int arity;
234  bool reified;
236  int rms;
244  bool testfix;
246 
247  bool eqv(void) const;
250  bool imp(void) const;
252  bool pmi(void) const;
254  public:
263  Test(const std::string& p, const std::string& s,
264  int a, const Gecode::IntSet& d, bool r=false,
274  Test(const std::string& s,
275  int a, const Gecode::IntSet& d, bool r=false,
285  Test(const std::string& p, const std::string& s,
286  int a, int min, int max, bool r=false,
296  Test(const std::string& s,
297  int a, int min, int max, bool r=false,
300  virtual Assignment* assignment(void) const;
302  virtual bool solution(const Assignment&) const = 0;
304  virtual bool ignore(const Assignment&) const;
306  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) = 0;
308  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
309  Gecode::Reify r);
311  virtual bool run(void);
313 
314  static std::string str(Gecode::IntPropLevel ipl);
317  static std::string str(Gecode::IntRelType irl);
319  static std::string str(Gecode::BoolOpType bot);
321  static std::string str(int i);
323  static std::string str(const Gecode::IntArgs& i);
325 
327  template<class T> static bool cmp(T x, Gecode::IntRelType r, T y);
330  };
332 
335  private:
337  static const Gecode::IntPropLevel ipls[3];
339  int i;
340  public:
342  IntPropLevels(void);
344  bool operator()(void) const;
346  void operator++(void);
348  Gecode::IntPropLevel ipl(void) const;
349  };
350 
353  private:
355  static const Gecode::IntPropLevel ipls[3];
357  int i;
358  public:
360  IntPropBasicAdvanced(void);
362  bool operator()(void) const;
364  void operator++(void);
366  Gecode::IntPropLevel ipl(void) const;
367  };
368 
370  class IntRelTypes {
371  private:
373  static const Gecode::IntRelType irts[6];
375  int i;
376  public:
378  IntRelTypes(void);
380  void reset(void);
382  bool operator()(void) const;
384  void operator++(void);
386  Gecode::IntRelType irt(void) const;
387  };
388 
390  class BoolOpTypes {
391  private:
393  static const Gecode::BoolOpType bots[5];
395  int i;
396  public:
398  BoolOpTypes(void);
400  bool operator()(void) const;
402  void operator++(void);
404  Gecode::BoolOpType bot(void) const;
405  };
406 
407  }
408 }
409 
414 std::ostream& operator<<(std::ostream& os, const Test::Int::Assignment& a);
415 
416 #include "test/int.hpp"
417 
418 #endif
419 
420 // STATISTICS: test-int
421 
NodeType t
Type of node.
Definition: bool-expr.cpp:234
Gecode::IntSet d
Initial domain.
Definition: int.hh:156
Gecode::IntVarArray x
Variables to be tested.
Definition: int.hh:158
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:228
int size(void) const
Return number of variables.
Definition: int.hpp:50
int a
How many assigments still to be generated Generate new value according to domain. ...
Definition: int.hh:103
BoolOpType
Operation types for Booleans.
Definition: int.hh:917
Gecode::Reify r
Reification information.
Definition: int.hh:160
Gecode::IntSet dom
Domain of variables.
Definition: int.hh:232
Integer variable array.
Definition: int.hh:742
Space for executing tests.
Definition: int.hh:153
ConTestLevel contest
Whether to test for certain consistency.
Definition: int.hh:240
const int max
Largest allowed integer value.
Definition: int.hh:114
int rms
Which reification modes are supported.
Definition: int.hh:236
Computation spaces.
Definition: core.hpp:1672
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition: rel.hpp:257
int _n1
How many variables in the second set.
Definition: int.hh:124
Generate random selection of assignments.
Definition: int.hh:100
const int min
Smallest allowed integer value.
Definition: int.hh:116
Iterator for basic and advanced integer propagation levels.
Definition: int.hh:352
int n
Number of variables.
Definition: int.hh:65
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:66
Reify imp(BoolVar x)
Use implication for reification.
Definition: reify.hpp:77
Gecode::FloatVal c(-8, 8)
struct Gecode::@554::NNF::@60::@62 a
For atomic nodes.
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
Gecode::IntArgs i(4, 1, 2, 3, 4)
void assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
Definition: branch.cpp:113
No consistency-test.
Definition: int.hh:144
Generate random selection of assignments.
Definition: int.hh:120
IntRelType
Relation types for integers.
Definition: int.hh:904
ConTestLevel
Level of consistency to test for.
Definition: int.hh:143
int a
How many assigments still to be generated.
Definition: int.hh:123
Simple propagation levels.
Definition: int.hh:943
int * vals
The current values for the variables.
Definition: int.hh:122
Iterator for integer relation types.
Definition: int.hh:370
virtual void operator++(void)=0
Move to next assignment.
Reification specification.
Definition: int.hh:855
Base class for all tests to be run
Definition: test.hh:107
Gecode::IntSetValues * dsv
Iterator for each variable.
Definition: int.hh:85
Test for bounds(z)-consistency.
Definition: int.hh:147
Test for bounds(d)-consistency.
Definition: int.hh:146
Integer sets.
Definition: int.hh:172
Test for domain-consistency.
Definition: int.hh:145
Reify eqv(BoolVar x)
Use equivalence for reification.
Definition: reify.hpp:73
Gecode::IntPropLevel ipl
Propagation level.
Definition: int.hh:238
Passing integer arguments.
Definition: int.hh:608
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const Dictionary &d)
Print statistics summary.
Definition: scowl.hpp:13621
bool testfix
Whether to perform fixpoint test.
Definition: int.hh:244
const int v[7]
Definition: distinct.cpp:263
General test support.
Definition: afc.cpp:43
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:941
Gecode::IntSet _d1
Domain for second set of variables Generate new value according to domain d.
Definition: int.hh:125
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Assignment(int n0, const Gecode::IntSet &d0)
Initialize assignments for n0 variables and values d0.
Definition: int.hpp:47
bool testsearch
Whether to perform search test.
Definition: int.hh:242
Region r
Definition: region.cpp:82
Base class for assignments
Definition: int.hh:63
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:47
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
Value iterator for integer sets.
Definition: int.hh:313
Iterator for Boolean operation types.
Definition: int.hh:390
int arity
Number of variables.
Definition: int.hh:230
virtual bool operator()(void) const =0
Test whether all assignments have been iterated.
virtual ~Assignment(void)
Destructor.
Definition: int.hpp:54
Test * test
The test currently run.
Definition: int.hh:162
ReifyMode
Mode for reification.
Definition: int.hh:827
bool reified
Does the constraint also exist as reified constraint.
Definition: int.hh:234
Generate all assignments.
Definition: int.hh:83
Iterator for simple integer propagation levels.
Definition: int.hh:334
int * vals
The current values for the variables.
Definition: int.hh:102
Reify pmi(BoolVar x)
Use reverse implication for reification.
Definition: reify.hpp:81
bool reified
Whether the test is for a reified propagator.
Definition: int.hh:164