00001 // QMcBeaver 00002 // 00003 // Constructed by 00004 // 00005 // Michael Todd Feldmann 00006 // and 00007 // David Randall "Chip" Kent IV 00008 // 00009 // Copyright 2000. All rights reserved. 00010 // 00011 // drkent@users.sourceforge.net mtfeldmann@users.sourceforge.net 00012 00013 #include "QMCLineSearchStepLengthSelectionFactory.h" 00014 #include "QMCMikesBracketingStepLengthSelector.h" 00015 #include "QMCWolfeStepLengthSelector.h" 00016 #include "QMCValueStepLength.h" 00017 #include "QMCLinearizeStepLength.h" 00018 00019 QMCLineSearchStepLengthSelectionAlgorithm * 00020 QMCLineSearchStepLengthSelectionFactory::factory(string & Type) 00021 { 00022 QMCLineSearchStepLengthSelectionAlgorithm * algorithm = 0; 00023 00024 double value = 0; 00025 00026 char ** ptr = 0; 00027 value = strtod(Type.c_str(), ptr); 00028 00029 if( Type == "MikesBracketing" ) 00030 { 00031 algorithm = new QMCMikesBracketingStepLengthSelector(); 00032 } 00033 else if( Type == "Wolfe" ) 00034 { 00035 algorithm = new QMCWolfeStepLengthSelector(); 00036 } 00037 else if( Type == "Linearize" ) 00038 { 00039 algorithm = new QMCLinearizeStepLength(); 00040 } 00041 else if( Type == "None" ) 00042 { 00043 algorithm = new QMCValueStepLength(1.0); 00044 } 00045 else if( fabs(value) > 1.0e-10 ) 00046 { 00047 algorithm = new QMCValueStepLength(value); 00048 } 00049 else 00050 { 00051 cerr << "ERROR: Unknown line search step length selection algorithm (" 00052 << Type 00053 << ") being assigned in QMCLineSearchStepLengthSelectionFactory!" 00054 << endl; 00055 exit(0); 00056 } 00057 00058 return algorithm; 00059 }