diff --git a/dune/solvers/solvers/quadraticipopt.hh b/dune/solvers/solvers/quadraticipopt.hh index 4cbd5a774e67be18512f0f30b40e05589f32cb15..3c303ca4a3bf3b952b58bbc4f83be0c765177c61 100644 --- a/dune/solvers/solvers/quadraticipopt.hh +++ b/dune/solvers/solvers/quadraticipopt.hh @@ -21,7 +21,7 @@ #include <dune/solvers/common/boxconstraint.hh> #include <dune/solvers/common/canignore.hh> -#include <dune/solvers/solvers/iterativesolver.hh> +#include <dune/solvers/solvers/linearsolver.hh> #include "IpTNLP.hpp" #include "IpIpoptApplication.hpp" @@ -632,7 +632,7 @@ finalize_solution(Ipopt::SolverReturn status, */ template <class MatrixType, class VectorType, class JacobianType=MatrixType> class QuadraticIPOptSolver - : public IterativeSolver<VectorType>, public CanIgnore<Dune::BitSetVector<VectorType::block_type::dimension> > +: public LinearSolver<MatrixType,VectorType>, public CanIgnore<Dune::BitSetVector<VectorType::block_type::dimension> > { enum {blocksize = VectorType::block_type::dimension}; @@ -647,7 +647,7 @@ class QuadraticIPOptSolver public: /** \brief Default constructor */ - QuadraticIPOptSolver () : IterativeSolver<VectorType>(1e-8, 100, NumProc::FULL), + QuadraticIPOptSolver () : LinearSolver<MatrixType,VectorType>(NumProc::FULL), hessian_(NULL), rhs_(NULL), obstacles_(NULL), linearSolverType_(""), @@ -657,7 +657,9 @@ public: /** \brief Constructor that only sets solver parameter. */ QuadraticIPOptSolver (field_type tolerance, int numIterations, NumProc::VerbosityMode verbosity = NumProc::FULL) - : IterativeSolver<VectorType>(tolerance, numIterations, verbosity) + : LinearSolver<MatrixType,VectorType>(verbosity), + tolerance_(tolerance), + maxIterations_(numIterations) {} /** \brief Constructor for a linear problem */ @@ -666,7 +668,9 @@ public: const VectorType& rhs, NumProc::VerbosityMode verbosity=NumProc::FULL, std::string linearSolverType = "") - : IterativeSolver<VectorType>(1e-8, 100, verbosity), + : LinearSolver<MatrixType,VectorType>(verbosity), + tolerance_(1e-8), + maxIterations_(100), hessian_(&hessian), rhs_(&rhs), obstacles_(NULL), linearSolverType_(linearSolverType), constraintObstacles_(nullptr),constraintMatrix_(nullptr) @@ -676,7 +680,8 @@ public: void setProblem(const MatrixType& hessian, VectorType& x, - const VectorType& rhs) { + const VectorType& rhs) override + { hessian_ = &hessian; x_ = &x; rhs_ = &rhs; @@ -694,6 +699,12 @@ public: // Data /////////////////////////////////////////////////////// + //! Solve the system until the IPOpt error measure drops below this value + double tolerance_; + + //! The maximum number of iterations + int maxIterations_; + //! The quadratic term in the quadratic energy, is assumed to be symmetric const MatrixType* hessian_; @@ -733,8 +744,8 @@ void QuadraticIPOptSolver<MatrixType,VectorType,JacobianType>::solve() Ipopt::SmartPtr<Ipopt::IpoptApplication> app = new Ipopt::IpoptApplication(); // Change some options - app->Options()->SetNumericValue("tol", this->tolerance_); - app->Options()->SetIntegerValue("max_iter", this->maxIterations_); + app->Options()->SetNumericValue("tol", tolerance_); + app->Options()->SetIntegerValue("max_iter", maxIterations_); app->Options()->SetStringValue("mu_strategy", "adaptive"); if (linearSolverType_!="") app->Options()->SetStringValue("linear_solver",linearSolverType_);