FFSM++  1.1.0
French Forest Sector Model ++
Ipopt_nlp_problem_debugtest.h
Go to the documentation of this file.
1 #ifndef IPOPT_NLP_PROBLEM_DEBUGTEST_H
2 #define IPOPT_NLP_PROBLEM_DEBUGTEST_H
3 
4 #include "IpTNLP.hpp"
5 
6 using namespace Ipopt;
7 
8 /** C++ Example NLP for interfacing a problem with IPOPT.
9  * HS071_NLP implements a C++ example of problem 71 of the
10  * Hock-Schittkowski test suite. This example is designed to go
11  * along with the tutorial document and show how to interface
12  * with IPOPT through the TNLP interface.
13  *
14  * Problem hs071 looks like this
15  *
16  * min x1*x4*(x1 + x2 + x3) + x3
17  * s.t. x1*x2*x3*x4 >= 25
18  * x1**2 + x2**2 + x3**2 + x4**2 = 40
19  * 1 <= x1,x2,x3,x4 <= 5
20  *
21  * Starting point:
22  * x = (1, 5, 5, 1)
23  *
24  * Optimal solution:
25  * x = (1.00000000, 4.74299963, 3.82114998, 1.37940829)
26  *
27  *
28  */
29 class Ipopt_nlp_problem_debugtest : public TNLP
30 {
31 public:
32  /** default constructor */
34 
35  /** default destructor */
36  virtual ~Ipopt_nlp_problem_debugtest();
37 
38  /**@name Overloaded from TNLP */
39  //@{
40  /** Method to return some info about the nlp */
41  virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
42  Index& nnz_h_lag, IndexStyleEnum& index_style);
43 
44  /** Method to return the bounds for my problem */
45  virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
46  Index m, Number* g_l, Number* g_u);
47 
48  /** Method to return the starting point for the algorithm */
49  virtual bool get_starting_point(Index n, bool init_x, Number* x,
50  bool init_z, Number* z_L, Number* z_U,
51  Index m, bool init_lambda,
52  Number* lambda);
53 
54  /** Method to return the objective value */
55  virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
56 
57  /** Method to return the gradient of the objective */
58  virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
59 
60  /** Method to return the constraint residuals */
61  virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
62 
63  /** Method to return:
64  * 1) The structure of the jacobian (if "values" is NULL)
65  * 2) The values of the jacobian (if "values" is not NULL)
66  */
67  virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
68  Index m, Index nele_jac, Index* iRow, Index *jCol,
69  Number* values);
70 
71 
72  /** Method to return:
73  * 1) The structure of the hessian of the lagrangian (if "values" is NULL)
74  * 2) The values of the hessian of the lagrangian (if "values" is not NULL)
75  */
76 
77  virtual bool eval_h(Index n, const Number* x, bool new_x,
78  Number obj_factor, Index m, const Number* lambda,
79  bool new_lambda, Index nele_hess, Index* iRow,
80  Index* jCol, Number* values);
81 
82  //@}
83 
84  /** @name Solution Methods */
85  //@{
86  /** This method is called when the algorithm is complete so the TNLP can store/write the solution */
87  virtual void finalize_solution(SolverReturn status,
88  Index n, const Number* x, const Number* z_L, const Number* z_U,
89  Index m, const Number* g, const Number* lambda,
90  Number obj_value,
91  const IpoptData* ip_data,
92  IpoptCalculatedQuantities* ip_cq);
93  //@}
94 
95 private:
96  /**@name Methods to block default compiler methods.
97  * The compiler automatically generates the following three methods.
98  * Since the default compiler implementation is generally not what
99  * you want (for all but the most simple classes), we usually
100  * put the declarations of these methods in the private section
101  * and never implement them. This prevents the compiler from
102  * implementing an incorrect "default" behavior without us
103  * knowing. (See Scott Meyers book, "Effective C++")
104  *
105  */
106  //@{
107  // Ipopt_nlp_problem_debugtest();
110  //@}
111 };
112 
113 
114 #endif // IPOPT_NLP_PROBLEM_H