- Main Page
- Classes
- Files

- File List
- File Members

# tutorial/CodingExercise/Cpp/3-solution/TutorialCpp_nlp.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2009 International Business Machines.
    00002 // All Rights Reserved.
    00003 // This code is published under the Eclipse Public License.
    00004 //
    00005 // $Id: TutorialCpp_nlp.hpp 1861 2010-12-21 21:34:47Z andreasw $
    00006 //
    00007 // Author:  Andreas Waechter               IBM    2009-04-02
    00008
    00009 // This file is part of the Ipopt tutorial.  It is a correct version
    00010 // of a C++ implemention of the coding exercise problem (in AMPL
    00011 // formulation):
    00012 //
    00013 // param n := 4;
    00014 //
    00015 // var x {1..n} <= 0, >= -1.5, := -0.5;
    00016 //
    00017 // minimize obj:
    00018 //   sum{i in 1..n} (x[i]-1)^2;
    00019 //
    00020 // subject to constr {i in 2..n-1}:
    00021 //   (x[i]^2+1.5*x[i]-i/n)*cos(x[i+1]) - x[i-1] = 0;
    00022 //
    00023 // The constant term "i/n" in the constraint is supposed to be input data
    00024 //
    00025
    00026 #ifndef __TUTORIALCPP_NLP_HPP__
    00027 #define __TUTORIALCPP_NLP_HPP__
    00028
    00029 #include "IpTNLP.hpp"
    00030
    00031 using namespace Ipopt;
    00032
    00033 // This inherits from Ipopt's TNLP
    00034 class TutorialCpp_NLP : public TNLP
    00035 {
    00036 public:
    00038   TutorialCpp_NLP(Index N, const Number* a);
    00039
    00041   virtual ~TutorialCpp_NLP();
    00042
    00046   virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
    00047                             Index& nnz_h_lag, IndexStyleEnum& index_style);
    00048
    00050   virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
    00051                                Index m, Number* g_l, Number* g_u);
    00052
    00054   virtual bool get_starting_point(Index n, bool init_x, Number* x,
    00055                                   bool init_z, Number* z_L, Number* z_U,
    00056                                   Index m, bool init_lambda,
    00057                                   Number* lambda);
    00058
    00060   virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
    00061
    00063   virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
    00064
    00066   virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
    00067
    00072   virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
    00073                           Index m, Index nele_jac, Index* iRow, Index *jCol,
    00074                           Number* values);
    00075
    00080   virtual bool eval_h(Index n, const Number* x, bool new_x,
    00081                       Number obj_factor, Index m, const Number* lambda,
    00082                       bool new_lambda, Index nele_hess, Index* iRow,
    00083                       Index* jCol, Number* values);
    00084
    00086
    00090   virtual void finalize_solution(SolverReturn status,
    00091                                  Index n, const Number* x, const Number* z_L, const Number* z_U,
    00092                                  Index m, const Number* g, const Number* lambda,
    00093                                  Number obj_value,
    00094                  const IpoptData* ip_data,
    00095                  IpoptCalculatedQuantities* ip_cq);
    00097
    00098 private:
    00110   TutorialCpp_NLP();
    00111   TutorialCpp_NLP(const TutorialCpp_NLP&);
    00112   TutorialCpp_NLP& operator=(const TutorialCpp_NLP&);
    00114
    00118   Index N_;
    00120   Number* a_;
    00122 };
    00123
    00124
    00125 #endif

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines