ipopt2.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 #define IPOPT_AVAILABLE
00008 #ifdef IPOPT_AVAILABLE
00009 #ifndef IPOPT_H
00010 #define IPOPT_H
00011 
00012 #include "standard.h"
00013 #include "opt.h"
00014 #include "problem.h"
00015 #include "param.h"
00016 
00017 #include "IpIpoptApplication.hpp"
00018 #include "IpTNLP.hpp"
00019 #include "IpSolveStatistics.hpp"
00020 
00021 using namespace Ipopt;
00022 
00023 class IpOpt;
00024 
00025 class IpOptProblem : public TNLP {
00026         friend class IpOpt;
00027         private:
00028                 const Pointer<MinlpProblem> prob;
00029 
00030                 IpOpt& ipopt;
00031 
00032                 vector<Pointer<SparsityInfo> > sparsity;
00033                 Index nnz_jac_g;
00034                 Index nnz_h_lag;
00035 
00043                 template <bool add>
00044                 void set_hessian(const SepQcFunc& func, int blocknr, Number* values, double factor, dvector& xx, dvector& y, dvector& z);
00045 
00050                 template <bool add>
00051                 void set_hessianquad(const SepQcFunc& func, int blocknr, Number* values, double factor);
00052 
00053         public:
00054                 IpOptProblem(const Pointer<MinlpProblem> prob_, IpOpt& ipopt);
00055 
00057                 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00058                                                 Index& nnz_h_lag, IndexStyleEnum &index_style);
00059 
00061                 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00062                                                         Index m, Number* g_l, Number* g_u);
00063 
00065                 virtual bool get_starting_point(Index n, bool init_x, Number* x,
00066                                                                                                                                                         bool init_z, Number* z_L, Number* z_U,
00067                                                                                                                                                         Index m, bool init_lambda, Number* lambda);
00068 
00070                 virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
00071 
00073                 virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
00074 
00076                 virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
00077 
00082                 virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00083                                         Index m, Index nele_jac, Index* iRow, Index *jCol,
00084                                         Number* values);
00085 
00090                 virtual bool eval_h(Index n, const Number* x, bool new_x,
00091                                                 Number obj_factor, Index m, const Number* lambda,
00092                                                 bool new_lambda, Index nele_hess, Index* iRow,
00093                                                 Index* jCol, Number* values);
00094 
00096                 virtual void finalize_solution(SolverReturn status,
00097                                         Index n, const Number* x, const Number* z_L, const Number* z_U,
00098                                         Index m, const Number* g, const Number* lambda,
00099                                         Number obj_values, const IpoptData* data, IpoptCalculatedQuantities* cq);
00100 
00101 };
00102 
00103 class IpOpt : public LocOpt {
00104         friend class IpOptProblem;
00105         private:
00106                 Pointer<Param> param;
00107 
00108                 SmartPtr<IpoptApplication> ipopt;
00109                 SmartPtr<TNLP> ipoptproblem;
00110 
00111                 dvector lambda;
00112 
00113         public:
00114                 IpOpt(const Pointer<MinlpProblem> prob_, Pointer<Param> param_, Pointer<ostream> out_solver_p_=out_out_p, Pointer<ostream> out_solver_log_p_=out_log_p);
00115 
00116                 ~IpOpt() {}
00117 
00118                 void reinit();
00119 
00120                 int solve();
00121                 int solve(dvector& start);
00122                 dvector get_lag_multipliers() { return lambda; }
00123 
00124 };
00125 
00126 #endif
00127 #endif

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