Files Classes Functions Hierarchy
#include <minpatternsearch.h>
Public Member Functions | |
| minpatternsearch (funcstate< X > &fn_, X const h0step=20.0, uintc indexmax_=500, boolc mem_=true) | |
| Allocate the fn with new. | |
| virtual void | reset () |
| Set the current position as the new minimum. | |
| virtual void | operator++ () |
| 1st order approximator to minimum. | |
Public Attributes | |
| funchistory< X > | fh |
| Consecutive X values are stored. | |
Definition at line 10 of file minpatternsearch.h.
| minpatternsearch< X >::minpatternsearch | ( | funcstate< X > & | fn_, | |
| X const | h0step = 20.0, |
|||
| uintc | indexmax_ = 500, |
|||
| boolc | mem_ = true | |||
| ) | [inline] |
Allocate the fn with new.
Definition at line 40 of file minpatternsearch.h.
00046 : minexpdim<X>(fn_,h0step,indexmax_,mem_), 00047 fh(fn_) 00048 { 00049 00050 00051 }
| void minpatternsearch< X >::operator++ | ( | ) | [inline, virtual] |
1st order approximator to minimum.
Reimplemented from minexpdim< X >.
Definition at line 55 of file minpatternsearch.h.
References minpatternsearch< X >::fh, and minexpdim< X >::moveOrder1().
00056 { 00057 //cout << "minpatternsearch<X>::operator ++" << endl; 00058 if (!minexpdim<X>::valid) 00059 return; 00060 00061 if (minexpdim<X>::index > minexpdim<X>::indexmax) 00062 { 00063 minexpdim<X>::valid=false; 00064 return; 00065 } 00066 00067 assert( fh.xik.size() >= 2 ); 00068 00069 uintc dim = minexpdim<X>::fn->dim; 00070 00071 // Algorithm on vectors 00072 // X* = X[k] + (X[k] - X[k-1]) 00073 X* XK0 = fh[0]; 00074 X* XK1 = fh[1]; 00075 00076 //cout << "before pattern move" << endl; 00077 //cout << "fmin=" << minexpdim<X>::fmin << " xi[dim]=" << minexpdim<X>::xi[dim] << endl; 00078 00079 // TODO preserve hi, 00080 // have funcstate hi variable, 00081 // funchistory have hipush, hipop, hidel_back. 00082 // flag for optionally turning on preserving h. 00083 00084 //cout << "fmin=" << minexpdim<X>::fmin << " xi[dim]=" << minexpdim<X>::xi[dim] << endl; 00085 assert(minexpdim<X>::fmin==minexpdim<X>::xi[dim]); 00086 00087 for (uint i=0; i<dim; ++i) 00088 { 00089 minexpdim<X>::xi[i] = XK0[i]*2.0-XK1[i]; 00090 } 00091 // Was the pattern + exploratory move successful 00092 if (minexpdim<X>::moveOrder1()) 00093 { 00094 minexpdim<X>::xi[dim] = minexpdim<X>::fmin; 00095 assert(minexpdim<X>::xi[dim]<XK0[dim]); 00096 fh.del_back(); 00097 fh.push(); 00098 } 00099 else 00100 { 00101 fh.restore(); 00102 //cout << "fmin=" << minexpdim<X>::fmin << " xi[dim]=" << minexpdim<X>::xi[dim] << endl; 00103 assert(minexpdim<X>::fmin==minexpdim<X>::xi[dim]); 00104 00105 bool res=minexpdim<X>::moveOrder1(5); 00106 assert(res); 00107 if (res) 00108 { 00109 minexpdim<X>::xi[dim] = minexpdim<X>::fmin; 00110 fh.del_back(); 00111 fh.push(); 00112 } 00113 } 00114 }
| void minpatternsearch< X >::reset | ( | ) | [inline, virtual] |
Set the current position as the new minimum.
Reimplemented from minexpdim< X >.
Definition at line 117 of file minpatternsearch.h.
References minpatternsearch< X >::fh, and minexpdim< X >::moveOrder1().
Referenced by minexpdimtest::test04().
00118 { 00119 minexpdim<X>::reset(); 00120 00121 static uint maxloop=20; 00122 for (uint j=0; j<2; ++j) 00123 { 00124 minexpdim<X>::moveOrder1(maxloop); 00125 assert(minexpdim<X>::hasminimized==true); 00126 fh.push(); 00127 minexpdim<X>::hasminimized=false; 00128 } 00129 }
| funchistory<X> minpatternsearch< X >::fh |
Consecutive X values are stored.
Definition at line 15 of file minpatternsearch.h.
Referenced by minpatternsearch< X >::operator++(), minpatternsearch< X >::reset(), and minexpdimtest::test04().
1.5.8