34 ipopt_app_ = std::make_shared<Ipopt::IpoptApplication>();
35 status_ = Ipopt::Solve_Succeeded;
50 SetOption(
"jacobian_approximation",
"exact");
51 SetOption(
"hessian_approximation",
"limited-memory");
54 SetOption(
"print_timing_statistics",
"no");
63 ipopt_app_->RethrowNonIpoptException(rethrow_non_ipopt_exceptions);
69 using namespace Ipopt;
72 if (
status_ != Solve_Succeeded) {
73 std::cout << std::endl << std::endl <<
"*** Error during initialization!" << std::endl;
74 throw std::length_error(
"Ipopt could not initialize correctly");
78 std::string jac_type =
"";
79 ipopt_app_->Options()->GetStringValue(
"jacobian_approximation", jac_type,
"");
80 bool finite_diff = jac_type==
"finite-difference-values";
83 SmartPtr<TNLP> nlp_ptr =
new IpoptAdapter(nlp,finite_diff);
86 if (
status_ != Solve_Succeeded) {
87 std::string msg =
"ERROR: Ipopt failed to find a solution. Return Code: " + std::to_string(
status_) +
"\n";
95 ipopt_app_->Options()->SetStringValue(name, value);
101 ipopt_app_->Options()->SetIntegerValue(name, value);
107 ipopt_app_->Options()->SetNumericValue(name, value);
113 return ipopt_app_->Statistics()->TotalWallclockTime();
void Solve(Problem &nlp) override
Creates an IpoptAdapter and solves the NLP.
A generic optimization problem with variables, costs and constraints.
Solves the optimization problem using the IPOPT solver.
double GetTotalWallclockTime()
Get the total wall clock time for the optimization, including function evaluations.
namespace defined by the Ipopt solver.
std::shared_ptr< Ipopt::IpoptApplication > ipopt_app_
common namespace for all elements in this library.
IpoptSolver(bool rethrow_non_ipopt_exceptions=false)
void SetOption(const std::string &name, const std::string &value)