OS  2.10.2
OSKnitroSolver.h
Go to the documentation of this file.
1 /* $Id: OSKnitroSolver.h 5284 2017-12-08 13:52:50Z stefan $ */
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() throw(ErrorClass);
160 
165  virtual void setSolverOptions() throw(ErrorClass);
166 
169  virtual void solve() throw (ErrorClass) ;
170 
176  void dataEchoCheck();
177 
178 private:
179 
180  OSrLWriter *osrlwriter;
181 
193  // KnitroSolver();
194  KnitroSolver(const KnitroSolver&);
195  KnitroSolver& operator=(const KnitroSolver&);
197  std::string knitroErrorMsg;
198 
199 };
200 
201 
202 #endif
OSConfig.h
OSExpressionTree.h
KnitroProblem::areDerivativesImplemented
bool areDerivativesImplemented(const DerivativesImplementedType nWhichDers)
OSDataStructures.h
KnitroSolver::setSolverOptions
virtual void setSolverOptions()
The implementation of the virtual functions.
OSErrorClass.h
KnitroProblem::getN
int getN(void)
KnitroProblem::getInitialX
void getInitialX(double *const daX)
KnitroProblem::~KnitroProblem
virtual ~KnitroProblem()
the IpoptProblem class destructor
OSrLWriter.h
OSInstance
The in-memory representation of an OSiL instance..
Definition: OSInstance.h:2262
OSrLWriter
Take an OSResult object and write a string that validates against OSrL.
Definition: OSrLWriter.h:30
KnitroSolver::KnitroSolver
KnitroSolver()
the KnitroSolver class constructor
KnitroProblem::KnitroProblem
KnitroProblem(OSInstance *osinstance_, OSResult *osresult_)
the IpoptProblemclass constructor
KnitroSolver::~KnitroSolver
~KnitroSolver()
the KnitroSolver class constructor
KnitroSolver::solve
virtual void solve()
solve results in an instance being read into the Knitro data structrues and optimized
OSInstance.h
This file defines the OSInstance class along with its supporting classes.
KnitroSolver
the KnitroSolver class solves problems using Knitro.
Definition: OSKnitroSolver.h:144
KnitroProblem::osinstance
OSInstance * osinstance
Definition: OSKnitroSolver.h:99
OSFileUtil.h
OSiLWriter.h
OSiLReader.h
KnitroProblem::evalGA
int evalGA(const double *const daX, double *const daG, double *const daJ, void *userParams)
OSResult
The Result Class.
Definition: OSResult.h:2548
KnitroSolver::buildSolverInstance
virtual void buildSolverInstance()
buildSolverInstance is a virtual function – the actual solvers will implement their own buildSolverIn...
OSDefaultSolver.h
KnitroProblem::evalH
int evalH(const double *const daX, const double *const daLambda, double *const daH, void *userParams)
ErrorClass
used for throwing exceptions.
Definition: OSErrorClass.h:31
KnitroProblem::evalFC
int evalFC(const double *const daX, double *const dObj, double *const daC, void *userParams)
KnitroProblem::knitroErrorMsg
std::string knitroErrorMsg
Definition: OSKnitroSolver.h:128
KnitroProblem
Definition: OSKnitroSolver.h:87
KnitroProblem::osresult
OSResult * osresult
Definition: OSKnitroSolver.h:97
KnitroProblem::evalHV
int evalHV(const double *const daX, const double *const daLambda, double *const daHV, void *userParams)
KnitroProblem::loadProblemIntoKnitro
bool loadProblemIntoKnitro(KTR_context_ptr kc)
KnitroSolver::dataEchoCheck
void dataEchoCheck()
use this for debugging, print out the instance that the solver thinks it has and compare this with th...
KnitroProblem::getM
int getM(void)
DefaultSolver
The Default Solver Class.
Definition: OSDefaultSolver.h:35
OSParameters.h
OSnLNode.h
This file defines the OSnLNode class along with its derived classes.