ipopt_adapter.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2017, Alexander W. Winkler, ETH Zurich. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without modification,
00005 are permitted provided that the following conditions are met:
00006     * Redistributions of source code must retain the above copyright notice,
00007       this list of conditions and the following disclaimer.
00008     * Redistributions in binary form must reproduce the above copyright notice,
00009       this list of conditions and the following disclaimer in the documentation
00010       and/or other materials provided with the distribution.
00011     * Neither the name of ETH ZURICH nor the names of its contributors may be
00012       used to endorse or promote products derived from this software without
00013       specific prior written permission.
00014 
00015 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00016 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00017 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00018 DISCLAIMED. IN NO EVENT SHALL ETH ZURICH BE LIABLE FOR ANY DIRECT, INDIRECT,
00019 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00020 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00022 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00023 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00024 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 ******************************************************************************/
00026 
00027 #ifndef IFOPT_INCLUDE_OPT_IPOPT_ADAPTER_H_
00028 #define IFOPT_INCLUDE_OPT_IPOPT_ADAPTER_H_
00029 
00030 #include <IpTNLP.hpp>
00031 #include <IpIpoptApplication.hpp>
00032 #include <IpSolveStatistics.hpp>
00033 
00034 #include <ifopt/problem.h>
00035 
00042 namespace Ipopt {
00043 
00054 class IpoptAdapter : public TNLP {
00055 public:
00056   using Problem  = ifopt::Problem;
00057   using VectorXd = Problem::VectorXd;
00058   using Jacobian = Problem::Jacobian;
00059 
00066   IpoptAdapter(Problem& nlp, bool finite_diff = false);
00067   virtual ~IpoptAdapter() = default;
00068 
00069 private:
00070   Problem* nlp_; 
00071   bool finite_diff_;  
00072 
00074   virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00075                             Index& nnz_h_lag, IndexStyleEnum& index_style);
00076 
00078   virtual bool get_bounds_info(Index n, double* x_l, double* x_u,
00079                                Index m, double* g_l, double* g_u);
00080 
00082   virtual bool get_starting_point(Index n, bool init_x, double* x,
00083                                   bool init_z, double* z_L, double* z_U,
00084                                   Index m, bool init_lambda,
00085                                   double* lambda);
00086 
00088   virtual bool eval_f(Index n, const double* x, bool new_x, double& obj_value);
00089 
00091   virtual bool eval_grad_f(Index n, const double* x, bool new_x, double* grad_f);
00092 
00094   virtual bool eval_g(Index n, const double* x, bool new_x, Index m, double* g);
00095 
00100   virtual bool eval_jac_g(Index n, const double* x, bool new_x,
00101                           Index m, Index nele_jac, Index* iRow, Index *jCol,
00102                           double* values);
00103 
00106   virtual bool intermediate_callback(AlgorithmMode mode,
00107                                      Index iter, double obj_value,
00108                                      double inf_pr, double inf_du,
00109                                      double mu, double d_norm,
00110                                      double regularization_size,
00111                                      double alpha_du, double alpha_pr,
00112                                      Index ls_trials,
00113                                      const IpoptData* ip_data,
00114                                      IpoptCalculatedQuantities* ip_cq);
00115 
00118   virtual void finalize_solution(SolverReturn status,
00119                                  Index n, const double* x, const double* z_L, const double* z_U,
00120                                  Index m, const double* g, const double* lambda,
00121                                  double obj_value,
00122                                  const IpoptData* ip_data,
00123                                  IpoptCalculatedQuantities* ip_cq);
00124 };
00125 
00126 } // namespace Ipopt
00127 
00128 #endif /* IFOPT_INCLUDE_OPT_IPOPT_ADAPTER_H_ */


ifopt
Author(s): Alexander W. Winkler
autogenerated on Sat May 18 2019 02:43:08