ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/NLModel.hpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/NLModel.hpp (file contents):
Revision 1000 by tim, Fri Jan 30 21:47:22 2004 UTC vs.
Revision 1010 by tim, Tue Feb 3 20:43:08 2004 UTC

# Line 3 | Line 3
3  
4   #include <vector>
5   #include <utility>
6 + #include <math.h>
7  
8   #include "SymMatrix.hpp"
9   #include "Functor.hpp"
10 + #include "ConstraintList.hpp"
11  
12   using namespace std;
13  
14  
15 < typedef enum FDType {backward, forward, central} ;
15 > typedef enum  {backward, forward, central} FDType;
16  
17   // special property of nonlinear object function
18 < typedef enum NLOFProp{linear, quadratic, general};
18 > typedef enum {linear, quadratic, general} NLOFProp;
19  
20   //abstract class of nonlinear optimization model
21   class NLModel{
# Line 23 | Line 25 | class NLModel{
25  
26      virtual void setX(const vector<double>& x)= 0;
27  
28 <    virtual int  getDim() const = 0;
28 >    virtual int  getDim() {return ndim;}
29  
30      bool hasConstraints() {  return constraints == NULL ? false : true;}
31 <    int getConsType() {  return constrains->getConsType();}
31 >    int getConsType() {  return constraints->getConsType();}
32  
33      virtual double calcF()  = 0;
34      virtual double calcF(const vector<double>& x)  = 0;
# Line 45 | Line 47 | class NLModel{
47    protected:
48      ConstraintList* constraints;       //constraints of nonlinear optimization model
49      int numOfFunEval;                  //number of function evaluation
50 +    int ndim;
51  
52   #ifdef IS_MPI
53      bool mpiInitFlag;
# Line 70 | Line 73 | class NLModel0 : public NLModel{
73      //Using finite difference methods to approximate the gradient
74      //It is inappropriate to apply these methods in large scale problem
75      
76 <    vector<double> BackwardGrad(const vector<double>& x, double& fx, vector<double>& grad);
77 <    vector<double> ForwardGrad(const vector<double>& x, double& fx, vector<double>& grad);
78 <    vector<double> CentralGrad(const vector<double>& x, double& fx, vector<double>& grad);
76 >    vector<double> BackwardGrad(const vector<double>& x, double& fx, vector<double>& grad, const vector<double>& h);
77 >    vector<double> ForwardGrad(const vector<double>& x, double& fx, vector<double>& grad, const vector<double>& h);
78 >    vector<double> CentralGrad(const vector<double>& x, double& fx, vector<double>& grad, const vector<double>& h);
79  
80      //Using finite difference methods to approximate the hessian
81      //It is inappropriate to apply this method in large scale problem
82 <    virtual SymMatrix FiniteHessian(vector<double>& x, double fx, vector<double>& h);
82 >    //virtual SymMatrix FiniteHessian(vector<double>& x, double fx, vector<double>& h);
83  
84    protected:
85  
86      FDType fdType;
87      vector<double> currentX;
88 <    double curretF;
88 >    double currentF;
89   };
90  
91   //concrete class of nonlinear optimization model without derivatives
# Line 114 | Line 117 | class NLModel1 : public NLModel0{
117      
118      //Using finite difference methods to approximate the hessian
119      //It is inappropriate to apply this method in large scale problem    
120 <    virtual SymMatrix FiniteHessian(vector<double>& x, double fx, vector<double>& h);
120 >    virtual SymMatrix FiniteHessian(vector<double>& x, vector<double>& h);
121      
122    protected:
123  
# Line 132 | Line 135 | class ConcreteNLMode1 : NLModel1{
135      virtual double calcF();
136      virtual double calcF(const vector<double>& x);
137      virtual vector<double> calcGrad();
138 <    virtual vector<double> calcGrad(vector<double>& x);
138 >    virtual vector<double> calcGrad(const vector<double>& x);
139      virtual SymMatrix calcHessian() ;
140      virtual SymMatrix calcHessian(vector<double>& x) ;
141  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines