Fixed text file permissions
[snark14.git] / tools / Display / eval_helper.hpp
1 /** @file eval_helper.hpp
2     @package snark14Display
3     @author Bruno M. Carvalho and Deniz Sarioz
4     licensed under (open-source) QPL v1.0
5     which accompanies this distribution in the file QPL
6 */
7
8 /** @name eval_helper.hpp
9     @type C++ header file
10     @date April 2004
11     @package snark14Display
12     @see eval_helper.cpp
13 */
14
15 #ifndef _EVAL_HELPER_HPP 
16 #define _EVAL_HELPER_HPP
17
18 #include <qwidget.h>
19 #include "verbosity.hpp"
20 #include <exception>
21 #include <stdexcept>
22 #include <cstdio>
23 #include <iostream>
24 #include <deque>
25 #include <vector>
26
27 #include "line_real_set_t.hpp"
28
29
30 enum globalYVar_t { AVERAGE, DISTANCE, RELERR, VARIANCE, STDDEV, RESIDUAL, KULLBACK };
31
32 typedef char* measline_t; // these types are potentially used everywhere
33 typedef char* execname_t;
34
35 class phantomeas;        // forward declaration of classes used by eval_execution_set
36 class eval_execution;
37
38 /** "public interface"-like class definition of eval_execution_set: 
39  *    superstructure capable of holding information 
40  *    from many eval executions, an entire eval08 file  */
41 class eval_execution_set {
42   std::deque<eval_execution> execs; // entire output of snark14 EVALUATE executions
43   std::vector<bool> selected; // holds which execs are selected by snark14Display user
44   phantomeas* phantomeasp;
45   bool completed; // holds whether creation of execs is complete (is this really necessary here?)
46   bool extrema_calculated; // holds whether extrema are calculated (ditto.)
47   bool selectionHasResidualvar;
48   bool selectionHasKullbackvar;
49   bool same_x_forall;  // for iter, plotted on x-axis
50   bool same_y_forall;  // for whatever it is that is requested for plotting on y-axis
51   // (almost the same as for eval_execution) extrama...
52   // first the global extrema
53   int minIter, maxIter;
54   double minAverage, maxAverage, minDistance, maxDistance, minRelerr, maxRelerr;
55   double minVariance, maxVariance, minStddev, maxStddev, minResidual, maxResidual, minKullback, maxKullback;
56   // then the PBP extrema...
57   std::vector<double> PBP_minima; // minima and maxima of each E(0)..E(N-1), N not varying within an eval file.
58   std::vector<double> PBP_maxima; // to be calculated over ALL EVALUATE calls, depending.
59   unsigned num_Es; // 'N' in comment above
60   // e.g., PBP_minima[2] is the minimum value of all E(2) in all PBPmeasets in all execs.
61 public:
62   // construction
63   eval_execution_set();
64   // cultivation  (call during the eval file reading phase)
65   void new_exec(execname_t line);
66   void new_globmeaset(execname_t line);
67   void add_to_globmeaset(measline_t line);
68   void new_PBPmeaset(execname_t line);
69   void add_to_PBPmeaset(measline_t line);
70   void set_phantomeas(measline_t line);
71   // completion (call to signal transition from cultivation phase to manipulation phase)
72   void complete();
73   // manipulation
74   bool calculate_global_extrema(bool restrict_domain, int min_it_arg, int max_it_arg);
75   bool calculate_global_extrema();
76   bool calculate_PBP_extrema(bool restrict_domain, int min_it_arg, int max_it_arg);
77   bool calculate_PBP_extrema();
78   void deselect_exec(unsigned idx);
79   void select_exec(unsigned idx);
80   void deselect_all_execs();
81   void select_all_execs();
82   void setSameXForAll (bool val = true);
83   void setSameYForAll (bool val = true);
84   void useSameExtremaForAll (bool val = true);
85   void useDifferentExtremaForEach();
86   // information extraction pertaining to entire set
87   unsigned num_eval_execs();
88   bool hasPhantom();
89   bool selectionHasGlobal();
90   bool selectionHasResidual(); // should really be called only after selectionHasGlobal()
91   bool selectionHasKullback();
92   bool selectionHasPBP();
93   unsigned get_num_Es(); // if no PBP, returns 0.  should really be called only after hasPBP()
94   bool getSameXForAll();
95   bool getSameYForAll();
96   int getMinIterViaGlobal();   // by some sleight of theory, 
97   int getMaxIterViaGlobal();  // iterations could be different from global to PBP... 
98   int getMinIterViaPBP();    // I'm taking out insurance.
99   int getMaxIterViaPBP();
100   double getMinYGlobal(globalYVar_t globalYVar);
101   double getMaxYGlobal(globalYVar_t globalYVar);
102   double getMinYPBP(unsigned idx);
103   double getMaxYPBP(unsigned idx);
104   // information extraction pertaining to a single evaluate execution
105   execname_t getExecName(unsigned idx);
106   // reporting to stdout (for debugging)
107   void show_all();
108   void show_selected();
109   void show_extrema();
110   void addPBPVarLines(line_real_set_t& LRS, unsigned PBPYVar, unsigned ee_index);
111   void addGlobVarLines(line_real_set_t& LRS, globalYVar_t globalYVar, unsigned ee_index);
112   void spawnDialogsGlob(QWidget* parent, globalYVar_t globalYVar);
113   void spawnDialogsPBP(QWidget* parent, unsigned PBPYVar);
114   void spawnAllPlotsGlob(QWidget* parent, globalYVar_t globalYVar, int userMinXVal, int userMaxXVal, double userMinYVal, double userMaxYVal, bool isGrayScale);
115   void spawnAllPlotsPBP(QWidget* parent, unsigned PBPYVar, int userMinXVal, int userMaxXVal, double userMinYVal, double userMaxYVal, bool isGrayScale);
116   // two flavors of destruction
117   void clear(); // allows there to be a single, shared variable
118   ~eval_execution_set();
119 }; // --"public interface" (within entire snark14Display) of class eval_execution_set
120 #endif // _EVAL_HELPER_HPP
121 // --eval_helper.hpp