00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef G4ConvergenceTester
00048 #define G4ConvergenceTester_h 1
00049
00050 #include "G4SimplexDownhill.hh"
00051
00052 #include "G4Timer.hh"
00053 #include "globals.hh"
00054
00055 #include <map>
00056 #include <vector>
00057
00058 class G4ConvergenceTester
00059 {
00060 public:
00061
00062 G4ConvergenceTester();
00063 ~G4ConvergenceTester();
00064 G4ConvergenceTester( G4double );
00065
00066 public:
00067
00068 void AddScore( G4double );
00069
00070
00071 void ShowHistory(std::ostream& out = G4cout);
00072 void ShowResult(std::ostream& out = G4cout);
00073
00074 inline G4double GetValueOfMinimizingFunction( std::vector<G4double> x )
00075 { return slope_fitting_function( x ); }
00076
00077 private:
00078
00079 void calStat();
00080
00081
00082
00083
00084 void CheckIsUpdated() { if(!statsAreUpdated) { calStat(); } }
00085
00086 public:
00087
00088 void ComputeStatistics() { calStat(); }
00089
00090
00091 G4double GetMean() { CheckIsUpdated(); return mean; }
00092 G4double GetStandardDeviation() { CheckIsUpdated(); return sd; }
00093 G4double GetVariance() { CheckIsUpdated(); return var; }
00094 G4double GetR() { CheckIsUpdated(); return r; }
00095 G4double GetEfficiency() { CheckIsUpdated(); return efficiency; }
00096 G4double GetR2eff() { CheckIsUpdated(); return r2eff; }
00097 G4double GetR2int() { CheckIsUpdated(); return r2int; }
00098 G4double GetShift() { CheckIsUpdated(); return shift; }
00099 G4double GetVOV() { CheckIsUpdated(); return vov; }
00100 G4double GetFOM() { CheckIsUpdated(); return fom; }
00101
00102 private:
00103 void calc_grid_point_of_history();
00104 void calc_stat_history();
00105 void check_stat_history(std::ostream& out = G4cout);
00106 G4double calc_Pearson_r( G4int, std::vector<G4double>,
00107 std::vector<G4double> );
00108 G4bool is_monotonically_decrease( std::vector<G4double> );
00109 void calc_slope_fit( std::vector< G4double > );
00110 G4double slope_fitting_function( std::vector< G4double > );
00111
00112 private:
00113
00114 std::map< G4int , G4double > nonzero_histories;
00115
00116 G4int n;
00117
00118 G4double sum;
00119
00120 G4Timer* timer;
00121 std::vector<G4double> cpu_time;
00122
00123 G4double mean;
00124 G4double var;
00125 G4double sd;
00126 G4double r;
00127 G4double efficiency;
00128 G4double r2eff;
00129 G4double r2int;
00130 G4double shift;
00131 G4double vov;
00132 G4double fom;
00133
00134 G4double largest;
00135 G4int largest_score_happened;
00136
00137 G4double mean_1;
00138 G4double var_1;
00139 G4double sd_1;
00140 G4double r_1;
00141 G4double shift_1;
00142 G4double vov_1;
00143 G4double fom_1;
00144
00145 G4int noBinOfHistory;
00146 std::vector< G4int > history_grid;
00147 std::vector< G4double > mean_history;
00148 std::vector< G4double > var_history;
00149 std::vector< G4double > sd_history;
00150 std::vector< G4double > r_history;
00151 std::vector< G4double > vov_history;
00152 std::vector< G4double > fom_history;
00153 std::vector< G4double > shift_history;
00154 std::vector< G4double > e_history;
00155 std::vector< G4double > r2eff_history;
00156 std::vector< G4double > r2int_history;
00157
00158 G4double slope;
00159 std::vector< G4double > largest_scores;
00160 std::vector< G4double > f_xi;
00161 std::vector< G4double > f_yi;
00162 G4int noBinOfPDF;
00163 G4SimplexDownhill<G4ConvergenceTester>* minimizer;
00164
00165 G4int noPass;
00166 G4int noTotal;
00167
00168 G4bool statsAreUpdated;
00169 };
00170 #endif
00171