FFSM++  1.1.0
French Forest Sector Model ++
Adolc_debugtest.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------
2  ADOL-C -- Automatic Differentiation by Overloading in C++
3  File: ADOL-C_NLP.hpp
4  Revision: $$
5  Contents: class myADOL-C_NPL for interfacing with Ipopt
6 
7  Copyright (c) Andrea Walther
8 
9  This file is part of ADOL-C. This software is provided as open source.
10  Any use, reproduction, or distribution of the software constitutes
11  recipient's acceptance of the terms of the accompanying license file.
12 
13  This code is based on the file MyNLP.hpp contained in the Ipopt package
14  with the authors: Carl Laird, Andreas Waechter
15 ----------------------------------------------------------------------------*/
16 
17 //*************************************************************************
18 //
19 //
20 // Nothing has to be changed in this file !!
21 //
22 //
23 //*************************************************************************
24 
25 #ifndef __MYADOLCNLP_HPP__
26 #define __MYADOLCNLP_HPP__
27 
28 #include "IpTNLP.hpp"
29 #include <adolc.h>
30 
31 #define tag_f 1
32 #define tag_g 2
33 #define tag_L 3
34 
35 using namespace Ipopt;
36 
37 class MyADOLC_NLP : public TNLP
38 {
39 public:
40  /** default constructor */
41  MyADOLC_NLP();
42 
43  /** default destructor */
44  virtual ~MyADOLC_NLP();
45 
46  /**@name Overloaded from TNLP */
47  //@{
48  /** Method to return some info about the nlp */
49  virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
50  Index& nnz_h_lag, IndexStyleEnum& index_style);
51 
52  /** Method to return the bounds for my problem */
53  virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
54  Index m, Number* g_l, Number* g_u);
55 
56  /** Method to return the starting point for the algorithm */
57  virtual bool get_starting_point(Index n, bool init_x, Number* x,
58  bool init_z, Number* z_L, Number* z_U,
59  Index m, bool init_lambda,
60  Number* lambda);
61 
62  /** Template to return the objective value */
63  template<class T> bool eval_obj(Index n, const T *x, T& obj_value);
64 
65 
66  /** Template to compute contraints */
67  template<class T> bool eval_constraints(Index n, const T *x, Index m, T *g);
68 
69  /** Original method from Ipopt to return the objective value */
70  /** remains unchanged */
71  virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
72 
73  /** Original method from Ipopt to return the gradient of the objective */
74  /** remains unchanged */
75  virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
76 
77  /** Original method from Ipopt to return the constraint residuals */
78  /** remains unchanged */
79  virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
80 
81  /** Original method from Ipopt to return:
82  * 1) The structure of the jacobian (if "values" is NULL)
83  * 2) The values of the jacobian (if "values" is not NULL)
84  */
85  /** remains unchanged */
86  virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
87  Index m, Index nele_jac, Index* iRow, Index *jCol,
88  Number* values);
89 
90  /** Original method from Ipopt to return:
91  * 1) The structure of the hessian of the lagrangian (if "values" is NULL)
92  * 2) The values of the hessian of the lagrangian (if "values" is not NULL)
93  */
94  /** remains unchanged */
95  virtual bool eval_h(Index n, const Number* x, bool new_x,
96  Number obj_factor, Index m, const Number* lambda,
97  bool new_lambda, Index nele_hess, Index* iRow,
98  Index* jCol, Number* values);
99 
100  //@}
101 
102  /** @name Solution Methods */
103  //@{
104  /** This method is called when the algorithm is complete so the TNLP can store/write the solution */
105  virtual void finalize_solution(SolverReturn status,
106  Index n, const Number* x, const Number* z_L, const Number* z_U,
107  Index m, const Number* g, const Number* lambda,
108  Number obj_value,
109  const IpoptData* ip_data,
110  IpoptCalculatedQuantities* ip_cq);
111  //@}
112 
113 //*************** start ADOL-C part ***********************************
114 
115  /** Method to generate the required tapes */
116  virtual void generate_tapes(Index n, Index m);
117 
118 //*************** end ADOL-C part ***********************************
119 
120 private:
121  /**@name Methods to block default compiler methods.
122  * The compiler automatically generates the following three methods.
123  * Since the default compiler implementation is generally not what
124  * you want (for all but the most simple classes), we usually
125  * put the declarations of these methods in the private section
126  * and never implement them. This prevents the compiler from
127  * implementing an incorrect "default" behavior without us
128  * knowing. (See Scott Meyers book, "Effective C++")
129  *
130  */
131  //@{
132  // MyADOLC_NLP();
133  MyADOLC_NLP(const MyADOLC_NLP&);
134  MyADOLC_NLP& operator=(const MyADOLC_NLP&);
135  //@}
136 
137  //@{
138  double **Jac;
139 
140  double *x_lam;
141  double **Hess;
142  //@}
143 
144 };
145 
146 #endif
double * x_lam
double ** Hess
double ** Jac