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