proj home

Files   Classes   Functions   Hierarchy  

explorepdtest.cpp File Reference

#include <iostream>
#include <cmath>
#include <iomanip>
#include <print.h>
#include <commandline.h>
#include <probsysequ01.h>
#include <explorepd1.h>
#include <lineoptimizergold.h>
#include <exploreh.h>
#include <explorepdtest.h>

Include dependency graph for explorepdtest.cpp:

Go to the source code of this file.

Functions

void explorepdtest01 (int argc, char **argv)
void explorepdtest02 (int argc, char **argv)

Variables

static double h0step = 0.2


Function Documentation

void explorepdtest01 ( int  argc,
char **  argv 
)

Definition at line 18 of file explorepdtest.cpp.

References h0step, and commandline::mapvar().

Referenced by main().

00019 {
00020   cout << "explore 1st order partial derivative with the golden ratio line search" << endl;
00021   cout << "  k=3 lineiter=10 are defaults." << endl;
00022 
00023   typedef exploreh<probsysequ01,double*,double> exp2;
00024   typedef lineoptimizergold<probsysequ01&,double*,double*,double> lnmin;
00025 
00026   commandline cmd(argc,argv);
00027   uint lineiter(10);
00028   cmd.mapvar(lineiter,"lineiter");
00029   uint k(3);
00030   cmd.mapvar(k,"k");
00031 
00032   explorepd1< exp2, lnmin > w(2,lineiter,h0step);
00033 
00034   cmd.mapvar(w.linet0,"t0");
00035   cmd.mapvar(w.linet1,"t1");
00036 
00037   double x0[2] = { 0.5, 0.5 };
00038   w.reset(x0);
00039 
00040   for (uint i=0; i<k; ++i)
00041   {
00042 //cout << printvecfunc(w.xi,2) << endl;
00043     ++w;
00044 //    cout << SHOW(w.fn.counter) << endl;
00045   }
00046   cout << left << setw(4) << "k";
00047   cout << left << setw(15) << "fmin";
00048   cout << "function counter" << endl;
00049   cout << left << setw(4) << k;
00050   cout << left << setw(15) << scientific << w.fmin;
00051   cout << left << setw(4) << w.fn.counter << endl;
00052   //cout << scientific << SHOW(w.fmin) << endl;
00053   //cout << SHOW(w.fn.counter) << endl;
00054 
00055 /*
00056   long double y0((long double)0.2);
00057   long double y1((long double)2.0/(long double)3.0);
00058   long double dist = (y0-w.xi[0])*(y0-w.xi[0]) + (y1-w.xi[1])*(y1-w.xi[1]);
00059 
00060 
00061   cout << "Compare with true solution" << endl;
00062   cout << "fn-count, k, lineiter, distance" << endl;
00063   cout << w.fn.counter << "  ";
00064   cout << k << "  ";
00065   cout << lineiter << "  ";
00066   cout << scientific << dist << endl;
00067 */
00068 
00069 }

void explorepdtest02 ( int  argc,
char **  argv 
)

Definition at line 72 of file explorepdtest.cpp.

References probsysequ01::counter, exploreh< FN, XI, T >::fmin, exploreh< FN, XI, T >::fn, h0step, commandline::mapvar(), and exploreh< FN, XI, T >::reset().

Referenced by main().

00073 {
00074   commandline cmd(argc,argv);
00075   uint k(3);
00076   cmd.mapvar(k,"k");
00077 
00078   exploreh<probsysequ01,double*,double> g(2,h0step,50000);
00079 
00080   double x0[2] = { 0.5, 0.5 };
00081 
00082   g.reset(x0);
00083 
00084   //g.print(cout);
00085 
00086   for (uint i=0; i<k; ++i)
00087   {
00088     ++g;
00089   }
00090 
00091   //cout << scientific << SHOW(g.fmin) << endl;
00092 
00093   //g.print(cout);
00094   //cout << SHOW(g.fn.counter) << endl;
00095 
00096 
00097   cout << left << setw(4) << "k";
00098   cout << left << setw(15) << "fmin";
00099   cout << "function counter" << endl;
00100   cout << left << setw(4) << k;
00101   cout << left << setw(15) << scientific << g.fmin;
00102   cout << left << setw(4) << g.fn.counter << endl;
00103 }


Variable Documentation

double h0step = 0.2 [static]

Definition at line 16 of file explorepdtest.cpp.

Referenced by explorepdtest01(), and explorepdtest02().


Generated on Fri Mar 4 00:49:44 2011 for Chelton Evans Source by  doxygen 1.5.8