00001
00017 #ifndef KNITROSOLVER_H
00018 #define KNITROSOLVER_H
00019
00020 #include "OSConfig.h"
00021
00022
00023
00024 #ifndef NLPPROBLEMDEF_H__
00025 #include "nlpProblemDef.h"
00026 #endif
00027
00028 #include "OSConfig.h"
00029 #include "OSDefaultSolver.h"
00030 #include "OSrLWriter.h"
00031 #include "OSiLWriter.h"
00032 #include "OSInstance.h"
00033 #include "OSParameters.h"
00034 #include "OSnLNode.h"
00035 #include "OSiLReader.h"
00036 #include "OSInstance.h"
00037 #include "OSExpressionTree.h"
00038 #include "OSnLNode.h"
00039 #include "OSDataStructures.h"
00040 #include "OSFileUtil.h"
00041 #include "OSErrorClass.h"
00042
00043 #ifndef KNITRO_H__
00044 #include "knitro.h"
00045 #endif
00046
00047 # include <cstddef>
00048 # include <cstdlib>
00049 # include <cctype>
00050 # include <cassert>
00051 # include <stack>
00052 #include <string>
00053 # include <cppad/cppad.hpp>
00054 #include<iostream>
00055
00056
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