1 //------------------------------------------------------------------------
2 // Copyright (C) 1993:
3 // J.C. Meza
4 // Sandia National Laboratories
5 // meza@california.sandia.gov
6 //------------------------------------------------------------------------
7
8 #include "NLP2.h"
9 #include "TOLS.h"
10 #include "cblas.h"
11 #include "ioformat.h"
12
13 using namespace std;
14
15 namespace OPTPP {
16
17 //-------------------------------------------------------------------------
18 // Output Routines
19 //-------------------------------------------------------------------------
20
printState(char * s)21 void NLP2::printState(char * s)
22 { // Print out current state: x current, gradient and Function value
23 cout << "\n\n========= " << s << " ===========\n\n";
24 cout << "\n i\t xc \t\t grad \t\t fcn_accrcy \n";
25 for (int i=1; i<=dim; i++)
26 cout << d(i,6) << e(mem_xc(i),12,4)<< "\t" << e(mem_grad(i),12,4)
27 << "\t" << e(mem_fcn_accrcy(i),12,4) << "\n";
28 cout <<"Function Value = " << e(fvalue,12,4) << "\n";
29 double gnorm = Norm2(mem_grad);
30 cout <<"Norm of gradient = " << e(gnorm,12,4) << "\n";
31 cout <<"\n\n==============================================\n\n";
32 }
33
fPrintState(ostream * nlpout,char * s)34 void NLP2::fPrintState(ostream *nlpout, char * s)
35 { // Print out current state: x current, gradient and Function value
36 (*nlpout) << "\n\n========= " << s << " ===========\n\n";
37 (*nlpout) << "\n i\t xc \t\t grad \t\t fcn_accrcy \n";
38 for (int i=1; i<=dim; i++)
39 (*nlpout)<< d(i,6) << e(mem_xc(i),12,4) << "\t" << e(mem_grad(i),12,4)
40 << "\t" << e(mem_fcn_accrcy(i),12,4) << "\n";
41 (*nlpout) <<"Function Value = " << e(fvalue,12,4) << "\n";
42 double gnorm = Norm2(mem_grad);
43 (*nlpout) <<"Norm of gradient = " << e(gnorm,12,4) << "\n";
44 // (*nlpout) <<"Function Accuracy = " << e(mem_fcn_accrcy,12,4) << "\n";
45 (*nlpout) <<"\n\n==============================================\n\n";
46 }
47
48 } // namespace OPTPP
49