#include <G4SimplexDownhill.hh>
Public Member Functions | |
G4SimplexDownhill (T *tp, G4int n) | |
~G4SimplexDownhill () | |
G4double | GetMinimum () |
std::vector< G4double > | GetMinimumPoint () |
Definition at line 49 of file G4SimplexDownhill.hh.
G4SimplexDownhill< T >::G4SimplexDownhill | ( | T * | tp, | |
G4int | n | |||
) | [inline] |
Definition at line 54 of file G4SimplexDownhill.hh.
00055 : currentValue(0.), target(tp), numberOfVariable(n) 00056 { init(); }
G4SimplexDownhill< T >::~G4SimplexDownhill | ( | ) |
G4double G4SimplexDownhill< T >::GetMinimum | ( | ) |
Definition at line 64 of file G4SimplexDownhill.icc.
Referenced by G4SimplexDownhill< T >::GetMinimumPoint().
00065 { 00066 00067 initialize(); 00068 00069 // First Tryal; 00070 00071 //G4cout << "Begin First Trials" << G4endl; 00072 doDownhill(); 00073 //G4cout << "End First Trials" << G4endl; 00074 00075 std::vector< G4double >::iterator it_minh = 00076 std::min_element( currentHeights.begin() , currentHeights.end() ); 00077 G4int imin = -1; 00078 G4int i = 0; 00079 for ( std::vector< G4double >::iterator it = currentHeights.begin(); 00080 it != currentHeights.end(); it++ ) 00081 { 00082 if ( it == it_minh ) 00083 { 00084 imin = i; 00085 } 00086 i++; 00087 } 00088 minimumPoint = currentSimplex[ imin ]; 00089 00090 // Second Trial 00091 00092 //std::vector< G4double > minimumPoint = currentSimplex[ 0 ]; 00093 initialize(); 00094 00095 currentSimplex[ numberOfVariable ] = minimumPoint; 00096 00097 //G4cout << "Begin Second Trials" << G4endl; 00098 doDownhill(); 00099 //G4cout << "End Second Trials" << G4endl; 00100 00101 G4double sum = std::accumulate( currentHeights.begin() , 00102 currentHeights.end() , 0.0 ); 00103 G4double average = sum/(numberOfVariable+1); 00104 G4double minimum = average; 00105 00106 minimized = true; 00107 00108 return minimum; 00109 00110 }
std::vector< G4double > G4SimplexDownhill< T >::GetMinimumPoint | ( | ) |
Definition at line 419 of file G4SimplexDownhill.icc.
References G4SimplexDownhill< T >::GetMinimum().
00420 { 00421 if ( minimized != true ) 00422 { 00423 GetMinimum(); 00424 } 00425 00426 std::vector< G4double >::iterator it_minh = 00427 std::min_element( currentHeights.begin() , currentHeights.end() );; 00428 G4int imin = -1; 00429 G4int i = 0; 00430 for ( std::vector< G4double >::iterator 00431 it = currentHeights.begin(); it != currentHeights.end(); it++ ) 00432 { 00433 if ( it == it_minh ) 00434 { 00435 imin = i; 00436 } 00437 i++; 00438 } 00439 minimumPoint = currentSimplex[ imin ]; 00440 00441 return minimumPoint; 00442 }