9#include "crocoddyl/core/solvers/ipopt.hpp" 
   16      ipopt_app_(IpoptApplicationFactory()) {
 
   17  ipopt_app_->Options()->SetNumericValue(
"tol", 
th_stop_);
 
   18  ipopt_app_->Options()->SetStringValue(
"mu_strategy", 
"adaptive");
 
   20  ipopt_status_ = ipopt_app_->Initialize();
 
   22  if (ipopt_status_ != Ipopt::Solve_Succeeded) {
 
   23    std::cerr << 
"Error during IPOPT initialization!" << std::endl;
 
 
   28                        const std::vector<Eigen::VectorXd>& init_us,
 
   29                        const std::size_t maxiter, 
const bool is_feasible,
 
   32  ipopt_iface_->set_xs(
xs_);
 
   33  ipopt_iface_->set_us(
us_);
 
   35  ipopt_app_->Options()->SetIntegerValue(
"max_iter",
 
   36                                         static_cast<Ipopt::Index
>(maxiter));
 
   37  ipopt_status_ = ipopt_app_->OptimizeTNLP(ipopt_iface_);
 
   39  std::copy(ipopt_iface_->get_xs().begin(), ipopt_iface_->get_xs().end(),
 
   41  std::copy(ipopt_iface_->get_us().begin(), ipopt_iface_->get_us().end(),
 
   43  cost_ = ipopt_iface_->get_cost();
 
   44  iter_ = ipopt_app_->Statistics()->IterationCount();
 
   46  return ipopt_status_ == Ipopt::Solve_Succeeded ||
 
   47         ipopt_status_ == Ipopt::Solved_To_Acceptable_Level;
 
 
   52  ipopt_iface_->resizeData();
 
 
   55SolverIpopt::~SolverIpopt() {}
 
   57void SolverIpopt::computeDirection(
const bool) {}
 
   59double SolverIpopt::tryStep(
const double) { 
return 0.; }
 
   61double SolverIpopt::stoppingCriteria() { 
return 0.; }
 
   63const Eigen::Vector2d& SolverIpopt::expectedImprovement() { 
return d_; }
 
   66                                       const std::string& value) {
 
   67  ipopt_app_->Options()->SetStringValue(tag, value);
 
 
   71                                        Ipopt::Number value) {
 
   72  ipopt_app_->Options()->SetNumericValue(tag, value);
 
 
   75void SolverIpopt::set_th_stop(
const double th_stop) {
 
   77    throw_pretty(
"Invalid argument: " << 
"th_stop value has to higher than 0.");
 
   80  ipopt_app_->Options()->SetNumericValue(
"tol", 
th_stop_);
 
Class for interfacing a crocoddyl::ShootingProblem with IPOPT.
 
Abstract class for optimal control solvers.
 
std::vector< Eigen::VectorXd > xs_
State trajectory.
 
std::vector< Eigen::VectorXd > us_
Control trajectory.
 
double th_stop_
Tolerance for stopping the algorithm.
 
void setCandidate(const std::vector< Eigen::VectorXd > &xs_warm=DEFAULT_VECTOR, const std::vector< Eigen::VectorXd > &us_warm=DEFAULT_VECTOR, const bool is_feasible=false)
Set the solver candidate trajectories .
 
double cost_
Cost for the current guess.
 
std::size_t iter_
Number of iteration performed by the solver.
 
Eigen::Vector2d d_
LQ approximation of the expected improvement.
 
virtual void resizeData()
Resizing the solver data.
 
bool solve(const std::vector< Eigen::VectorXd > &init_xs=DEFAULT_VECTOR, const std::vector< Eigen::VectorXd > &init_us=DEFAULT_VECTOR, const std::size_t maxiter=100, const bool is_feasible=false, const double reg_init=1e-9)
Compute the optimal trajectory  as lists of  and  terms.
 
EIGEN_MAKE_ALIGNED_OPERATOR_NEW SolverIpopt(std::shared_ptr< crocoddyl::ShootingProblem > problem)
Initialize the Ipopt solver.
 
void setStringIpoptOption(const std::string &tag, const std::string &value)
Set a string ipopt option.
 
virtual void resizeData()
Resizing the solver data.
 
void setNumericIpoptOption(const std::string &tag, Ipopt::Number value)
Set a string ipopt option.