Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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
37namespace Gecode {
38
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
117
118}
119
120// STATISTICS: float-trace
NodeType t
Type of node.
Trace delta information for float variables.
Definition float.hh:2049
int min(int i) const
Return minimum of range at position i.
int max(int i) const
Return maximum of range at position i.
Computation spaces.
Definition core.hpp:1742
Standard float variable tracer.
Definition float.hh:2094
static StdFloatTracer def
Default tracer (printing to std::cerr)
Definition float.hh:2113
StdFloatTracer(std::ostream &os0=std::cerr)
Initialize with output stream os0.
Definition tracer.cpp:39
virtual void fail(const Space &home, const FloatTraceRecorder &t)
Print failure information.
Definition tracer.cpp:81
virtual void fix(const Space &home, const FloatTraceRecorder &t)
Print fixpoint information.
Definition tracer.cpp:63
std::ostream & os
Output stream to use.
Definition float.hh:2097
virtual void done(const Space &home, const FloatTraceRecorder &t)
Print that trace recorder is done.
Definition tracer.cpp:99
virtual void prune(const Space &home, const FloatTraceRecorder &t, const ViewTraceInfo &vti, int i, FloatTraceDelta &d)
Print prune information.
Definition tracer.cpp:52
virtual void init(const Space &home, const FloatTraceRecorder &t)
Print init information.
Definition tracer.cpp:43
View trace information.
Definition core.hpp:908
Propagator for recording view trace information.
Definition tracer.hpp:44
Gecode toplevel namespace