Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
metric.h
Go to the documentation of this file.
1 #ifndef _METRIC_H_
2 #define _METRIC_H_
3 
4 #include <cstdio>
5 #include <cstdlib>
6 #include <iostream>
7 #include <ostream>
8 #include <fstream>
9 #include <string>
10 #include <time.h>
11 #include <sstream>
12 #include <iomanip>
13 #include <math.h>
14 
15 #include "CImg.h"
16 #include "file.h"
17 #include "points.h"
18 #include "datatypedef.h"
19 #include "tecplotwriter.h"
20 
21 #include "colormaps.h"
22 
23 #include "BoundingBox.hpp"
24 
25 using namespace cimg_library;
26 using std::cout;
27 using std::cerr;
28 using std::endl;
29 
30 
31 
32 /*
33  * Base class for metrics
34  */
35 class metric {
36 
37  public:
38 
39  metric(std::vector<points*> datasets1, std::vector<points*> datasets2,
40  int var_ds1, int var_ds2,
41  ofstream &outfile, string outprefix);
42 
43  void set_datasets1(std::vector<points*> datasets1);
44  void set_datasets2(std::vector<points*> datasets2);
45 
46  inline void setRange( BoundingBox *rangePtr )
47  {
48 
49  if( rangePtr != NULL )
50  {
51  this ->restrictToBoxRange = true;
52  this ->range = rangePtr;
53  }
54 
55  }
56 
57  virtual string get_res();
58 
59  virtual string get_metric_name();
60 
61  protected:
62 
65 
66  string outprefix;
67 
68  std::vector<points*> datasets1;
69  std::vector<points*> datasets2;
70 
71  int var_ds1;
72  int var_ds2;
73 
74  ofstream &outfile;
75 
76  void error_out(string err_ps);
77 
78 };
79 
80 
81 
82 /* Mean square error
83  *
84  *
85  *//*
86 class mse : public metric {
87 
88  public:
89 
90  mse(std::vector<points*> datasets1, std::vector<points*> datasets2,
91  int var_ds1, int var_ds2,
92  ofstream &outfile, string outprefix);
93 
94  string get_metric_name();
95 
96  string get_res();
97 
98  private:
99 
100  long double compare();
101 
102  //Make sure the files have the same number of elements
103  bool check_card_match();
104 
105 };
106 */
107 
108 
109 /* Root mean square error
110  *
111  *
112  *//*
113 class rmse : public metric {
114 
115  public:
116 
117  rmse(std::vector<points*> datasets1, points *dataset2, int var_ds1, int var_ds2,
118  ofstream &outfile, string outprefix);
119 
120  string get_res();
121 
122  string get_metric_name();
123 
124  private:
125 
126  long double compare();
127 
128  //Make sure the files have the same number of elements
129  bool check_card_match();
130 
131 };
132 */
133 
134 
135 /* Simple Cross-correlation / Template Matching
136  *
137  *
138  *//*
139 class scc : public metric {
140 
141  public:
142 
143  scc(std::vector<points*> datasets1, points *dataset2,
144  int var_ds1, int var_ds2,
145  ofstream &outfile, string outprefix);
146 
147  string get_res();
148 
149  string get_metric_name();
150 
151  private:
152 
153  long double compare();
154 
155  //Make sure the files have the same number of elements
156  bool check_card_match();
157 
158 };
159 */
160 
161 
162 /* map Base Class
163  *
164  *
165  *//*
166 class map : public metric {
167 
168  public:
169 
170  map(std::vector<points*> datasets1, points *dataset2,
171  int var_ds1, int var_ds2,
172  ofstream &outfile, string outprefix);
173 
174  protected:
175 
176  //For datasets that have a definite start point
177  //ie. 0 -> inf
178  rgb_color get_color_single_sided(long double pt_val, long double range, long double min);
179 
180  //For datasets that have a definite midpoint
181  //ie. -inf <- 0 -> inf
182  rgb_color get_color_double_sided(long double pt_val, long double range, long double min,
183  long double mid_point);
184 };
185 */
186 
187 
188 /* Difference Map
189  *
190  *
191  *//*
192 class difmap : public map {
193 
194  public:
195 
196  difmap(std::vector<indexed_points*> datasets1, indexed_points *dataset2, int var_ds1, int var_ds2,
197  ofstream &outfile, string outprefix);
198 
199  string get_res();
200 
201  virtual string get_metric_name();
202 
203  protected:
204 
205  virtual string compare();
206 
207  //Make sure the files have the same number of elements
208  bool check_card_match();
209 
210  long double get_max_value(int ds);
211 
212  long double get_min_value(int ds);
213 
214  long double get_max_dif();
215 
216  long double get_min_dif();
217 
218  void output_info(string filename, long double max, long double min, int large_ds);
219 };
220 */
221 
222 /*
223 class difmap_wkey : public difmap {
224 
225  public:
226 
227  difmap_wkey(std::vector<indexed_points*> datasets1, indexed_points *dataset2, int var_ds1, int var_ds2,
228  ofstream &outfile, string outprefix);
229 
230  string get_metric_name();
231 
232  protected:
233 
234  virtual string compare();
235 
236  private:
237 
238  int border_width;
239  int key_width;
240 
241  rgb_color border_color;
242 };
243 */
244 
245 
246 /* Color Map
247  *
248  *
249  *//*
250 class colmap : public map {
251 
252  public:
253 
254  colmap(std::vector<indexed_points*> datasets1, indexed_points *dataset2, int var_ds1, int var_ds2,
255  ofstream &outfile, string outprefix);
256 
257  string get_res();
258 
259  string get_metric_name();
260 
261  private:
262 
263  string compare();
264 
265  long double get_max_value(int ds, int var);
266 
267  long double get_min_value(int ds, int var);
268 
269 };
270 */
271 
272 
273 /*
277 class scorco : public metric {
278 
279  public:
280 
281  scorco(std::vector<points*> datasets1, points *dataset2, int var_ds1, int var_ds2,
282  ofstream &outfile, string outprefix);
283 
284  string get_res();
285 
286  string get_metric_name();
287 
288  private:
289 
290  long double compare();
291 *//*
296  long double get_average_f1();
297 *//*
302  long double get_average_f2();
303 */
304  //Make sure the files have the same number of elements
305 /* bool check_card_match();
306 
307 };
308 */
309 
310 /*
314 class modef : public metric {
315 
316  public:
317 
318  modef(std::vector<points*> datasets1, points *dataset2, int var_ds1, int var_ds2,
319  ofstream &outfile, string outprefix);
320 
321  string get_res();
322 
323  string get_metric_name();
324 
325  private:
326 
327  long double compare();
328 
329  long double get_average_f1();
330  long double get_average_f2();
331 
332  //Make sure the files have the same number of elements
333  bool check_card_match();
334 
335 };
336 */
337 
338 
339 /*
340  * Metric Selection
341  */
342 
343 //List metrics
344 void print_metrics();
345 
346 //Select metric from switch
347 metric *metric_select(int m, std::vector<points*> dss1, std::vector<points*> dss2,
348  int var_ds1, int var_ds2,
349  ofstream &outfile, string outprefix);
350 
351 
352 
353 /* HOW TO Write your own metric
354  *
355  * 1. Create a derived class from the "metric" class
356  * 2. Write compare() function to do the comparison work
357  * 3. Write a get_metric_name() function that returns the name of your metric
358  * 4. Add your function to
359  * - print_metrics()
360  * - metric_select()
361  */
362 
363 
364 
365 #endif
A concrete object that provides the functionality for representing a bounding box geometric primitive...
Definition: BoundingBox.hpp:21
void setRange(BoundingBox *rangePtr)
Definition: metric.h:46
std::vector< points * > datasets1
Definition: metric.h:68
void print_metrics()
Sample Correlation Coefficient.
Definition: metric.cpp:1161
int var_ds2
Definition: metric.h:72
int var_ds1
Definition: metric.h:71
bool restrictToBoxRange
Definition: metric.h:63
metric * metric_select(int m, std::vector< points * > dss1, std::vector< points * > dss2, int var_ds1, int var_ds2, ofstream &outfile, string outprefix)
Definition: metric.cpp:1194
BoundingBox * range
Definition: metric.h:64
string outprefix
Definition: metric.h:66
ofstream & outfile
Definition: metric.h:74
std::vector< points * > datasets2
Definition: metric.h:69
Definition: metric.h:35