Commit 2bd2b908 authored by Patric Schmitz's avatar Patric Schmitz

IPOPTSolverLean: set_ipopt_option overload instead of template

this allows string literal parameters to decay to std::string implicitly
parent b53b6f37
...@@ -47,9 +47,9 @@ public: ...@@ -47,9 +47,9 @@ public:
setup_ipopt_defaults(); setup_ipopt_defaults();
} }
void set_ipopt_option(std::string, int); void set_ipopt_option(std::string, const int&);
void set_ipopt_option(std::string, double); void set_ipopt_option(std::string, const double&);
void set_ipopt_option(std::string, std::string); void set_ipopt_option(std::string, const std::string&);
template <typename T> template <typename T>
T get_ipopt_option(std::string); T get_ipopt_option(std::string);
...@@ -78,7 +78,7 @@ const int IPOPTSolverLean::Impl::ipopt_default_mumps_mem_percent = 5; ...@@ -78,7 +78,7 @@ const int IPOPTSolverLean::Impl::ipopt_default_mumps_mem_percent = 5;
void void
IPOPTSolverLean::Impl:: IPOPTSolverLean::Impl::
set_ipopt_option set_ipopt_option
(std::string option, int value) (std::string option, const int& value)
{ {
app_->Options()->SetIntegerValue(option, value); app_->Options()->SetIntegerValue(option, value);
} }
...@@ -86,7 +86,7 @@ set_ipopt_option ...@@ -86,7 +86,7 @@ set_ipopt_option
void void
IPOPTSolverLean::Impl:: IPOPTSolverLean::Impl::
set_ipopt_option set_ipopt_option
(std::string option, double value) (std::string option, const double& value)
{ {
app_->Options()->SetNumericValue(option, value); app_->Options()->SetNumericValue(option, value);
} }
...@@ -94,7 +94,7 @@ set_ipopt_option ...@@ -94,7 +94,7 @@ set_ipopt_option
void void
IPOPTSolverLean::Impl:: IPOPTSolverLean::Impl::
set_ipopt_option set_ipopt_option
(std::string option, std::string value) (std::string option, const std::string& value)
{ {
app_->Options()->SetStringValue(option, value); app_->Options()->SetStringValue(option, value);
} }
...@@ -174,11 +174,26 @@ IPOPTSolverLean:: ...@@ -174,11 +174,26 @@ IPOPTSolverLean::
delete impl_; delete impl_;
} }
template <typename T>
void void
IPOPTSolverLean:: IPOPTSolverLean::
set_ipopt_option set_ipopt_option
(std::string option, const T& value) (std::string option, const int& value)
{
impl_->set_ipopt_option(option, value);
}
void
IPOPTSolverLean::
set_ipopt_option
(std::string option, const double& value)
{
impl_->set_ipopt_option(option, value);
}
void
IPOPTSolverLean::
set_ipopt_option
(std::string option, const std::string& value)
{ {
impl_->set_ipopt_option(option, value); impl_->set_ipopt_option(option, value);
} }
...@@ -190,6 +205,10 @@ get_ipopt_option(std::string option) ...@@ -190,6 +205,10 @@ get_ipopt_option(std::string option)
return impl_->get_ipopt_option<T>(option); return impl_->get_ipopt_option<T>(option);
} }
template int IPOPTSolverLean::get_ipopt_option<int>(std::string);
template double IPOPTSolverLean::get_ipopt_option<double>(std::string);
template std::string IPOPTSolverLean::get_ipopt_option<std::string>(std::string);
void void
IPOPTSolverLean:: IPOPTSolverLean::
set_max_iterations set_max_iterations
......
...@@ -58,8 +58,9 @@ public: ...@@ -58,8 +58,9 @@ public:
For a thorough list and documentation of available options, refer For a thorough list and documentation of available options, refer
to: https://www.coin-or.org/Ipopt/documentation/node40.html to: https://www.coin-or.org/Ipopt/documentation/node40.html
*/ */
template<typename T> void set_ipopt_option(std::string, const int&);
void set_ipopt_option(std::string option, const T& value); void set_ipopt_option(std::string, const double&);
void set_ipopt_option(std::string, const std::string&);
/*! /*!
Get options of the underlying ipopt solver. Get options of the underlying ipopt solver.
...@@ -114,7 +115,7 @@ public: ...@@ -114,7 +115,7 @@ public:
void solve void solve
(NProblemInterface* _problem, (NProblemInterface* _problem,
const std::vector<NConstraintInterface*>& _constraints, const std::vector<NConstraintInterface*>& _constraints,
const std::vector<NConstraintInterface*>& _lazy_constraints = {}); const std::vector<NConstraintInterface*>& _lazy_constraints);
//! Get the computed solution energy //! Get the computed solution energy
double energy(); double energy();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment