Skip to content

Commit

Permalink
allow to specify name for custom_solver as additional arg for Algorit…
Browse files Browse the repository at this point in the history
…hmBuilder

- if not empty, will be used in "This is Ipopt ..." message
  • Loading branch information
svigerske committed Mar 16, 2023
1 parent a386f64 commit 034c949
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ More detailed information about incremental changes can be found in the
- Fixed crash of GetIpoptCurrentIterate() and GetIpoptCurrentViolations() in
C interface when called before or after IpoptSolve(). [#644, #645, by Robbybp]
- Fixed crash when trying to solve problem without variables and constraints. [#648]
- Added optional argument to `AlgorithmBuilder` constructor to provide name of custom solver. [#618]

### 3.14.11 (2023-02-07)

Expand Down
8 changes: 6 additions & 2 deletions src/Algorithm/IpAlgBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ static const Index dbg_verbosity = 0;
#endif

AlgorithmBuilder::AlgorithmBuilder(
SmartPtr<AugSystemSolver> custom_solver /*=NULL*/
SmartPtr<AugSystemSolver> custom_solver, /*=NULL*/
const std::string& custom_solver_name /*=std::string()*/
)
: custom_solver_(custom_solver)
: custom_solver_(custom_solver),
custom_solver_name_(custom_solver_name)
{ }

void AlgorithmBuilder::RegisterOptions(
Expand Down Expand Up @@ -576,6 +578,8 @@ SmartPtr<AugSystemSolver> AlgorithmBuilder::AugSystemSolverFactory(
{
ASSERT_EXCEPTION(IsValid(custom_solver_), OPTION_INVALID, "Selected linear solver CUSTOM not available.");
AugSolver = custom_solver_;
if( !custom_solver_name_.empty() )
linear_solver = custom_solver_name_;
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion src/Algorithm/IpAlgBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class IPOPTLIB_EXPORT AlgorithmBuilder: public ReferencedObject
///@{
/** Constructor */
AlgorithmBuilder(
SmartPtr<AugSystemSolver> custom_solver = NULL
SmartPtr<AugSystemSolver> custom_solver = NULL,
const std::string& custom_solver_name = std::string() /**< @since 3.14.12 */
);

/** Destructor */
Expand Down Expand Up @@ -402,6 +403,7 @@ class IPOPTLIB_EXPORT AlgorithmBuilder: public ReferencedObject
/** Optional pointer to AugSystemSolver. If this is set in the
* constructor, we will use this to solve the linear systems. */
SmartPtr<AugSystemSolver> custom_solver_;
std::string custom_solver_name_;

/// name of linear solver constructed in SymLinearSolverFactory
std::string linear_solver;
Expand Down

0 comments on commit 034c949

Please sign in to comment.