OS  2.9.3
OSKnitroSolver.h
Go to the documentation of this file.
1 /* $Id: OSKnitroSolver.h 4960 2015-02-23 00:40:11Z tkr $ */
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 #ifdef OS_HAS_CPPAD
52 # include <cppad/cppad.hpp>
53 #endif
54 #include<iostream>
55 
56 
57 #ifdef HAVE_CTIME
58 # include <ctime>
59 #else
60 # ifdef HAVE_TIME_H
61 # include <time.h>
62 # else
63 # error "don't have header file for time"
64 # endif
65 #endif
66 
67 
68 #ifdef HAVE_CMATH
69 # include <cmath>
70 #else
71 # ifdef HAVE_MATH_H
72 # include <math.h>
73 # else
74 # error "don't have header file for math"
75 # endif
76 #endif
77 
78 
79 
80 //#include<vector>
81 //#include <map>
82 
83 
84 
85 class KnitroProblem : public NlpProblemDef
86 {
87 public:
88 
90  KnitroProblem(OSInstance *osinstance_ , OSResult *osresult_);
91 
93  virtual ~KnitroProblem();
94 
96 
98 
99  //Knitro specific methods
100  //++ Declare virtual base class methods that are implemented here.
101  //++ See NlpProblemDef.h for descriptions.
102  int getN (void);
103  int getM (void);
104  void getInitialX (double * const daX);
105  bool loadProblemIntoKnitro (KTR_context_ptr kc);
107  (const DerivativesImplementedType nWhichDers);
108 
109  int evalFC (const double * const daX,
110  double * const dObj,
111  double * const daC,
112  void * userParams);
113  int evalGA (const double * const daX,
114  double * const daG,
115  double * const daJ,
116  void * userParams);
117  int evalH (const double * const daX,
118  const double * const daLambda,
119  double * const daH,
120  void * userParams);
121  int evalHV (const double * const daX,
122  const double * const daLambda,
123  double * const daHV,
124  void * userParams);
125 
126  std::string knitroErrorMsg;
127 };
128 
129 
143 {
144 
145 public:
146 
148  KnitroSolver();
149 
151  ~KnitroSolver();
152 
157  virtual void buildSolverInstance() throw(ErrorClass);
158 
163  virtual void setSolverOptions() throw(ErrorClass);
164 
167  virtual void solve() throw (ErrorClass) ;
168 
174  void dataEchoCheck();
175 
176 private:
177 
178  OSrLWriter *osrlwriter;
179 
191  // KnitroSolver();
192  KnitroSolver(const KnitroSolver&);
193  KnitroSolver& operator=(const KnitroSolver&);
195  std::string knitroErrorMsg;
196 
197 };
198 
199 
200 #endif
used for throwing exceptions.
Definition: OSErrorClass.h:31
int evalGA(const double *const daX, double *const daG, double *const daJ, void *userParams)
int getM(void)
Take an OSResult object and write a string that validates against OSrL.
Definition: OSrLWriter.h:30
virtual void solve()
solve results in an instance being read into the Knitro data structrues and optimized ...
bool loadProblemIntoKnitro(KTR_context_ptr kc)
KnitroProblem(OSInstance *osinstance_, OSResult *osresult_)
the IpoptProblemclass constructor
~KnitroSolver()
the KnitroSolver class constructor
int evalFC(const double *const daX, double *const dObj, double *const daC, void *userParams)
OSResult * osresult
OSInstance * osinstance
the KnitroSolver class solves problems using Knitro.
virtual void setSolverOptions()
The implementation of the virtual functions.
The in-memory representation of an OSiL instance.
Definition: OSInstance.h:2241
void getInitialX(double *const daX)
This file defines the OSInstance class along with its supporting classes.
virtual void buildSolverInstance()
buildSolverInstance is a virtual function – the actual solvers will implement their own buildSolverI...
std::string knitroErrorMsg
This file defines the OSnLNode class along with its derived classes.
int evalHV(const double *const daX, const double *const daLambda, double *const daHV, void *userParams)
void dataEchoCheck()
use this for debugging, print out the instance that the solver thinks it has and compare this with th...
bool areDerivativesImplemented(const DerivativesImplementedType nWhichDers)
int evalH(const double *const daX, const double *const daLambda, double *const daH, void *userParams)
The Default Solver Class.
int getN(void)
virtual ~KnitroProblem()
the IpoptProblem class destructor
The Result Class.
Definition: OSResult.h:2312
KnitroSolver()
the KnitroSolver class constructor