From 53ef569fa7975d7d54c1b602017ed29f0e9cb6ff Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Fri, 19 Feb 2016 21:46:46 +0100
Subject: [PATCH] Let IPOpt choose its default linear solver

IPOpt needs a linear solver for internal use, but does not provide any one itself.
Previously, the dune-istl interface to IPOpt picked 'ma27' as the linear solver
when no other one was chosen.  The reason for this choice is historic, among other
things, ma27 is relatively easy to come by.  However, 'ma27' is not always a good
default.  For example, on Debian systems 'mumps' is the default linear solver
for IPOpt.

This patch removes the default from the dune-istl wrapper, and let's IPOpt picks
what it thinks is best.  This will only fail if there is no solver installed
at all.

(cherry picked from commit 0c36f0a5e195708791f8262a90765fed8f493576)
---
 dune/solvers/solvers/quadraticipopt.hh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/dune/solvers/solvers/quadraticipopt.hh b/dune/solvers/solvers/quadraticipopt.hh
index 391d062..6bd1f02 100644
--- a/dune/solvers/solvers/quadraticipopt.hh
+++ b/dune/solvers/solvers/quadraticipopt.hh
@@ -644,7 +644,7 @@ public:
     QuadraticIPOptSolver () : IterativeSolver<VectorType>(1e-8, 100, NumProc::FULL),
                               hessian_(NULL), rhs_(NULL),
                               obstacles_(NULL),
-                              linearSolverType_("ma27"),
+                              linearSolverType_(""),
                               constraintObstacles_(nullptr),constraintMatrix_(nullptr)
     {}
 
@@ -653,7 +653,7 @@ public:
                        VectorType& x,
                        const VectorType& rhs,
                        NumProc::VerbosityMode verbosity=NumProc::FULL,
-                       std::string linearSolverType = "ma27")
+                       std::string linearSolverType = "")
         : IterativeSolver<VectorType>(1e-8, 100, verbosity),
           hessian_(&hessian), rhs_(&rhs), obstacles_(NULL),
           linearSolverType_(linearSolverType),
@@ -724,7 +724,8 @@ void QuadraticIPOptSolver<MatrixType,VectorType,JacobianType>::solve()
   app->Options()->SetNumericValue("tol", this->tolerance_);
   app->Options()->SetIntegerValue("max_iter", this->maxIterations_);
   app->Options()->SetStringValue("mu_strategy", "adaptive");
-  app->Options()->SetStringValue("linear_solver",linearSolverType_);
+  if (linearSolverType_!="")
+    app->Options()->SetStringValue("linear_solver",linearSolverType_);
   app->Options()->SetStringValue("output_file", "ipopt.out");
   app->Options()->SetStringValue("hessian_constant", "yes");
 
-- 
GitLab