20 #ifndef __MAST_snopt_optimization_interface_h__ 21 #define __MAST_snopt_optimization_interface_h__ 33 #include <libmesh/parallel.h> 37 extern void sninit_(
int* iPrint,
46 extern void sninitf_(
const char* printfile,
47 const char* summary_file,
57 extern void snspec_(
int* iSpecs,
66 extern void snspecf_(
const char* specsfile,
114 extern void npoptn_(
const char*,
int );
119 namespace Optimization {
141 template <
typename FunctionEvaluationType>
153 #if MAST_ENABLE_SNOPT == 0 154 Error(
false,
"MAST configured without SNOPT support.");
158 _exit_message[10] =
" The problem appears to be infeasible 20 The problem appears to be unbounded 30 Resource limit error";
159 _exit_message[40] =
" Terminated after numerical difficulties 50 Error in the user-supplied functions";
164 _exit_message[100] =
" Finished successfully (associated with SNOPT auxiliary routines) 110 Errors while processing MPS data";
165 _exit_message[120] =
" Errors while estimating Jacobian structure";
171 _info_message[3] =
"requested accuracy could not be achieved";
173 _info_message[12] =
"infeasible linear equality constraints";
176 _info_message[15] =
"infeasible linear constraints in QP subproblem";
185 _info_message[43] =
"cannot satisfy the general constraints";
189 _info_message[56] =
"irregular or badly scaled problem functions";
190 _info_message[61] =
"undefined function at the first feasible point";
191 _info_message[62] =
"undefined function at the initial point";
192 _info_message[63] =
"unable to proceed into undefined region";
194 _info_message[72] =
"terminated during constraint evaluation";
195 _info_message[73] =
"terminated during objective evaluation";
197 _info_message[81] =
"work arrays must have at least 500 elements";
202 _info_message[92] =
"basis file dimensions do not match this problem";
212 #if MAST_ENABLE_SNOPT == 1 216 _funobj = feval.get_objective_evaluation_function();
217 _funcon = feval.get_constraint_evaluation_function();
242 #if MAST_ENABLE_SNOPT == 1 255 NCTOTL = N+NCLIN+NCNLN,
256 LDA = std::max(NCLIN, 1),
257 LDJ = std::max(NCNLN, 1),
270 LENIW = std::max(1200*(NCTOTL+N) ,1000),
271 LENW = std::max(2400*(NCTOTL+N), 1000);
293 CLAMBDA (NCTOTL, 0.),
306 _feval->init_dvar(X, xmin, xmax);
307 for (
unsigned int i=0; i<N; i++) {
314 for (
unsigned int i=0; i<NCNLN; i++) {
319 std::string cw(lencw*8,
' ');
334 snspec_(&iSpec, &INFORM, cw.c_str(), &lencw, &IW[0], &LENIW, &W[0], &LENW);
336 Error(INFORM != 101,
"INFORM == 101. Stopping");
366 #endif // MAST_ENABLE_SNOPT 1 375 exit = (INFORM%10)*10;
381 <<
"SNOPT EXIT :" << exit << std::endl
383 <<
" INFO :" << INFORM << std::endl
405 libMesh::Parallel::Communicator &
_comm;
418 #endif // __MAST_snopt_optimization_interface_h__
void(* _funcon)(int *mode, int *ncnln, int *n, int *ldJ, int *needc, double *x, double *c, double *cJac, int *nstate)
void sninit_(int *iPrint, int *iSumm, const char *cw, int *lencw, int *iw, int *leniw, double *rw, int *lenrw)
void npoptn_(const char *, int)
void snspec_(int *iSpecs, int *INFO, const char *cw, int *lencw, int *iw, int *leniw, double *rw, int *lenrw)
SNOPTInterface(libMesh::Parallel::Communicator &comm)
std::map< int, std::string > _exit_message
void set_function_evaluation(FunctionEvaluationType &feval)
virtual ~SNOPTInterface()
FunctionEvaluationType * _feval
libMesh::Parallel::Communicator & _comm
void npopt_(int *n, int *nclin, int *ncnln, int *ldA, int *ldgg, int *ldH, double *A, double *bl, double *bu, void(*)(int *mode, int *ncnln, int *n, int *ldJ, int *needc, double *x, double *c, double *cJac, int *nstate), void(*)(int *mode, int *n, double *x, double *f, double *g, int *nstate), int *INFO, int *majIts, int *iState, double *fCon, double *gCon, double *cMul, double *fObj, double *gObj, double *Hess, double *x, int *iw, int *leniw, double *re, int *lenrw)
void(* funcon)(int *mode, int *ncnln, int *n, int *ldJ, int *needc, double *x, double *c, double *cJac, int *nstate)
void init()
initializes the design variable vector from the function object.
void snspecf_(const char *specsfile, int *INFO, const char *cw, int *lencw, int *iw, int *leniw, double *rw, int *lenrw)
#define Assert0(cond, msg)
std::vector< real_t > _XVAL
void _print_termination_message(const int INFORM)
void(* funobj)(int *mode, int *n, double *x, double *f, double *g, int *nstate)
std::map< int, std::string > _info_message
std::vector< real_t > _XMAX
void sninitf_(const char *printfile, const char *summary_file, int *iPrint, int *iSumm, const char *cw, int *lencw, int *iw, int *leniw, double *rw, int *lenrw)
std::vector< real_t > _XMIN
void(* _funobj)(int *mode, int *n, double *x, double *f, double *g, int *nstate)