NLFAPP.h

00001 #ifndef NLF0APP_h
00002 #define NLF0APP_h
00003 
00004 #include "NLF.h"
00005 #include "AppLauncher.h"
00006 
00007 using std::ostream;
00008 
00009 namespace OPTPP {
00010 
00018 typedef void (*USERFCN0APP)(int, const NEWMAT::ColumnVector&, real&, int&, 
00019   AppLauncher * launcher);
00020 typedef void (*USERNLNCON0APP)(int, int, const NEWMAT::ColumnVector&, 
00021   NEWMAT::ColumnVector&, int&, AppLauncher * launcher);
00022 typedef void (*INITFCNAPP)(int, NEWMAT::ColumnVector&, AppLauncher * launcher);
00023 
00030 class NLF0APP: public NLF0 {
00031 protected:
00032 USERFCN0APP fcn;                
00033 USERNLNCON0APP confcn;          
00034 INITFCNAPP init_fcn;            
00035 INITCONFCN init_confcn;         
00036 AppLauncher * launcher_;        
00037 bool init_flag;                 
00038 
00039 public:
00040 // Constructors
00041 NLF0APP(): 
00042   NLF0(){;}
00043 NLF0APP(int ndim): 
00044   NLF0(ndim){;}
00045 NLF0APP(int ndim, USERFCN0APP f): 
00046   NLF0(ndim) {fcn = f;}
00047 NLF0APP(int ndim, USERFCN0APP f, INITFCNAPP i, AppLauncher * launcher, CompoundConstraint* constraint = 0):
00048   NLF0(ndim, NULL, NULL, constraint) {fcn = f; init_fcn = i; init_flag = false; launcher_ = launcher;}
00049 NLF0APP(int ndim, USERFCN0APP f, INITFCNAPP i, INITCONFCN c):
00050   NLF0(ndim)
00051   {fcn = f; init_fcn = i; init_confcn = c; init_flag = false; 
00052    constraint_ = init_confcn(ndim);}                            
00053 NLF0APP(int ndim,int nlncons, USERNLNCON0APP f, INITFCNAPP i, AppLauncher *launcher):
00054   NLF0(ndim, nlncons, NULL, NULL) {confcn = f; init_fcn = i; init_flag = false; launcher_ = launcher;}
00055 
00056 // Destructor
00057 virtual ~NLF0APP() {;}               
00058 
00060 virtual void reset();                   
00061 
00063 virtual void initFcn();                         
00064 
00066 virtual void eval();                            
00067 
00069 virtual real evalF();                           
00070 
00072 virtual real evalF(const NEWMAT::ColumnVector& x);      
00073 
00075 virtual NEWMAT::ColumnVector evalCF(const NEWMAT::ColumnVector& x);     
00076 
00077 // Default Gradient function for NLF0 is to do a finite-difference
00079 virtual NEWMAT::ColumnVector evalG();
00080 
00082 virtual real evalLagrangian(const NEWMAT::ColumnVector& x, NEWMAT::ColumnVector& mult, 
00083   const NEWMAT::ColumnVector& type) ;
00084 
00086 virtual NEWMAT::ColumnVector evalLagrangianGradient(const NEWMAT::ColumnVector& x,
00087                                                 const NEWMAT::ColumnVector& mult,
00088                                                 const NEWMAT::ColumnVector& type) ;
00089 
00090 private:
00092 virtual NEWMAT::ColumnVector evalG(const NEWMAT::ColumnVector& x);  
00094 virtual NEWMAT::SymmetricMatrix evalH();                
00096 virtual NEWMAT::SymmetricMatrix evalH(NEWMAT::ColumnVector &x);
00098 virtual NEWMAT::Matrix evalCG(const NEWMAT::ColumnVector& x);   
00100 virtual NEWMAT::SymmetricMatrix evalCH(NEWMAT::ColumnVector &x);        
00102 virtual OptppArray<NEWMAT::SymmetricMatrix> evalCH(NEWMAT::ColumnVector &x, int darg);
00103 virtual void evalC(const NEWMAT::ColumnVector& x);      
00104 };
00105 
00112 class FDNLF1APP: public FDNLF1 {
00113 protected:
00114 USERFCN0APP fcn;                
00115 USERNLNCON0APP confcn;          
00116 INITFCNAPP init_fcn;            
00117 INITCONFCN init_confcn;         
00118 AppLauncher * launcher_;
00119 bool init_flag;                 
00120 
00121 public:
00122 // Constructor
00123 FDNLF1APP(): 
00124   FDNLF1(){;}
00125 FDNLF1APP(int ndim): 
00126   FDNLF1(ndim){;}
00127 FDNLF1APP(int ndim, USERFCN0APP f, INITFCNAPP i, AppLauncher * launcher, CompoundConstraint* constraint = 0): 
00128   FDNLF1(ndim, NULL, NULL, constraint)
00129   { fcn = f; init_fcn = i; init_flag = false; analytic_grad = 0; launcher_ = launcher;}
00130 FDNLF1APP(int ndim, int nlncons, USERNLNCON0APP f, INITFCNAPP i): 
00131   FDNLF1(ndim, nlncons, NULL, NULL)
00132   { confcn = f; init_fcn = i; init_flag = false; analytic_grad = 0;}
00133 FDNLF1APP(int ndim, USERFCN0APP f, INITFCNAPP i, INITCONFCN c): 
00134   FDNLF1(ndim){ fcn = f; init_fcn = i; init_confcn = c; 
00135   init_flag = false; analytic_grad = 0; constraint_ = init_confcn(ndim);}
00136 FDNLF1APP(int ndim, int nlncons, USERNLNCON0APP f, INITFCNAPP i, AppLauncher *launcher):
00137   FDNLF1(ndim, nlncons, NULL, NULL) {confcn = f; init_fcn = i; init_flag = false; 
00138   analytic_grad = 0; launcher_ = launcher;}
00139                         
00140 // Destructor
00141 virtual ~FDNLF1APP() {;}                     
00142 
00143 virtual void reset();                           
00144 virtual void initFcn();                         
00145 virtual void eval();                            
00146 virtual real evalF();                           
00147 virtual real evalF(const NEWMAT::ColumnVector& x);      
00148 virtual NEWMAT::ColumnVector evalG();                   
00149 
00150 virtual NEWMAT::ColumnVector evalG(const NEWMAT::ColumnVector& x);      
00151 virtual NEWMAT::SymmetricMatrix evalH();                        
00152 NEWMAT::SymmetricMatrix FDHessian(NEWMAT::ColumnVector& x);     
00153 
00154 // Print state
00155 virtual void printState(char *);    
00156 virtual void fPrintState(ostream *, char *);    
00157 
00159 virtual real evalLagrangian(const NEWMAT::ColumnVector& x, NEWMAT::ColumnVector& mult,
00160   const NEWMAT::ColumnVector& type) ;
00161 virtual NEWMAT::ColumnVector evalLagrangianGradient(const NEWMAT::ColumnVector& x,
00162                                                 const NEWMAT::ColumnVector& mult,
00163                                                 const NEWMAT::ColumnVector& type) ;
00165 virtual NEWMAT::ColumnVector evalCF(const NEWMAT::ColumnVector& x);     
00167 virtual NEWMAT::Matrix evalCG(const NEWMAT::ColumnVector& x);   
00168 
00169 private:
00171 virtual NEWMAT::SymmetricMatrix evalH(NEWMAT::ColumnVector& x);
00173 virtual NEWMAT::SymmetricMatrix evalCH(NEWMAT::ColumnVector &x);
00175 virtual OptppArray<NEWMAT::SymmetricMatrix> evalCH(NEWMAT::ColumnVector &x, int darg);
00176 virtual void evalC(const NEWMAT::ColumnVector& x);      
00177 };
00178 
00179 } // namespace OPTPP
00180 
00181 #endif
Generated on Mon Jan 24 12:04:37 2011 for FASTlib by  doxygen 1.6.3