Generated on Wed Jan 1 2020 10:37:59 for Gecode by doxygen 1.8.16
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/float.hh>
36 
37 namespace Gecode {
38 
39  StdFloatTracer::StdFloatTracer(std::ostream& os0)
40  : os(os0) {}
41 
42  void
44  os << "trace<Float>::init(id:" << t.id();
45  if (t.group().in())
46  os << ",g:" << t.group().id();
47  os << ") slack: 100.00% (" << t.slack().initial() << " width)"
48  << std::endl;
49  }
50 
51  void
53  const ViewTraceInfo& vti, int i, FloatTraceDelta& d) {
54  os << "trace<Float>::prune(id:" << t.id();
55  if (t.group().in())
56  os << ",g:" << t.group().id();
57  os << "): [" << i << "] = " << t[i] << " - ["
58  << d.min() << ".." << d.max()
59  << "] by " << vti << std::endl;
60  }
61 
62  void
64  os << "trace<Float>::fix(id:" << t.id();
65  if (t.group().in())
66  os << ",g:" << t.group().id();
67  os << ") slack: ";
68  double sl_i = static_cast<double>(t.slack().initial());
69  double sl_p = static_cast<double>(t.slack().previous());
70  double sl_c = static_cast<double>(t.slack().current());
71  double p_c = 100.0 * (sl_c / sl_i);
72  double p_d = 100.0 * (sl_p / sl_i) - p_c;
73  os << std::showpoint << std::setprecision(4)
74  << p_c << "% - "
75  << std::showpoint << std::setprecision(4)
76  << p_d << '%'
77  << std::endl;
78  }
79 
80  void
82  os << "trace<Float>::fail(id:" << t.id();
83  if (t.group().in())
84  os << ",g:" << t.group().id();
85  os << ") slack: ";
86  double sl_i = static_cast<double>(t.slack().initial());
87  double sl_p = static_cast<double>(t.slack().previous());
88  double sl_c = static_cast<double>(t.slack().current());
89  double p_c = 100.0 * (sl_c / sl_i);
90  double p_d = 100.0 * (sl_p / sl_i) - p_c;
91  os << std::showpoint << std::setprecision(4)
92  << p_c << "% - "
93  << std::showpoint << std::setprecision(4)
94  << p_d << '%'
95  << std::endl;
96  }
97 
98  void
100  os << "trace<Float>::done(id:" << t.id();
101  if (t.group().in())
102  os << ",g:" << t.group().id();
103  os << ") slack: ";
104  double sl_i = static_cast<double>(t.slack().initial());
105  double sl_p = static_cast<double>(t.slack().previous());
106  double sl_c = static_cast<double>(t.slack().current());
107  double p_c = 100.0 * (sl_c / sl_i);
108  double p_d = 100.0 * (sl_p / sl_i) - p_c;
109  os << std::showpoint << std::setprecision(4)
110  << p_c << "% - "
111  << std::showpoint << std::setprecision(4)
112  << p_d << '%'
113  << std::endl;
114  }
115 
116  StdFloatTracer StdFloatTracer::def;
117 
118 }
119 
120 // STATISTICS: float-trace
int min(int i) const
Return minimum of range at position i.
Definition: int-set-1.hpp:152
int max(int i) const
Return maximum of range at position i.
Definition: int-set-1.hpp:158
Print that trace recorder is virtual done void done(const Space &home, const FloatTraceRecorder &t)
Definition: tracer.cpp:99
Print prune virtual information void prune(const Space &home, const FloatTraceRecorder &t, const ViewTraceInfo &vti, int i, FloatTraceDelta &d)
Definition: tracer.cpp:52
NodeType t
Type of node.
Definition: bool-expr.cpp:230
Computation spaces.
Definition: core.hpp:1742
Standard float variable tracer.
Definition: float.hh:2094
Print failure virtual information void fail(const Space &home, const FloatTraceRecorder &t)
Definition: tracer.cpp:81
Output stream to use std::ostream & os
Definition: float.hh:2097
Gecode toplevel namespace
Initialize with output stream a os0 StdFloatTracer(std::ostream &os0=std::cerr)
Definition: tracer.cpp:39
Propagator for recording view trace information.
Definition: recorder.hpp:60
Gecode::IntSet d(v, 7)
Print fixpoint virtual information void fix(const Space &home, const FloatTraceRecorder &t)
Definition: tracer.cpp:63
View trace information.
Definition: core.hpp:908
Print init virtual information void init(const Space &home, const FloatTraceRecorder &t)
Definition: tracer.cpp:43
Gecode::IntArgs i({1, 2, 3, 4})
Trace delta information for float variables.
Definition: float.hh:2049