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");
66 using namespace Ipopt;
69 if (
status_ != Solve_Succeeded) {
70 std::cout << std::endl << std::endl <<
"*** Error during initialization!" << std::endl;
71 throw std::length_error(
"Ipopt could not initialize correctly");
75 std::string jac_type =
"";
76 ipopt_app_->Options()->GetStringValue(
"jacobian_approximation", jac_type,
"");
77 bool finite_diff = jac_type==
"finite-difference-values";
80 SmartPtr<TNLP> nlp_ptr =
new IpoptAdapter(nlp,finite_diff);
83 if (
status_ != Solve_Succeeded) {
84 std::string msg =
"ERROR: Ipopt failed to find a solution. Return Code: " + std::to_string(
status_) +
"\n";
92 ipopt_app_->Options()->SetStringValue(name, value);
98 ipopt_app_->Options()->SetIntegerValue(name, value);
104 ipopt_app_->Options()->SetNumericValue(name, value);
110 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.
void SetOption(const std::string &name, const std::string &value)