My Project
OSKnitroSolver.h
Go to the documentation of this file.
1 /* $Id$ */
15 #ifndef KNITROSOLVER_H
16 #define KNITROSOLVER_H
17 
18 #include "OSConfig.h"
19 
20 
21 
22 #ifndef NLPPROBLEMDEF_H__
23 #include "nlpProblemDef.h"
24 #endif
25 
26 #include "OSConfig.h"
27 #include "OSDefaultSolver.h"
28 #include "OSrLWriter.h"
29 #include "OSiLWriter.h"
30 #include "OSInstance.h"
31 #include "OSParameters.h"
32 #include "OSnLNode.h"
33 #include "OSiLReader.h"
34 #include "OSInstance.h"
35 #include "OSExpressionTree.h"
36 #include "OSnLNode.h"
37 #include "OSDataStructures.h"
38 #include "OSFileUtil.h"
39 #include "OSErrorClass.h"
40 
41 #ifndef KNITRO_H__
42 # include "knitro.h"
43 #endif
44 
45 #include <cstddef>
46 #include <cstdlib>
47 #include <cctype>
48 #include <cassert>
49 #include <stack>
50 #include <string>
51 
52 #ifdef OS_HAS_CPPAD
53 # include <cppad/cppad.hpp>
54 #endif
55 
56 #include<iostream>
57 
58 
59 #ifdef HAVE_CTIME
60 # include <ctime>
61 #else
62 # ifdef HAVE_TIME_H
63 # include <time.h>
64 # else
65 # error "don't have header file for time"
66 # endif
67 #endif
68 
69 
70 #ifdef HAVE_CMATH
71 # include <cmath>
72 #else
73 # ifdef HAVE_MATH_H
74 # include <math.h>
75 # else
76 # error "don't have header file for math"
77 # endif
78 #endif
79 
80 
81 
82 //#include<vector>
83 //#include <map>
84 
85 
86 
87 class KnitroProblem : public NlpProblemDef
88 {
89 public:
90 
92  KnitroProblem(OSInstance *osinstance_ , OSResult *osresult_);
93 
95  virtual ~KnitroProblem();
96 
98 
100 
101  //Knitro specific methods
102  //++ Declare virtual base class methods that are implemented here.
103  //++ See NlpProblemDef.h for descriptions.
104  int getN (void);
105  int getM (void);
106  void getInitialX (double * const daX);
107  bool loadProblemIntoKnitro (KTR_context_ptr kc);
109  (const DerivativesImplementedType nWhichDers);
110 
111  int evalFC (const double * const daX,
112  double * const dObj,
113  double * const daC,
114  void * userParams);
115  int evalGA (const double * const daX,
116  double * const daG,
117  double * const daJ,
118  void * userParams);
119  int evalH (const double * const daX,
120  const double * const daLambda,
121  double * const daH,
122  void * userParams);
123  int evalHV (const double * const daX,
124  const double * const daLambda,
125  double * const daHV,
126  void * userParams);
127 
128  std::string knitroErrorMsg;
129 };
130 
131 
145 {
146 
147 public:
148 
150  KnitroSolver();
151 
153  ~KnitroSolver();
154 
159  virtual void buildSolverInstance();
160 
165  virtual void setSolverOptions();
166 
169  virtual void solve();
170 
176  void dataEchoCheck();
177 
178 private:
179 
181 
193  // KnitroSolver();
197  std::string knitroErrorMsg;
198 
199 };
200 
201 
202 #endif
This file defines the OSnLNode class along with its derived classes.
The Default Solver Class.
int evalGA(const double *const daX, double *const daG, double *const daJ, void *userParams)
int evalFC(const double *const daX, double *const dObj, double *const daC, void *userParams)
std::string knitroErrorMsg
OSInstance * osinstance
int evalHV(const double *const daX, const double *const daLambda, double *const daHV, void *userParams)
int evalH(const double *const daX, const double *const daLambda, double *const daH, void *userParams)
KnitroProblem(OSInstance *osinstance_, OSResult *osresult_)
the IpoptProblemclass constructor
OSResult * osresult
void getInitialX(double *const daX)
bool areDerivativesImplemented(const DerivativesImplementedType nWhichDers)
virtual ~KnitroProblem()
the IpoptProblem class destructor
bool loadProblemIntoKnitro(KTR_context_ptr kc)
Define the fixed problem definition information and pass it to KNITRO by calling KTR_init_problem.
the KnitroSolver class solves problems using Knitro.
KnitroSolver()
the KnitroSolver class constructor
virtual void solve()
solve results in an instance being read into the Knitro data structrues and optimized
virtual void buildSolverInstance()
buildSolverInstance is a virtual function – the actual solvers will implement their own buildSolverIn...
KnitroSolver & operator=(const KnitroSolver &)
virtual void setSolverOptions()
The implementation of the virtual functions.
void dataEchoCheck()
use this for debugging, print out the instance that the solver thinks it has and compare this with th...
OSrLWriter * osrlwriter
KnitroSolver(const KnitroSolver &)
~KnitroSolver()
the KnitroSolver class constructor
std::string knitroErrorMsg
The in-memory representation of an OSiL instance..
Definition: OSInstance.h:2263
The Result Class.
Definition: OSResult.h:2549
Take an OSResult object and write a string that validates against OSrL.
Definition: OSrLWriter.h:31