#include <fstream> #include "OptCG.h" #include "NLF.h" #include "tstfcn.h" using NEWMAT::ColumnVector; using namespace OPTPP; void update_model(int, int, ColumnVector) {} int main () { int n = 2; static char *status_file = {"tstcg.out"}; // Create a Nonlinear problem object NLF1 nlp(n,rosen,init_rosen); // Build a CG object and optimize OptCG objfcn(&nlp); objfcn.setUpdateModel(update_model); if (!objfcn.setOutputFile(status_file, 0)) cerr << "main: output file open failed" << endl; // Set gradient tolerance equal to 1.0e-6 objfcn.setGradTol(1.e-6); objfcn.optimize(); objfcn.printStatus("Solution from CG: Fcn not Expensive"); objfcn.cleanup(); }
View the output of a conjugate gradient method
Next Section: Quasi-Newton method with trust-region | Back to Unconstrained minimization
Last revised September 14, 2006 .