00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "QMCOptimizationFactory.h"
00014 #include "QMCLineSearchStepLengthSelectionFactory.h"
00015 #include "QMCSteepestDescent.h"
00016 #include "QMCBFGSQuasiNewtonLineSearch.h"
00017 #include "CKGeneticAlgorithm1.h"
00018 #include "QMCEigenSearch.h"
00019
00020 QMCOptimizationAlgorithm * QMCOptimizationFactory::
00021 optimizationAlgorithmFactory(QMCObjectiveFunction &objFunc,
00022 QMCInput * input)
00023 {
00024 QMCOptimizationAlgorithm * optAlg = 0;
00025
00026 if( input->flags.optimize_Psi_criteria == "analytical_energy_variance")
00027 {
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 QMCLineSearchStepLengthSelectionAlgorithm *stepAlg =
00045 QMCLineSearchStepLengthSelectionFactory::factory(
00046 input->flags.line_search_step_length);
00047
00048 optAlg = new QMCSteepestDescent(&objFunc, stepAlg,
00049 input->flags.optimization_max_iterations,
00050 input->flags.optimization_error_tolerance);
00051
00052 }
00053 else if( input->flags.optimize_Psi_criteria == "generalized_eigenvector" )
00054 {
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 QMCLineSearchStepLengthSelectionAlgorithm *stepAlg =
00066 QMCLineSearchStepLengthSelectionFactory::factory(
00067 input->flags.line_search_step_length);
00068
00069 optAlg = new QMCEigenSearch(&objFunc, stepAlg,
00070 input->flags.optimization_max_iterations,
00071 input->flags.optimization_error_tolerance);
00072
00073 }
00074 else if( input->flags.optimize_Psi_method == "BFGSQuasiNewton" )
00075 {
00076
00077
00078
00079 QMCLineSearchStepLengthSelectionAlgorithm *stepAlg =
00080 QMCLineSearchStepLengthSelectionFactory::factory(
00081 input->flags.line_search_step_length);
00082
00083 optAlg = new QMCBFGSQuasiNewtonLineSearch(&objFunc, stepAlg,
00084 input->flags.optimization_max_iterations,
00085 input->flags.optimization_error_tolerance);
00086
00087 }
00088 else if( input->flags.optimize_Psi_method == "CKGeneticAlgorithm1" )
00089 {
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 optAlg = new CKGeneticAlgorithm1(&objFunc,
00100 input->flags.ck_genetic_algorithm_1_population_size,
00101 input->flags.ck_genetic_algorithm_1_mutation_rate,
00102 input->flags.ck_genetic_algorithm_1_initial_distribution_deviation);
00103 }
00104 else if( input->flags.optimize_Psi_method == "Steepest_Descent" )
00105 {
00106
00107
00108
00109
00110
00111
00112 QMCLineSearchStepLengthSelectionAlgorithm *stepAlg =
00113 QMCLineSearchStepLengthSelectionFactory::factory(
00114 input->flags.line_search_step_length);
00115
00116 optAlg = new QMCSteepestDescent(&objFunc, stepAlg,
00117 input->flags.optimization_max_iterations,
00118 input->flags.optimization_error_tolerance);
00119
00120 }
00121 else
00122 {
00123 cerr << "ERROR: Unknown optimization algorithm ("
00124 << input->flags.optimize_Psi_method
00125 << ") in QMCOptimizationFactory!" << endl;
00126 exit(1);
00127 }
00128
00129 return optAlg;
00130 }