Generated on Thu Jan 31 2019 20:56:38 for Gecode by doxygen 1.8.15
int-trace-view.hpp
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  *
6  * Copyright:
7  * Christian Schulte, 2016
8  *
9  * Last modified:
10  * $Date: 2017-03-17 23:04:57 +0100 (Fri, 17 Mar 2017) $ by $Author: schulte $
11  * $Revision: 15597 $
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 namespace Gecode { namespace Int {
39 
41  class IntTraceView {
42  protected:
45  public:
47  IntTraceView(void);
49  IntTraceView(Space& home, IntView y);
51  RangeList* ranges(void) const;
53  void prune(Space& home, IntView y, const Delta& d);
55  void update(Space& home, bool share, IntTraceView x);
57  static unsigned long long int slack(IntView x);
58  };
59 
62 
66  RangeList::copy(home, dom, yr);
67  }
68 
70  IntTraceView::ranges(void) const {
71  return dom;
72  }
73 
74  forceinline void
76  if (y.range() && (dom->next() == NULL)) {
77  dom->min(y.min()); dom->max(y.max());
78  } else if (!y.any(d) && (y.max(d)+1 == y.min())) {
79  // The lower bound has been adjusted
80  if (y.min() > dom->max()) {
81  RangeList* p = dom;
82  RangeList* l = p->next();
83  while ((l != NULL) && (l->max() < y.min())) {
84  p=l; l=l->next();
85  }
86  dom->dispose(home,p);
87  dom = l;
88  }
89  dom->min(y.min());
90  } else if (!y.any(d) && (y.max()+1 == y.min(d))) {
91  // upper bound has been adjusted
92  if ((y.max() <= dom->max()) && (dom->next() == NULL)) {
93  dom->max(y.max());
94  } else {
95  RangeList* p = dom;
96  RangeList* l = p->next();
97  while ((l != NULL) && (l->min() <= y.max())) {
98  p=l; l=l->next();
99  }
100  p->max(y.max());
101  if (p->next() != NULL)
102  p->next()->dispose(home);
103  p->next(NULL);
104  }
105  } else {
106  // Just copy the domain
108  RangeList::overwrite(home,dom,yr);
109  }
110  }
111 
112  forceinline void
114  Iter::Ranges::RangeList yr(y.dom);
115  RangeList::copy(home,dom,yr);
116  }
117 
118  forceinline unsigned long long int
120  return x.width()-1;
121  }
122 
123 
124 }}
125 
126 // STATISTICS: int-trace
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
RangeList * dom
Ranges capturing the variable domain.
RangeList * ranges(void) const
Give access to ranges.
RangeList * next(void) const
Return next element.
Definition: range-list.hpp:145
void update(Space &home, bool share, IntTraceView x)
Update during cloning.
Range iterator for range lists
int min(void) const
Return minimum.
Definition: range-list.hpp:168
Range iterator for integer variable views
Definition: int.hpp:236
Computation spaces.
Definition: core.hpp:1748
Gecode::IntSet d(v, 7)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
int max(void) const
Return maximum.
Definition: range-list.hpp:172
static unsigned long long int slack(IntView x)
Return slack measure.
Duplicate of an integer view.
static void copy(Space &home, RangeList *&r, Iter &i)
Create rangelist r from range iterator i.
Definition: range-list.hpp:219
Integer view for integer variables.
Definition: view.hpp:129
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:784
Generic domain change information to be supplied to advisors.
Definition: core.hpp:281
#define forceinline
Definition: config.hpp:173
void prune(Space &home, IntView y, const Delta &d)
Update duplicated view from view y and modification delta d.
IntTraceView(void)
Default constructor (initializes with no view)
Post propagator for SetVar x
Definition: set.hh:784
void dispose(Space &home, RangeList *l)
Free memory for all elements between this and l (inclusive)
Definition: range-list.hpp:205
Lists of ranges (intervals)
Definition: range-list.hpp:53
static void overwrite(Space &home, RangeList *&r, Iter &i)
Overwrite rangelist r with ranges from range iterator i.
Definition: range-list.hpp:232
Gecode toplevel namespace