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 #ifndef G4SimplexDownhill
00041 #define G4SimplexDownhill_h
00042
00043 #include "globals.hh"
00044
00045 #include <vector>
00046 #include <algorithm>
00047
00048 template<class T>
00049 class G4SimplexDownhill
00050 {
00051
00052 public:
00053
00054 G4SimplexDownhill( T* tp , G4int n )
00055 : currentValue(0.), target(tp), numberOfVariable(n)
00056 { init(); }
00057
00058 ~G4SimplexDownhill();
00059
00060 G4double GetMinimum();
00061
00062 std::vector< G4double > GetMinimumPoint();
00063
00064
00065 private:
00066
00067 G4double getValue( std::vector< G4double > x )
00068 { return target->GetValueOfMinimizingFunction( x ); }
00069
00070 void initialize();
00071 std::vector< std::vector< G4double > > currentSimplex;
00072
00073 void calHeights();
00074 std::vector< G4double > currentHeights;
00075 G4double currentValue;
00076
00077 std::vector< G4double > calCentroid( G4int );
00078
00079 G4bool isItGoodEnough();
00080
00081 std::vector< G4double > getReflectionPoint( std::vector< G4double > ,
00082 std::vector< G4double > );
00083 std::vector< G4double > getExpansionPoint( std::vector< G4double > ,
00084 std::vector< G4double > );
00085 std::vector< G4double > getContractionPoint( std::vector< G4double > ,
00086 std::vector< G4double > );
00087
00088 void doDownhill();
00089
00090 void init();
00091
00092 private:
00093
00094 T* target;
00095
00096 G4int numberOfVariable;
00097
00098 G4double alpha;
00099 G4double beta;
00100 G4double gamma;
00101 G4double max_se;
00102 G4double max_ratio;
00103 G4int maximum_no_trial;
00104 G4bool minimized;
00105
00106 std::vector< G4double > minimumPoint;
00107 };
00108
00109 #include "G4SimplexDownhill.icc"
00110
00111 #endif