DOpE
snopt_wrapper.h
Go to the documentation of this file.
1 
24 #ifndef SNOPT_WRAPPER_
25 #define SNOPT_WRAPPER_
26 
27 #ifdef WITH_SNOPT
28 //BEGIN DONOT_TOUCH
29 //The following code is sensitive to ordering
30 //due to some bugs in f2c and snopt
31 //please do not touch this unless you are very
32 //sure of what you are doing! And even then---don't.
33 //If you do something wrong here your code may compile
34 //and then fail if you include some other headers you
35 //may additionally need for no apparent reason with no
36 //reasonable compiler warning whatsoever.
37 // You have been warned: HERE BE DRAGONS!
38 #include "snopt.hh"
39 #include "snfilewrapper.hh"
40 #include "snoptProblem.hh"
42 #undef abs
43 #undef dabs
44 #undef min
45 #undef max
46 #undef dmin
47 #undef dmax
48 #undef bit_test
49 #undef bit_clear
50 #undef bit_set
51 //END OF f2c BUGFIX
52 //END DONOT_TOUCH
53 
54 #include <boost/function.hpp>
55 
56 namespace DOpEWrapper
57 {
70  struct SNOPT_FUNC_DATA{
71  integer *Status; integer *n; doublereal* x;
72  integer *needF; integer *neF; doublereal* F;
73  integer *needG; integer *neG; doublereal* G;
74  char *cu; integer *lencu;
75  integer *iu; integer *leniu;
76  doublereal *ru; integer *lenru;
77  };
78 
88  boost::function1<int, SNOPT_FUNC_DATA&> SNOPT_A_userfunc_interface;
89  int SNOPT_A_userfunc_(integer *Status, integer *n, doublereal x[],
90  integer *needF, integer *neF, doublereal F[],
91  integer *needG, integer *neG, doublereal G[],
92  char *cu, integer *lencu,
93  integer iu[], integer *leniu,
94  doublereal ru[], integer *lenru )
95  {
96  SNOPT_FUNC_DATA data;
97  data.Status = Status;
98  data.n = n;
99  data.x = x;
100  data.needF = needF;
101  data.neF = neF;
102  data.F = F;
103  data.needG = needG;
104  data.neG = neG;
105  data.G = G;
106  data.cu = cu;
107  data.lencu = lencu;
108  data.iu = iu;
109  data.leniu = leniu;
110  data.ru = ru;
111  data.lenru = lenru;
112 
113  if(SNOPT_A_userfunc_interface)
114  return SNOPT_A_userfunc_interface(data);
115  else
116  throw DOpE::DOpEException("The boost::function SNOPT_userfunc_interface has not been declared","DOpEWrapper::SNOPT::dope_snopt_userfunc_");
117  }
118 
124  class SNOPT_Problem : public snoptProblem
125  {
126  public:
127  int GetReturnStatus() { return snoptProblem::inform; }
128  };
129 }
130 #endif //Endof WITH_SNOPT
131 #endif //Endof File
Definition: dopeexception.h:35