All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
openmidending-stat.cc
Go to the documentation of this file.
1 /* show-eval.cc
2  */
5 #include "osl/record/csaRecord.h"
7 #include "osl/stat/variance.h"
8 #include "osl/oslConfig.h"
9 #include <iostream>
10 #include <iomanip>
11 #include <cstdlib>
12 #include <cstdio>
13 #include <unistd.h>
14 
15 using namespace osl;
16 using namespace osl::eval;
17 
18 void usage(const char *prog)
19 {
20  using namespace std;
21  cerr << "Usage: " << prog << " csa-filename"
22  << endl;
23  exit(1);
24 }
25 
26 void show(const char *filename);
27 void finish();
28 
29 int main(int argc, char **argv)
30 {
31  const char *program_name = argv[0];
32  bool error_flag = false;
33 
34  extern int optind;
35  char c;
36  while ((c = getopt(argc, argv, "e:vh")) != EOF)
37  {
38  switch(c)
39  {
40  default: error_flag = true;
41  }
42  }
43  argc -= optind;
44  argv += optind;
45 
46  if (error_flag)
47  usage(program_name);
48 
51 
52  for (int i=0; i<argc; ++i)
53  {
54  show(argv[i]);
55  }
56  finish();
57 }
58 
59 using namespace osl::eval::ml;
61 CArray<CArray<Variance,4>, OpenMidEndingEvalDebugInfo::STAGE_FEATURE_LIMIT>
63 CArray<Variance, OpenMidEndingEvalDebugInfo::PROGRESS_INDEPENDENT_FEATURE_LIMIT>
65 
66 void show(const NumEffectState& state)
67 {
68  OpenMidEndingEval eval(state);
69  const OpenMidEndingEvalDebugInfo info = eval.debugInfo(state);
70  for (int i=0; i<OpenMidEndingEvalDebugInfo::STAGE_FEATURE_LIMIT; ++i)
71  for (int s=0; s<4; ++s)
72  stage_features[i][s].add(info.stage_values[i][s]);
73  for (int i=0; i<OpenMidEndingEvalDebugInfo::PROGRESS_INDEPENDENT_FEATURE_LIMIT; ++i)
75 
76 void finish()
77 {
78  for (int i=0; i<OpenMidEndingEvalDebugInfo::STAGE_FEATURE_LIMIT; ++i)
79  for (int s=0; s<4; ++s)
80  std::cout << OpenMidEndingEvalDebugInfo::name((OpenMidEndingEvalDebugInfo::StageFeature)i)
81  << s
82  << " " << stage_features[i][s].getAverage()
83  << " " << sqrt(stage_features[i][s].variance()) << "\n";
84  for (int i=0; i<OpenMidEndingEvalDebugInfo::PROGRESS_INDEPENDENT_FEATURE_LIMIT; ++i)
85  std::cout << OpenMidEndingEvalDebugInfo::name((OpenMidEndingEvalDebugInfo::ProgressIndependentFeature)i)
86  << " " << progress_independent_features[i].getAverage()
87  << " " << sqrt(progress_independent_features[i].variance()) << "\n";
88 }
89 
90 void show(const char *filename)
91 {
92  CsaFile file(filename);
93  const vector<osl::Move> moves = file.getRecord().getMoves();
94  NumEffectState state(file.getInitialState());
95  for (unsigned int i=0; i<moves.size(); i++)
96  {
97  show(state);
98  const Move m = moves[i];
99  state.makeMove(m);
100  }
101  show(state);
102 }
103 
104 /* ------------------------------------------------------------------------- */
105 // ;;; Local Variables:
106 // ;;; mode:c++
107 // ;;; c-basic-offset:2
108 // ;;; End: