PaGMO  1.1.5
ipopt_problem.h
1 /*****************************************************************************
2  * Copyright (C) 2004-2015 The PaGMO development team, *
3  * Advanced Concepts Team (ACT), European Space Agency (ESA) *
4  * *
5  * https://github.com/esa/pagmo *
6  * *
7  * act@esa.int *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the *
21  * Free Software Foundation, Inc., *
22  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23  *****************************************************************************/
24 
25 #ifndef IPOPT_PROBLEM_H
26 #define IPOPT_PROBLEM_H
27 
28 #include <coin/IpTNLP.hpp>
29 #include "../../population.h"
30 #include "../../types.h"
31 #include "boost/array.hpp"
32 
33 
34 //Interface between Ipopt NLP and PaGMO problem
35 
36 class ipopt_problem : public Ipopt::TNLP
37 {
38 public:
40  ipopt_problem(pagmo::population *);
41 
43  virtual ~ipopt_problem();
44 
48  virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
49  Ipopt::Index& nnz_h_lag, IndexStyleEnum& index_style);
50 
52  virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
53  Ipopt::Index m, Ipopt::Number* g_l, Ipopt::Number* g_u);
54 
56  virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
57  bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
58  Ipopt::Index m, bool init_lambda,
59  Ipopt::Number* lambda);
60 
62  virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number& obj_value);
63 
65  virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number* grad_f);
66 
68  virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Index m, Ipopt::Number* g);
69 
74  virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
75  Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow, Ipopt::Index *jCol,
76  Ipopt::Number* values);
77 
79 
83  virtual void finalize_solution(Ipopt::SolverReturn status,
84  Ipopt::Index n, const Ipopt::Number* x, const Ipopt::Number* z_L, const Ipopt::Number* z_U,
85  Ipopt::Index m, const Ipopt::Number* g, const Ipopt::Number* lambda,
86  Ipopt::Number obj_value,
87  const Ipopt::IpoptData* ip_data,
88  Ipopt::IpoptCalculatedQuantities* ip_cq);
90 
91 private:
95  ipopt_problem();
96  ipopt_problem(const ipopt_problem&);
97  ipopt_problem& operator=(const ipopt_problem&);
99  //Points to a PaGMO population
100  ::pagmo::population *m_pop;
101  //Number of non-zero entries in the Jacbian
102  ::Ipopt::Index len_jac;
103  //Sparse representation of the Jacobian
104  std::vector< ::Ipopt::Index> iJfun,jJvar;
105  //Contains the variables that effect the objective function
106  std::vector< ::Ipopt::Index> affects_obj;
107  //Sorting criteria for the iJfun, jJvar entries to achieve constraint cache efficiency
108  static bool cache_efficiency_criterion(boost::array<int,2>,boost::array<int,2>);
109  // Internal caches used during evolution.
113 };
114 
115 
116 #endif
std::vector< double > decision_vector
Decision vector type.
Definition: types.h:40
Population class.
Definition: population.h:70
std::vector< double > fitness_vector
Fitness vector type.
Definition: types.h:42
std::vector< double > constraint_vector
Constraint vector type.
Definition: types.h:44