31 #ifdef BUILD_WITH_IPOPT_SUPPORT // build IPOPT interface 35 #include <coin/IpTNLP.hpp> 36 #include <coin/IpIpoptApplication.hpp> 37 #include <coin/IpSolveStatistics.hpp> 39 #endif // BUILD_WITH_IPOPT_SUPPORT 47 #ifdef BUILD_WITH_IPOPT_SUPPORT // build IPOPT interface 56 template <
typename SCALAR>
60 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
61 using BASE = NlpSolver<SCALAR>;
62 using VectorXs = Eigen::Matrix<SCALAR, Eigen::Dynamic, 1>;
63 using MapVecXs = Eigen::Map<VectorXs>;
64 using MapConstVecXs = Eigen::Map<const VectorXs>;
72 IpoptSolver(std::shared_ptr<tpl::Nlp<SCALAR>> nlp,
const NlpSolverSettings& settings);
82 bool solve()
override;
91 bool get_nlp_info(Ipopt::Index& n,
93 Ipopt::Index& nnz_jac_g,
94 Ipopt::Index& nnz_h_lag,
95 IndexStyleEnum& index_style)
override;
101 bool get_starting_point(Ipopt::Index n,
112 bool eval_f(Ipopt::Index n,
const SCALAR*
x,
bool new_x,
SCALAR& obj_value)
override;
115 bool eval_grad_f(Ipopt::Index n,
const SCALAR*
x,
bool new_x,
SCALAR* grad_f)
override;
118 bool eval_g(Ipopt::Index n,
const SCALAR*
x,
bool new_x, Ipopt::Index m,
SCALAR* g)
override;
124 bool eval_jac_g(Ipopt::Index n,
128 Ipopt::Index nele_jac,
137 bool eval_h(Ipopt::Index n,
144 Ipopt::Index nele_hess,
154 void finalize_solution(Ipopt::SolverReturn status,
163 const Ipopt::IpoptData* ip_data,
164 Ipopt::IpoptCalculatedQuantities* ip_cq)
override;
171 void setSolverOptions();
172 std::shared_ptr<Ipopt::IpoptApplication> ipoptApp_;
173 Ipopt::ApplicationReturnStatus status_;
179 #else // BUILD_WITH_IPOPT_SUPPORT -- not building with IPOPT support, create dummy class 181 template <
typename SCALAR>
185 IpoptSolver() {
throw(std::runtime_error(
"Error - IPOPT interface not compiled.")); }
188 throw(std::runtime_error(
"Error - IPOPT interface not compiled."));
191 bool solve()
override {
return false; }
196 #endif // BUILD_WITH_IPOPT_SUPPORT Abstract base class for the NLP solvers.
Definition: NlpSolver.h:21
Definition: IpoptSolver.h:182
Contains the NLP solver settings.
Definition: NlpSolverSettings.h:261
void prepareWarmStart(size_t maxIterations) override
Prepares the solver for a warmstarting scenario with available (good) initial guess.
Definition: IpoptSolver.h:192
The NLP base class. This class serves as abstract base class to use as an interface to the NLP solver...
Definition: Nlp.h:32
tpl::NlpSolver< double > NlpSolver
Definition: NlpSolver.h:93
CppAD::AD< CppAD::cg::CG< double > > SCALAR
IpoptSolver(std::shared_ptr< tpl::Nlp< SCALAR >> nlp, NlpSolverSettings settings)
Definition: IpoptSolver.h:186
IpoptSolver()
Definition: IpoptSolver.h:185
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
NlpSolverSettings settings_
Definition: NlpSolver.h:88
tpl::IpoptSolver< double > IpoptSolver
Definition: IpoptSolver.h:200
bool solve() override
Solves the nlp.
Definition: IpoptSolver.h:191
void configureDerived(const NlpSolverSettings &settings) override
Forwards the settings to the corresponding nlp solver.
Definition: IpoptSolver.h:193