Files Classes Functions Hierarchy
00001 #include <cassert> 00002 #include <iostream> 00003 #include <cmath> 00004 #include <iomanip> 00005 using namespace std; 00006 00007 00008 00009 #include <print.h> 00010 #include <commandline.h> 00011 00012 #include <probsysequ01.h> 00013 #include <exploreh.h> 00014 00015 #include <lineoptimizergold2.h> 00016 00017 00018 00019 //#include <powell02.h> 00020 #include <powelltest.h> 00021 #include <linepathd1.h> 00022 00023 00024 //static double h0step=0.2; 00025 00026 void powelltest01(int argc, char** argv) 00027 { 00028 /* 00029 00030 cout << "explore and golden ratio line search" << endl; 00031 cout << " k=3 lineiter=10 are defaults." << endl; 00032 00033 typedef exploreh<probsysequ01,double*,double> exp2; 00034 typedef linepathd1< probsysequ01,double*,double*,double > lnpath; 00035 typedef lineoptimizergold2< lnpath, double > lnmin; 00036 00037 00038 commandline cmd(argc,argv); 00039 uint lineiter(10); 00040 cmd.mapvar(lineiter,"lineiter"); 00041 uint k(3); 00042 cmd.mapvar(k,"k"); 00043 00044 powell02< exp2, lnmin > w(2,lineiter,h0step); 00045 00046 cmd.mapvar(w.linet0,"t0"); 00047 cmd.mapvar(w.linet1,"t1"); 00048 00049 cout << SHOW( w.exp.fn.counter) << endl; 00050 00051 double x0[2] = { 0.5, 0.5 }; 00052 w.reset(x0); 00053 00054 00055 cout << SHOW( w.exp.fn.counter) << endl; 00056 00057 for (uint i=0; i<k; ++i) 00058 { 00059 //cout << printvecfunc(w.xi,2) << endl; 00060 //cout << SHOW(w.exp.fmin) << endl; 00061 ++w; 00062 // cout << SHOW(w.fn.counter) << endl; 00063 } 00064 00065 double * xi = w.xi0[0]; 00066 00067 long double y0((long double)0.2); 00068 long double y1((long double)2.0/(long double)3.0); 00069 long double dist = (y0-xi[0])*(y0-xi[0]) + (y1-xi[1])*(y1-xi[1]); 00070 00071 cout << "Compare with true solution" << endl; 00072 cout << "fn count, k, lineiter, distance" << endl; 00073 cout << w.exp.fn.counter << " "; 00074 cout << k << " "; 00075 cout << lineiter << " "; 00076 cout << scientific << dist << endl; 00077 cout << SHOW(w.exp.fmin) << endl; 00078 */ 00079 00080 } 00081 00082 void powelltest02(int argc, char** argv) 00083 { 00084 00085 } 00086 00087 00088
1.5.8