Generated on Fri Jan 28 2022 04:43:06 for Gecode by doxygen 1.8.13
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  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 namespace Gecode { namespace Int {
35 
37  class IntTraceView {
38  protected:
41  public:
43  IntTraceView(void);
45  IntTraceView(Space& home, IntView y);
47  RangeList* ranges(void) const;
49  void prune(Space& home, IntView y, const Delta& d);
51  void update(Space& home, IntTraceView x);
53  static unsigned long long int slack(IntView x);
54  };
55 
58 
61  ViewRanges<IntView> yr(y);
62  RangeList::copy(home, dom, yr);
63  }
64 
66  IntTraceView::ranges(void) const {
67  return dom;
68  }
69 
70  forceinline void
72  if (y.range() && (dom->next() == NULL)) {
73  dom->min(y.min()); dom->max(y.max());
74  } else if (!y.any(d) && (y.max(d)+1 == y.min())) {
75  // The lower bound has been adjusted
76  if (y.min() > dom->max()) {
77  RangeList* p = dom;
78  RangeList* l = p->next();
79  while ((l != NULL) && (l->max() < y.min())) {
80  p=l; l=l->next();
81  }
82  dom->dispose(home,p);
83  dom = l;
84  }
85  dom->min(y.min());
86  } else if (!y.any(d) && (y.max()+1 == y.min(d))) {
87  // upper bound has been adjusted
88  if ((y.max() <= dom->max()) && (dom->next() == NULL)) {
89  dom->max(y.max());
90  } else {
91  RangeList* p = dom;
92  RangeList* l = p->next();
93  while ((l != NULL) && (l->min() <= y.max())) {
94  p=l; l=l->next();
95  }
96  p->max(y.max());
97  if (p->next() != NULL)
98  p->next()->dispose(home);
99  p->next(NULL);
100  }
101  } else {
102  // Just copy the domain
103  ViewRanges<IntView> yr(y);
104  RangeList::overwrite(home,dom,yr);
105  }
106  }
107 
108  forceinline void
111  RangeList::copy(home,dom,yr);
112  }
113 
114  forceinline unsigned long long int
116  return x.width()-1;
117  }
118 
119 
120 }}
121 
122 // STATISTICS: int-trace
NNF * l
Left subtree.
Definition: bool-expr.cpp:240
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:141
Range iterator for range lists
int min(void) const
Return minimum.
Definition: range-list.hpp:164
Range iterator for integer variable views
Definition: int.hpp:246
#define forceinline
Definition: config.hpp:185
Computation spaces.
Definition: core.hpp:1701
Gecode::IntSet d(v, 7)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
int max(void) const
Return maximum.
Definition: range-list.hpp:168
static unsigned long long int slack(IntView x)
Return slack measure.
Duplicate of an integer view.
int min(void) const
Return minimum of domain.
Definition: int.hpp:58
bool range(void) const
Test whether domain is a range.
Definition: int.hpp:103
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition: int.hpp:85
static void copy(Space &home, RangeList *&r, Iter &i)
Create rangelist r from range iterator i.
Definition: range-list.hpp:215
Integer view for integer variables.
Definition: view.hpp:129
bool any(const Delta &d) const
Test whether arbitrary values got pruned.
Definition: int.hpp:230
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
Generic domain change information to be supplied to advisors.
Definition: core.hpp:203
void prune(Space &home, IntView y, const Delta &d)
Update duplicated view from view y and modification delta d.
void update(Space &home, IntTraceView x)
Update during cloning.
IntTraceView(void)
Default constructor (initializes with no view)
Post propagator for SetVar x
Definition: set.hh:767
void dispose(Space &home, RangeList *l)
Free memory for all elements between this and l (inclusive)
Definition: range-list.hpp:201
Lists of ranges (intervals)
Definition: range-list.hpp:49
static void overwrite(Space &home, RangeList *&r, Iter &i)
Overwrite rangelist r with ranges from range iterator i.
Definition: range-list.hpp:228
Gecode toplevel namespace
int max(void) const
Return maximum of domain.
Definition: int.hpp:62