00001
00016 #ifndef KNITROSOLVER_H
00017 #define KNITROSOLVER_H
00018
00019 #include "OSConfig.h"
00020
00021
00022
00023 #ifndef NLPPROBLEMDEF_H__
00024 #include "nlpProblemDef.h"
00025 #endif
00026
00027 #include "OSConfig.h"
00028 #include "OSDefaultSolver.h"
00029 #include "OSrLWriter.h"
00030 #include "OSiLWriter.h"
00031 #include "OSInstance.h"
00032 #include "OSParameters.h"
00033 #include "OSnLNode.h"
00034 #include "OSiLReader.h"
00035 #include "OSInstance.h"
00036 #include "OSExpressionTree.h"
00037 #include "OSnLNode.h"
00038 #include "OSDataStructures.h"
00039 #include "OSFileUtil.h"
00040 #include "OSErrorClass.h"
00041
00042 #ifndef KNITRO_H__
00043 #include "knitro.h"
00044 #endif
00045
00046 # include <cstddef>
00047 # include <cstdlib>
00048 # include <cctype>
00049 # include <cassert>
00050 # include <stack>
00051 #include <string>
00052 # include <cppad/cppad.hpp>
00053 #include<iostream>
00054
00055
00056
00057
00058 #ifdef HAVE_CTIME
00059 # include <ctime>
00060 #else
00061 # ifdef HAVE_TIME_H
00062 # include <time.h>
00063 # else
00064 # error "don't have header file for time"
00065 # endif
00066 #endif
00067
00068
00069 #ifdef HAVE_CMATH
00070 # include <cmath>
00071 #else
00072 # ifdef HAVE_MATH_H
00073 # include <math.h>
00074 # else
00075 # error "don't have header file for math"
00076 # endif
00077 #endif
00078
00079
00080
00081
00082
00083
00084
00085
00086 class KnitroProblem : public NlpProblemDef {
00087 public:
00088
00090 KnitroProblem(OSInstance *osinstance_ , OSResult *osresult_);
00091
00093 virtual ~KnitroProblem();
00094
00095 OSResult *osresult;
00096
00097 OSInstance *osinstance;
00098
00099
00100
00101
00102 int getN (void);
00103 int getM (void);
00104 void getInitialX (double * const daX);
00105 bool loadProblemIntoKnitro (KTR_context_ptr kc);
00106 bool areDerivativesImplemented
00107 (const DerivativesImplementedType nWhichDers);
00108
00109 int evalFC (const double * const daX,
00110 double * const dObj,
00111 double * const daC,
00112 void * userParams);
00113 int evalGA (const double * const daX,
00114 double * const daG,
00115 double * const daJ,
00116 void * userParams);
00117 int evalH (const double * const daX,
00118 const double * const daLambda,
00119 double * const daH,
00120 void * userParams);
00121 int evalHV (const double * const daX,
00122 const double * const daLambda,
00123 double * const daHV,
00124 void * userParams);
00125
00126 std::string knitroErrorMsg;
00127 };
00128
00129
00142 class KnitroSolver : public DefaultSolver {
00143
00144 public:
00145
00147 KnitroSolver();
00148
00150 ~KnitroSolver();
00151
00156 virtual void buildSolverInstance() throw(ErrorClass);
00157
00160 virtual void solve() throw (ErrorClass) ;
00161
00167 void dataEchoCheck();
00168
00169 private:
00170
00171 OSrLWriter *osrlwriter;
00172
00184
00185 KnitroSolver(const KnitroSolver&);
00186 KnitroSolver& operator=(const KnitroSolver&);
00188 std::string knitroErrorMsg;
00189
00190 };
00191
00192
00193 #endif