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 996 by tim, Wed Jan 28 22:44:44 2004 UTC vs.
Revision 1000 by tim, Fri Jan 30 21:47:22 2004 UTC

# Line 20 | Line 20 | class NLModel{
20    public:    
21      NLModel(ConstraintList* cons) {constraints = cons;}
22      virtual ~NLModel() {  if (constraints != NULL) delete constraints;}
23 +
24      virtual void setX(const vector<double>& x)= 0;
25  
25    virtual void setF(const vector<double>& fx)= 0;
26
26      virtual int  getDim() const = 0;
27  
28      bool hasConstraints() {  return constraints == NULL ? false : true;}
# Line 66 | Line 65 | class NLModel0 : public NLModel{
65      NLModel0(int dim,  ConstraintList* cons = NULL);
66      ~NLModel0() {}
67  
68 <  protected:
68 >    virtual void setX(const vector<double>& x);
69  
70      //Using finite difference methods to approximate the gradient
71      //It is inappropriate to apply these methods in large scale problem
# Line 77 | Line 76 | class NLModel0 : public NLModel{
76  
77      //Using finite difference methods to approximate the hessian
78      //It is inappropriate to apply this method in large scale problem
79 <    virtual SymMatrix FiniteHessian(vector<double>& sx);
79 >    virtual SymMatrix FiniteHessian(vector<double>& x, double fx, vector<double>& h);
80  
81 +  protected:
82 +
83      FDType fdType;
84      vector<double> currentX;
85 +    double curretF;
86   };
87  
88 + //concrete class of nonlinear optimization model without derivatives
89 +
90 + class ConcreteNLMode0 : public NLModel0{
91 +
92 +  public:
93 +
94 +    ConcreteNLMode0(int dim, ObjFunctor0* func ,  ConstraintList* cons = NULL);
95 +    ConcreteNLMode0(int dim, ConstraintList* cons = NULL);
96 +
97 +    virtual double calcF();
98 +    virtual double calcF(const vector<double>& x);
99 +    virtual vector<double> calcGrad();
100 +    virtual vector<double> calcGrad(vector<double>& x);
101 +    virtual SymMatrix calcHessian() ;
102 +    virtual SymMatrix calcHessian(vector<double>& x) ;
103 +    
104 +  protected:
105 +
106 +    ObjFunctor0* objfunc;
107 +
108 + };
109 +
110   //abstract class of nonlinear optimization model with first derivatives
111   class NLModel1 : public NLModel0{
112 +
113    public:
114      
115      //Using finite difference methods to approximate the hessian
116      //It is inappropriate to apply this method in large scale problem    
117 <    virtual SymMatrix ForwardHessian(vector<double>& sx);
117 >    virtual SymMatrix FiniteHessian(vector<double>& x, double fx, vector<double>& h);
118      
119    protected:
120 +
121      vector<double> currentGrad;
122   };
123  
124   //concrete class of nonlinear optimization model with first derivatives
125   class ConcreteNLMode1 : NLModel1{
126 +
127    public:
128 +
129      ConcreteNLMode1(int dim, ObjFunctor1* func ,  ConstraintList* cons = NULL);
130      ConcreteNLMode1(int dim, ConstraintList* cons = NULL);
131      
# Line 109 | Line 137 | class ConcreteNLMode1 : NLModel1{
137      virtual SymMatrix calcHessian(vector<double>& x) ;
138  
139    protected:
140 +
141      ObjFunctor1* objfunc;
142   };
143  
115
144   /*
145 + //abstract class of nonlinear optimization model with second derivatives
146   class NLModel2 : public NLModel1{
147    public:
148 +    
149 +  protected:    
150 +    SymMatrix currentHessian;
151  
152 <    NLModel2(int dim, ObjFunctor2* func ,  ConstraintList* cons = NULL);
153 <    ~NLModel2() {}  
152 > };
153 >
154 > //concrete class of nonlinear optimization model with second derivatives
155 > class ConcreteNLModel2 : public NLModel2{
156 >  public:
157 >
158 >    ConcreteNLModel2(int dim, ObjFunctor2* func ,  ConstraintList* cons = NULL);
159 >    ConcreteNLModel2(int dim, ConstraintList* cons = NULL);
160      
161      virtual double calcF();
162      virtual double calcF(const vector<double>& x);
# Line 129 | Line 167 | class NLModel2 : public NLModel1{
167      
168    protected:
169      
132    SymMatrix hessian;
170      ObjFunctor2* objFunc;
171   };
172   */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines