OptNPSOL.h

00001 #ifndef OptNPSOL_h
00002 #define OptNPSOL_h
00003 
00004 /*----------------------------------------------------------------------
00005   Copyright (c) 2001, Sandia Corporation.   Under the terms of Contract 
00006   DE-AC04-94AL85000, there is a non-exclusive license for use of this 
00007   work by or on behalf of the U.S. Government.
00008  ----------------------------------------------------------------------*/
00009 
00010 #include "Opt.h"
00011 #include "NLF.h"
00012 #include "Appl_Data_NPSOL.h"
00013 
00014 namespace OPTPP {
00015 
00026 class OptNPSOL: public OptimizeClass {
00027 
00028   int             npsol_n;        
00029   int             npsol_nclin;    
00030   int             npsol_ncnln;    
00031   int             buf_len;        
00032   int             deriv_level;    
00033   int             lda;            
00034   int             ldcjac;         
00035   int             liwork;         
00036   int             lwork;          
00037   int             maxiter;        
00038   int             iter_taken;     
00039   int             ret_code;       
00040   int             *istate;        
00041   int             *iwork;         
00042   double          diff_interval;  
00043   double          fcn_accrcy;     
00044   double          *xvalue;        
00045   double          fvalue;         
00046   double          *grad;          
00047   double          *A;             
00048   double          *cfcn;          
00049   double          *clambda;       
00050   double          *cjac;          
00051   double          *hessian;       
00052   double          *lowerbounds;   
00053   double          *upperbounds;   
00054   double          *work;          
00055   bool            setXFlag;       
00056   INITFCN         initfcn;        
00057   USERFCN0        usrfcn0;        
00058   USERFCN1        usrfcn1;        
00059   USERNLNCON0     confcn0;        
00060   USERNLNCON1     confcn1;        
00061   Appl_Data_NPSOL *application;   
00062 
00063 public:
00064 
00065   //----------------------------------------------------------------------
00066   // Constructors & Destructors
00067   //----------------------------------------------------------------------
00068 
00069   OptNPSOL(int n, int nclin, int ncnln, USERFCN0 f,INITFCN i) : npsol_n(n), 
00070            npsol_nclin(nclin), npsol_ncnln(ncnln), buf_len(1), 
00071            deriv_level(0), lda(nclin), ldcjac(ncnln), fvalue(1.0e30),
00072            setXFlag(false)  
00073            {initfcn = i; usrfcn0 = f; usrfcn1 = NULL; 
00074             confcn0 = NULL; confcn1 = NULL; application = NULL;
00075             xvalue=grad=A=cfcn=clambda=cjac=lowerbounds=upperbounds=NULL;
00076             hessian=work=NULL; istate=iwork=NULL;
00077            }
00078 
00079   OptNPSOL(int n, int nclin, int ncnln, USERFCN1 f,INITFCN i) : npsol_n(n), 
00080            npsol_nclin(nclin), npsol_ncnln(ncnln), buf_len(1), 
00081            deriv_level(0), lda(nclin), ldcjac(ncnln), fvalue(1.0e30),
00082            setXFlag(false) 
00083            {initfcn = i; usrfcn0 = NULL; usrfcn1 = f; 
00084             confcn0 = NULL; confcn1 = NULL; application = NULL;
00085             xvalue=grad=A=cfcn=clambda=cjac=lowerbounds=upperbounds=NULL;
00086             hessian=work=NULL; istate=iwork=NULL;
00087            }
00088 
00089   OptNPSOL(int n,int nclin,int ncnln,USERFCN0 f,INITFCN i,USERNLNCON0 c) : 
00090            npsol_n(n), npsol_nclin(nclin), npsol_ncnln(ncnln), buf_len(1),
00091            deriv_level(0), lda(nclin), ldcjac(ncnln), fvalue(1.0e30),
00092            setXFlag(false) 
00093            {initfcn = i; usrfcn0 = f; usrfcn1 = NULL; 
00094             confcn0 = c; confcn1 = NULL; application = NULL;
00095             xvalue=grad=A=cfcn=clambda=cjac=lowerbounds=upperbounds=NULL;
00096             hessian=work=NULL; istate=iwork=NULL;
00097            }
00098 
00099   OptNPSOL(int n,int nclin,int ncnln,USERFCN1 f,INITFCN i,USERNLNCON0 c) : 
00100            npsol_n(n), npsol_nclin(nclin), npsol_ncnln(ncnln), buf_len(1),
00101            deriv_level(0), lda(nclin), ldcjac(ncnln), fvalue(1.0e30),
00102            setXFlag(false) 
00103            {initfcn = i; usrfcn0 = NULL; usrfcn1 = f; 
00104             confcn0 = c; confcn1 = NULL; application = NULL;
00105             xvalue=grad=A=cfcn=clambda=cjac=lowerbounds=upperbounds=NULL;
00106             hessian=work=NULL; istate=iwork=NULL;
00107            }
00108 
00109   OptNPSOL(int n,int nclin,int ncnln,USERFCN1 f,INITFCN i,USERNLNCON1 c) : 
00110            npsol_n(n), npsol_nclin(nclin), npsol_ncnln(ncnln), buf_len(1),
00111            deriv_level(0), lda(nclin), ldcjac(ncnln), fvalue(1.0e30), 
00112            setXFlag(false) 
00113            { initfcn = i; usrfcn0 = NULL; usrfcn1 = f; 
00114             confcn0 = NULL; confcn1 = c; application = NULL;
00115             xvalue=grad=A=cfcn=clambda=cjac=lowerbounds=upperbounds=NULL;
00116             hessian=work=NULL; istate=iwork=NULL;
00117            }
00118 
00119   ~OptNPSOL(); 
00120 
00121   //----------------------------------------------------------------------
00122   // internal functions
00123   //----------------------------------------------------------------------
00124 
00125   void initOpt();                       
00126   void optimize();                      
00127   void allocate(int&, int&, int&,       
00128             int&, int&);
00129   void readOptInput();                  
00130   void printStatus(char *);             
00131   void setX(const NEWMAT::ColumnVector&);       
00132   void setLower(const NEWMAT::ColumnVector&);   
00133   void setUpper(const NEWMAT::ColumnVector&);   
00134   void setMatrix(const NEWMAT::Matrix&);        
00135   void setDerivativeLevel(int &);       
00136   void setDifferenceInterval(double &); 
00137   void setFcnAccrcy(double &);          
00138   
00139 
00140   //----------------------------------------------------------------------
00141   // other functions that need to be defined to get around the pure
00142   // virtual function complaints from the compiler
00143   //----------------------------------------------------------------------
00144 
00145   virtual void  acceptStep(int, int ) { }
00146   virtual int   checkConvg()          {return 0;}
00147   virtual NEWMAT::ColumnVector computeSearch(NEWMAT::SymmetricMatrix& ) 
00148                                       {return (NEWMAT::ColumnVector) 0;}
00149   virtual void  updateModel(int k, int ndim, NEWMAT::ColumnVector x)
00150     {OptimizeClass::defaultUpdateModel(k, ndim, x);}
00151   virtual void reset(){;}
00152 
00153 };
00154 
00155 } // namespace OPTPP
00156 
00157 #endif
00158 
Generated on Mon Jan 24 12:04:37 2011 for FASTlib by  doxygen 1.6.3