Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
tracer.cpp
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$ by $Author$
11  * $Revision$
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 #include <iomanip>
39 #include <gecode/set.hh>
40 
41 namespace Gecode {
42 
43  StdSetTracer::StdSetTracer(std::ostream& os0)
44  : os(os0) {}
45 
46  void
48  os << "trace<Set>::init(id:" << t.id();
49  if (t.group().in())
50  os << ",g:" << t.group().id();
51  os << ") slack: 100.00% (" << t.slack().initial() << " values)"
52  << std::endl;
53  }
54 
55  void
57  const ViewTraceInfo& vti, int i, SetTraceDelta& d) {
58  os << "trace<Set>::prune(id:" << t.id();
59  if (t.group().in())
60  os << ",g:" << t.group().id();
61  os << "): [" << i << "] = " << t[i] << " + {";
62  {
63  SetTraceDelta::Glb glb(d.glb());
64  if (glb()) {
65  os << glb.min() << ".." << glb.max();
66  ++glb;
67  while (glb()) {
68  os << "," << glb.min() << ".." << glb.max();
69  ++glb;
70  }
71  }
72  }
73  os << "} - {";
74  {
75  SetTraceDelta::Lub lub(d.lub());
76  if (lub()) {
77  os << lub.min() << ".." << lub.max();
78  ++lub;
79  while (lub()) {
80  os << "," << lub.min() << ".." << lub.max();
81  ++lub;
82  }
83  }
84  }
85  os << "} by " << vti << std::endl;
86  }
87 
88  void
90  os << "trace<Set>::fix(id:" << t.id();
91  if (t.group().in())
92  os << ",g:" << t.group().id();
93  os << ") slack: ";
94  double sl_i = static_cast<double>(t.slack().initial());
95  double sl_p = static_cast<double>(t.slack().previous());
96  double sl_c = static_cast<double>(t.slack().current());
97  double p_c = 100.0 * (sl_c / sl_i);
98  double p_d = 100.0 * (sl_p / sl_i) - p_c;
99  os << std::showpoint << std::setprecision(4)
100  << p_c << "% - "
101  << std::showpoint << std::setprecision(4)
102  << p_d << '%'
103  << std::endl;
104  }
105 
106  void
108  os << "trace<Set>::fail(id:" << t.id();
109  if (t.group().in())
110  os << ",g:" << t.group().id();
111  os << ") slack: ";
112  double sl_i = static_cast<double>(t.slack().initial());
113  double sl_p = static_cast<double>(t.slack().previous());
114  double sl_c = static_cast<double>(t.slack().current());
115  double p_c = 100.0 * (sl_c / sl_i);
116  double p_d = 100.0 * (sl_p / sl_i) - p_c;
117  os << std::showpoint << std::setprecision(4)
118  << p_c << "% - "
119  << std::showpoint << std::setprecision(4)
120  << p_d << '%'
121  << std::endl;
122  }
123 
124  void
126  os << "trace<Set>::done(id:" << t.id();
127  if (t.group().in())
128  os << ",g:" << t.group().id();
129  os << ") slack: 0%" << std::endl;
130  }
131 
133 
134 }
135 
136 // STATISTICS: set-trace
NodeType t
Type of node.
Definition: bool-expr.cpp:234
Glb & glb(void)
Give access to iterator for delta in greatest lower bound (values that have been included) ...
Definition: delta.hpp:56
View trace information.
Definition: core.hpp:898
bool in(Group a) const
Check whether actor group a is included in this group.
Definition: core.hpp:4803
StdSetTracer(std::ostream &os0=std::cerr)
Initialize with output stream os0.
Definition: tracer.cpp:43
virtual void fail(const Space &home, const SetTraceRecorder &t)
Print failure information.
Definition: tracer.cpp:107
Standard set variable tracer.
Definition: set.hh:1785
unsigned int id(void) const
Return a unique id for the group.
Definition: core.hpp:4821
Computation spaces.
Definition: core.hpp:1668
Lub & lub(void)
Give access iterator for delta in leat bound (values that have been removed)
Definition: delta.hpp:60
unsigned int id(void) const
Return propagator id.
Definition: core.hpp:3412
Gecode::IntSet d(v, 7)
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual void fix(const Space &home, const SetTraceRecorder &t)
Print fixpoint information.
Definition: tracer.cpp:89
std::ostream & os
Output stream to use.
Definition: set.hh:1788
PropagatorGroup group(void) const
Return group propagator belongs to.
Definition: core.hpp:3417
virtual void prune(const Space &home, const SetTraceRecorder &t, const ViewTraceInfo &vti, int i, SetTraceDelta &d)
Print prune information.
Definition: tracer.cpp:56
SlackValue previous(void) const
Return previous slack value.
Definition: recorder.hpp:227
Trace delta information for set variables.
Definition: set.hh:1710
Propagator for recording view trace information.
Definition: recorder.hpp:63
virtual void done(const Space &home, const SetTraceRecorder &t)
Print that trace recorder is done.
Definition: tracer.cpp:125
virtual void init(const Space &home, const SetTraceRecorder &t)
Print init information.
Definition: tracer.cpp:47
Delta for the least upper bound.
Definition: set.hh:1732
SlackValue current(void) const
Return current slack value.
Definition: recorder.hpp:232
Delta for the greatest lower bound.
Definition: set.hh:1715
Gecode toplevel namespace
const Slack & slack(void) const
Provide access to slack information.
Definition: recorder.hpp:211
SlackValue initial(void) const
Return initial slack value.
Definition: recorder.hpp:222
static StdSetTracer def
Default tracer (printing to std::cerr)
Definition: set.hh:1804