00001 // rdSQP.cpp 00002 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00003 // Copyright 2000 Realistic Dynamics, Inc. 00004 // All rights reserved. 00005 // 00006 // CONFIDENTIAL 00007 // 00008 // The material contain within this file is the property of 00009 // Realistic Dynamics, Inc. Please do not read, copy, or distribute 00010 // without the expressed writen consent of Realistic Dynamics, Inc. 00011 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00012 #ifndef __rdSQP_h__ 00013 #define __rdSQP_h__ 00014 00015 00016 00017 //============================================================================= 00018 // INCLUDES 00019 //============================================================================= 00020 #include <rdMtx.h> 00021 #include "rdSQPDLL.h" 00022 #include "rdOptimizationTarget.h" 00023 00024 00025 //============================================================================= 00026 //============================================================================= 00031 class RDSQP_API rdSQP 00032 { 00033 //============================================================================= 00034 // DATA 00035 //============================================================================= 00036 private: 00037 // OPTIMIZATION TARGET 00038 rdOptimizationTarget *_target; 00039 00040 // CONTROLS 00041 int _nx; 00042 double *_xtmp,*_dx; 00043 00044 // PERFORMANCE AND CONSTRAINTS 00045 int _status; 00046 int _nc,_nceq; 00047 double _p,*_c,*_cw; 00048 00049 // DERIVATIVES 00050 double *_dpdx,*_dcdx,*_dxda; 00051 00052 // WORKSPACE 00053 int _nwd,_nwi; 00054 double *_wd; 00055 int *_wi; 00056 00057 // SQP PARAMETERS 00058 int _statusOpt; 00059 int _maxIter; 00060 double _epsOpt,_convergence; 00061 00062 // LINE SEARCH PARAMETERS 00063 int _statusLine; 00064 int _mfc; 00065 double _epsLine; 00066 double _fact[4]; 00067 double _minAlpha,_maxAlpha; 00068 double _firstAlpha; 00069 double _alpha[4]; 00070 00071 //============================================================================= 00072 // METHODS 00073 //============================================================================= 00074 public: 00075 //-------------------------------------------------------------------------- 00076 // CONSTRUCTION 00077 //-------------------------------------------------------------------------- 00078 virtual ~rdSQP(); 00079 static void Delete(void *aPtr); 00080 rdSQP(rdOptimizationTarget *aTarget); 00081 00082 //-------------------------------------------------------------------------- 00083 // SET AND GET 00084 //-------------------------------------------------------------------------- 00085 void setMaxIterations(int aMaxIter); 00086 int getMaxIterations(); 00087 void setConvergenceCriterion(double aMaxIter); 00088 double getConvergenceCriterion(); 00089 void setMaxEvaluations(int aMaxEval); 00090 int getMaxEvaluations(); 00091 void setLineConvergenceCriterion(double aMaxIter); 00092 double getLineConvergenceCriterion(); 00093 void setMinAlpha(double aMin); 00094 double getMinAlpha(); 00095 void setMaxAlpha(double aMax); 00096 double getMaxAlpha(); 00097 00098 00099 //-------------------------------------------------------------------------- 00100 // OPTIMAL CONTROLS 00101 //-------------------------------------------------------------------------- 00102 int computeOptimalControls(const double *xstart,double *x); 00103 00104 //-------------------------------------------------------------------------- 00105 // DERIVATIVES 00106 //-------------------------------------------------------------------------- 00107 static int 00108 CentralDifferences(rdOptimizationTarget *aTarget, 00109 double *dx,double *x,double *dpdx,double *dcdx); 00110 00111 //-------------------------------------------------------------------------- 00112 // SEARCH DIRECTION 00113 //-------------------------------------------------------------------------- 00114 void 00115 computeSearchDirection(int *status,double *x, 00116 double *p,double *dpdx,double *c,double *dcdx,double *alpha, 00117 double *dxda,double *mu); 00118 00119 //-------------------------------------------------------------------------- 00120 // LINE SEARCH 00121 //-------------------------------------------------------------------------- 00122 int lineSearch(double *x,double *dx,double *mu,double *xnew); 00123 00124 //============================================================================= 00125 }; // END class rdSQP 00126 //============================================================================= 00127 //============================================================================= 00128 00129 #endif // __rdSQP_h__
1.3