Generated on Tue Jan 26 2021 00:00:00 for Gecode by doxygen 1.9.1
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  * 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 #include <iomanip>
35 #include <gecode/set.hh>
36 
37 namespace Gecode {
38 
39  StdSetTracer::StdSetTracer(std::ostream& os0)
40  : os(os0) {}
41 
42  void
44  os << "trace<Set>::init(id:" << t.id();
45  if (t.group().in())
46  os << ",g:" << t.group().id();
47  os << ") slack: 100.00% (" << t.slack().initial() << " values)"
48  << std::endl;
49  }
50 
51  void
53  const ViewTraceInfo& vti, int i, SetTraceDelta& d) {
54  os << "trace<Set>::prune(id:" << t.id();
55  if (t.group().in())
56  os << ",g:" << t.group().id();
57  os << "): [" << i << "] = " << t[i] << " + {";
58  {
59  SetTraceDelta::Glb glb(d.glb());
60  if (glb()) {
61  os << glb.min() << ".." << glb.max();
62  ++glb;
63  while (glb()) {
64  os << "," << glb.min() << ".." << glb.max();
65  ++glb;
66  }
67  }
68  }
69  os << "} - {";
70  {
71  SetTraceDelta::Lub lub(d.lub());
72  if (lub()) {
73  os << lub.min() << ".." << lub.max();
74  ++lub;
75  while (lub()) {
76  os << "," << lub.min() << ".." << lub.max();
77  ++lub;
78  }
79  }
80  }
81  os << "} by " << vti << std::endl;
82  }
83 
84  void
86  os << "trace<Set>::fix(id:" << t.id();
87  if (t.group().in())
88  os << ",g:" << t.group().id();
89  os << ") slack: ";
90  double sl_i = static_cast<double>(t.slack().initial());
91  double sl_p = static_cast<double>(t.slack().previous());
92  double sl_c = static_cast<double>(t.slack().current());
93  double p_c = 100.0 * (sl_c / sl_i);
94  double p_d = 100.0 * (sl_p / sl_i) - p_c;
95  os << std::showpoint << std::setprecision(4)
96  << p_c << "% - "
97  << std::showpoint << std::setprecision(4)
98  << p_d << '%'
99  << std::endl;
100  }
101 
102  void
104  os << "trace<Set>::fail(id:" << t.id();
105  if (t.group().in())
106  os << ",g:" << t.group().id();
107  os << ") slack: ";
108  double sl_i = static_cast<double>(t.slack().initial());
109  double sl_p = static_cast<double>(t.slack().previous());
110  double sl_c = static_cast<double>(t.slack().current());
111  double p_c = 100.0 * (sl_c / sl_i);
112  double p_d = 100.0 * (sl_p / sl_i) - p_c;
113  os << std::showpoint << std::setprecision(4)
114  << p_c << "% - "
115  << std::showpoint << std::setprecision(4)
116  << p_d << '%'
117  << std::endl;
118  }
119 
120  void
122  os << "trace<Set>::done(id:" << t.id();
123  if (t.group().in())
124  os << ",g:" << t.group().id();
125  os << ") slack: 0%" << std::endl;
126  }
127 
129 
130 }
131 
132 // STATISTICS: set-trace
NodeType t
Type of node.
Definition: bool-expr.cpp:230
int min(void) const
Return smallest value of range.
int max(void) const
Return largest value of range.
Delta for the greatest lower bound.
Definition: set.hh:1755
Delta for the least upper bound.
Definition: set.hh:1772
Trace delta information for set variables.
Definition: set.hh:1748
Computation spaces.
Definition: core.hpp:1742
Standard set variable tracer.
Definition: set.hh:1823
virtual void done(const Space &home, const SetTraceRecorder &t)
Print that trace recorder is done.
Definition: tracer.cpp:121
virtual void init(const Space &home, const SetTraceRecorder &t)
Print init information.
Definition: tracer.cpp:43
StdSetTracer(std::ostream &os0=std::cerr)
Initialize with output stream os0.
Definition: tracer.cpp:39
virtual void fail(const Space &home, const SetTraceRecorder &t)
Print failure information.
Definition: tracer.cpp:103
virtual void prune(const Space &home, const SetTraceRecorder &t, const ViewTraceInfo &vti, int i, SetTraceDelta &d)
Print prune information.
Definition: tracer.cpp:52
virtual void fix(const Space &home, const SetTraceRecorder &t)
Print fixpoint information.
Definition: tracer.cpp:85
std::ostream & os
Output stream to use.
Definition: set.hh:1826
static StdSetTracer def
Default tracer (printing to std::cerr)
Definition: set.hh:1842
View trace information.
Definition: core.hpp:908
Propagator for recording view trace information.
Definition: recorder.hpp:60
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::IntSet d(v, 7)