ipopt_adapter.h
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright (c) 2017, Alexander W. Winkler, ETH Zurich. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6  * Redistributions of source code must retain the above copyright notice,
7  this list of conditions and the following disclaimer.
8  * Redistributions in binary form must reproduce the above copyright notice,
9  this list of conditions and the following disclaimer in the documentation
10  and/or other materials provided with the distribution.
11  * Neither the name of ETH ZURICH nor the names of its contributors may be
12  used to endorse or promote products derived from this software without
13  specific prior written permission.
14 
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 DISCLAIMED. IN NO EVENT SHALL ETH ZURICH BE LIABLE FOR ANY DIRECT, INDIRECT,
19 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 ******************************************************************************/
26 
27 #ifndef IFOPT_INCLUDE_OPT_IPOPT_ADAPTER_H_
28 #define IFOPT_INCLUDE_OPT_IPOPT_ADAPTER_H_
29 
30 #include <IpTNLP.hpp>
31 #include <IpIpoptApplication.hpp>
32 #include <IpSolveStatistics.hpp>
33 
34 #include <ifopt/problem.h>
35 
42 namespace Ipopt {
43 
54 class IpoptAdapter : public TNLP {
55 public:
59 
66  IpoptAdapter(Problem& nlp, bool finite_diff = false);
67  virtual ~IpoptAdapter() = default;
68 
69 private:
71  bool finite_diff_;
72 
74  virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
75  Index& nnz_h_lag, IndexStyleEnum& index_style);
76 
78  virtual bool get_bounds_info(Index n, double* x_l, double* x_u,
79  Index m, double* g_l, double* g_u);
80 
82  virtual bool get_starting_point(Index n, bool init_x, double* x,
83  bool init_z, double* z_L, double* z_U,
84  Index m, bool init_lambda,
85  double* lambda);
86 
88  virtual bool eval_f(Index n, const double* x, bool new_x, double& obj_value);
89 
91  virtual bool eval_grad_f(Index n, const double* x, bool new_x, double* grad_f);
92 
94  virtual bool eval_g(Index n, const double* x, bool new_x, Index m, double* g);
95 
100  virtual bool eval_jac_g(Index n, const double* x, bool new_x,
101  Index m, Index nele_jac, Index* iRow, Index *jCol,
102  double* values);
103 
106  virtual bool intermediate_callback(AlgorithmMode mode,
107  Index iter, double obj_value,
108  double inf_pr, double inf_du,
109  double mu, double d_norm,
110  double regularization_size,
111  double alpha_du, double alpha_pr,
112  Index ls_trials,
113  const IpoptData* ip_data,
114  IpoptCalculatedQuantities* ip_cq);
115 
118  virtual void finalize_solution(SolverReturn status,
119  Index n, const double* x, const double* z_L, const double* z_U,
120  Index m, const double* g, const double* lambda,
121  double obj_value,
122  const IpoptData* ip_data,
123  IpoptCalculatedQuantities* ip_cq);
124 };
125 
126 } // namespace Ipopt
127 
128 #endif /* IFOPT_INCLUDE_OPT_IPOPT_ADAPTER_H_ */
A generic optimization problem with variables, costs and constraints.
Definition: problem.h:97
Solves the optimization problem using the IPOPT solver.
Definition: ipopt_adapter.h:54
Component::Jacobian Jacobian
Definition: problem.h:100
virtual bool eval_grad_f(Index n, const double *x, bool new_x, double *grad_f)
IpoptAdapter(Problem &nlp, bool finite_diff=false)
Creates an IpoptAdapter wrapping the nlp.
virtual bool get_bounds_info(Index n, double *x_l, double *x_u, Index m, double *g_l, double *g_u)
virtual bool get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)
Component::VectorXd VectorXd
Definition: problem.h:101
namespace defined by the Ipopt solver.
Definition: ipopt_adapter.h:42
virtual bool eval_f(Index n, const double *x, bool new_x, double &obj_value)
virtual void finalize_solution(SolverReturn status, Index n, const double *x, const double *z_L, const double *z_U, Index m, const double *g, const double *lambda, double obj_value, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
virtual ~IpoptAdapter()=default
Problem * nlp_
The solver independent problem definition.
Definition: ipopt_adapter.h:70
virtual bool eval_jac_g(Index n, const double *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, double *values)
Problem::VectorXd VectorXd
Definition: ipopt_adapter.h:57
virtual bool get_starting_point(Index n, bool init_x, double *x, bool init_z, double *z_L, double *z_U, Index m, bool init_lambda, double *lambda)
Problem::Jacobian Jacobian
Definition: ipopt_adapter.h:58
virtual bool eval_g(Index n, const double *x, bool new_x, Index m, double *g)
virtual bool intermediate_callback(AlgorithmMode mode, Index iter, double obj_value, double inf_pr, double inf_du, double mu, double d_norm, double regularization_size, double alpha_du, double alpha_pr, Index ls_trials, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
bool finite_diff_
Flag that indicates the "finite-difference-values" option is set.
Definition: ipopt_adapter.h:71


ifopt
Author(s): Alexander W. Winkler
autogenerated on Fri May 17 2019 02:29:49