snopt.h

Go to the documentation of this file.
00001 // Copyright (C) 2006 Ivo Nowak and Stefan Vigerske
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Author: Stefan Vigerske
00006 
00007 // snopt.h
00008 // C++ interface to SNOPT
00009 
00010 #ifdef SNOPT_AVAILABLE
00011 #ifndef SNOPT_H
00012 #define SNOPT_H
00013 
00014 #include "standard.h"
00015 #include "opt.h"
00016 #include "problem.h"
00017 #include "param.h"
00018 #include "usermatrix.h"
00019 
00020 #ifdef NOUNDERSCORE
00021 #define FUNCON funcon
00022 #define FUNOBJ funobj
00023 #else
00024 #define FUNCON funcon_
00025 #define FUNOBJ funobj_
00026 #endif
00027 
00028 extern bool snoptlicenceok;
00029 
00045 extern "C" void FUNOBJ (
00046       int& mode, int& nnObj,
00047       double* x, double& fObj, double* gObj, int& nState,
00048       char* cu, int& lencu,
00049       int* iu, int& leniu,
00050       double* ru, int& lenru );
00051 
00069 extern "C" void FUNCON (
00070       int& mode, int& nnCon, int& nnJac, int& neJac,
00071       double* x, double* fCon,
00072       double* gCon, int &nState,
00073       char* cu, int& lencu,
00074       int* iu, int& leniu,
00075       double* ru, int& lenru );
00076 
00093 class SnOpt : public LocOpt {
00094         friend void FUNOBJ (
00095       int& mode, int& nnObj,
00096       double* x, double& fObj, double* gObj, int& nState,
00097       char* cu, int& lencu,
00098       int* iu, int& leniu,
00099       double* ru, int& lenru );
00100         friend void FUNCON (
00101       int& mode, int& nnCon, int& nnJac, int& neJac,
00102       double* x, double* fCon,
00103       double* gCon, int &nState,
00104       char* cu, int& lencu,
00105       int* iu, int& leniu,
00106       double* ru, int& lenru );
00107   private:
00110     const Pointer<MinlpProblem> minlp;
00111 
00114     Pointer<Param> param;
00115 
00116     Pointer<char> param_name;
00117     int param_prefix_end;
00118 
00121                 list<int> nonlin_con;
00124                 list<int> lin_con;
00127                 list<int> nonlin_block_conobj;
00130                 list<int> nonlin_block_cononly;
00133                 list<int> nonlin_block_objonly;
00136                 list<int> lin_block;
00137 
00141                 list<int> all_block;
00142 
00145     Pointer<char> Specsfile;
00146     int Specsfileid; // the fortran-id of the specsfile
00147 
00150     Pointer<char> Printfile;
00151     int Printfileid;  // the fortran-id of the printfile
00152 
00155     Pointer<char> Summaryfile;
00156     int Summaryfileid; // the fortran-id of the summaryfile
00157 
00161     Pointer<char> start;
00162 
00163     /* Number of constraints.
00164     */
00165     int m;
00166 
00167     /* Number of variables excluding slacks (n>0)
00168     */
00169     int n;
00170 
00173     int ne;
00174 
00178     int nnCon;
00179 
00182     int nnObj;
00183 
00187     int nnJac;
00188 
00192     int iObj;
00193 
00196     double ObjAdd;
00197 
00200     Pointer<double> a;
00203     Pointer<int> ha;
00207     Pointer<int> ka;
00208 
00211     Pointer<double> bl;
00214     Pointer<double> bu;
00215 
00218     Pointer<int> hs;
00222     Pointer<double> xs;
00223 
00226     Pointer<double> pi;
00227 
00230     int lencw;
00233     int leniw;
00236     int lenrw;
00239     Pointer<char> cw;
00242     Pointer<int> iw;
00245     Pointer<double> rw;
00246 
00249     Pointer<double> rc;
00250 
00253     void sort();
00254 
00255                 void init_jacobian();
00256 
00257                 void init_bounds();
00258 
00259                 void init();
00260 
00261                 bool nnobj(double& val, double* grad, int mode, const double* x);
00262 
00263                 bool nncon(double* val, double* grad, int mode, const double* x);
00264 
00265   public:
00272     SnOpt(const Pointer<MinlpProblem> p_, Pointer<Param> param_=NULL, char* param_prefix=NULL, Pointer<ostream> out_solver_p_=out_out_p, Pointer<ostream> out_solver_log_p_=out_log_p);
00273 
00277     ~SnOpt();
00278 
00282                 void reinit();
00283 
00288     int solve();
00289 
00297     int solve(dvector &x);
00298 
00302     dvector get_lag_multipliers();
00303 
00304     dvector get_mu_q();
00305 };
00306 
00307 #endif // SNOPT_H
00308 #endif // SNOPT_AVAILABLE

Generated on Mon Oct 20 03:12:06 2008 for LaGO by  doxygen 1.4.7