CSimpleLineSearch.cpp

Go to the documentation of this file.
00001 #include "CSimpleLineSearch.h"
00002 #include <iostream>
00003 
00004 using namespace std;
00005 CSimpleLineSearch::CSimpleLineSearch()
00006 {
00007         Wolfe1Factor = 1e-4;
00008 }
00009 
00010 CSimpleLineSearch::~CSimpleLineSearch()
00011 {
00012 }
00013 
00014 double CSimpleLineSearch::SearchStepsize(const double initial,const double CurrentMisfit,
00015                 const ublas::vector<double> &Searchdirection, const ublas::vector<double> &Model, 
00016                 const ublas::vector<double> &Data, const ublas::vector<double> Gradient)
00017 {
00018         cout << endl << "In Line Search " << endl << endl;
00019         double stepsize = initial;
00020         const int maxsearch = 40;
00021         const double stepreduction = 0.5;
00022         int searchiterations = 0; 
00023         double NewMisfit = 1e90;
00024         ublas::vector<double> NewModel(Model.size());
00025         double Wolfe1 = 0; 
00026         const double gradsearchprodukt =  inner_prod(Gradient,Searchdirection);
00027         cout << "Gradsearchprodukt: " << gradsearchprodukt << endl;
00028         while ((NewMisfit > Wolfe1) && (searchiterations < maxsearch))
00029         {
00030                 NewModel= Model + stepsize * Searchdirection;
00031                 NewMisfit = MisfitCalculator->CalcPerformance(NewModel);
00032                 Wolfe1 = CurrentMisfit + Wolfe1Factor * stepsize * gradsearchprodukt;  
00033                 cout << "NewMisfit: " << NewMisfit << " ";
00034                 cout << "Wolfe1: " << Wolfe1 << endl;
00035                 stepsize *= stepreduction;
00036                 if (isnan(NewMisfit))
00037                 {
00038                         NewMisfit = 1e90;
00039                         stepsize /= 100;
00040                 }
00041                 searchiterations++;
00042         }
00043         cout << "Searches: " << searchiterations << " Stepsize: " << 2 * stepsize << endl;
00044         cout << "NewMisfit: " << NewMisfit << " " << "Wolfe1: " << Wolfe1 << endl << endl;;
00045         return stepsize/stepreduction;
00046 }

Generated on Fri Jul 4 15:30:20 2008 for GPLIB++ by  doxygen 1.5.5