Generated on Tue Jan 28 2020 00:00:00 for Gecode by doxygen 1.8.17
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: 2017-03-17 23:04:57 +0100 (Fri, 17 Mar 2017) $ by $Author: schulte $
11  * $Revision: 15597 $
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/float.hh>
40 
41 namespace Gecode {
42 
43  StdFloatTracer::StdFloatTracer(std::ostream& os0)
44  : os(os0) {}
45 
46  void
48  os << "trace<Float>::init(id:" << t.id();
49  if (t.group().in())
50  os << ",g:";t.group().id();
51  os << ") slack: 100.00% (" << t.slack().initial() << " width)"
52  << std::endl;
53  }
54 
55  void
57  const ViewTraceInfo& vti, int i, FloatTraceDelta& d) {
58  os << "trace<Float>::prune(id:" << t.id();
59  if (t.group().in())
60  os << ",g:";t.group().id();
61  os << "): [" << i << "] = " << t[i] << " - ["
62  << d.min() << ".." << d.max()
63  << "] by " << vti << std::endl;
64  }
65 
66  void
68  os << "trace<Float>::fix(id:" << t.id();
69  if (t.group().in())
70  os << ",g:";t.group().id();
71  os << ") slack: ";
72  double sl_i = static_cast<double>(t.slack().initial());
73  double sl_p = static_cast<double>(t.slack().previous());
74  double sl_c = static_cast<double>(t.slack().current());
75  double p_c = 100.0 * (sl_c / sl_i);
76  double p_d = 100.0 * (sl_p / sl_i) - p_c;
77  os << std::showpoint << std::setprecision(4)
78  << p_c << "% - "
79  << std::showpoint << std::setprecision(4)
80  << p_d << '%'
81  << std::endl;
82  }
83 
84  void
86  os << "trace<Float>::fail(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<Float>::done(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  StdFloatTracer StdFloatTracer::def;
121 
122 }
123 
124 // STATISTICS: float-trace
int min(int i) const
Return minimum of range at position i.
Definition: int-set-1.hpp:115
int max(int i) const
Return maximum of range at position i.
Definition: int-set-1.hpp:121
Print that trace recorder is virtual done void done(const Space &home, const FloatTraceRecorder &t)
Definition: tracer.cpp:103
Print prune virtual information void prune(const Space &home, const FloatTraceRecorder &t, const ViewTraceInfo &vti, int i, FloatTraceDelta &d)
Definition: tracer.cpp:56
Gecode::IntArgs i(4, 1, 2, 3, 4)
NodeType t
Type of node.
Definition: bool-expr.cpp:234
Computation spaces.
Definition: core.hpp:1748
Standard float variable tracer.
Definition: float.hh:1996
Print failure virtual information void fail(const Space &home, const FloatTraceRecorder &t)
Definition: tracer.cpp:85
Output stream to use std::ostream & os
Definition: float.hh:1999
Gecode toplevel namespace
Initialize with output stream a os0 StdFloatTracer(std::ostream &os0=std::cerr)
Definition: tracer.cpp:43
Propagator for recording view trace information.
Gecode::IntSet d(v, 7)
Print fixpoint virtual information void fix(const Space &home, const FloatTraceRecorder &t)
Definition: tracer.cpp:67
View trace information.
Definition: core.hpp:974
Print init virtual information void init(const Space &home, const FloatTraceRecorder &t)
Definition: tracer.cpp:47
Trace delta information for float variables.
Definition: float.hh:1951