24#ifdef MFEM_USE_SUITESPARSE
141 MPI_Comm comm = MPI_COMM_NULL;
213 bool final=
false)
const;
338 {
return dot_prod_type == 0 ? MPI_COMM_NULL : comm; }
440 const real_t damping=1.0);
453 const real_t damping=1.0);
486 bool use_abs_diag =
false;
492 const bool allow_updates;
513 int order,
real_t max_eig_estimate);
519 int order,
real_t max_eig_estimate);
531 int order, MPI_Comm comm = MPI_COMM_NULL,
532 int power_iterations = 10,
533 real_t power_tolerance = 1e-8,
534 int power_seed = 12345);
540 int order, MPI_Comm comm = MPI_COMM_NULL,
541 int power_iterations = 10,
542 real_t power_tolerance = 1e-8);
546 int order,
int power_iterations = 10,
547 real_t power_tolerance = 1e-8,
548 int power_seed = 12345);
554 int order,
int power_iterations = 10,
555 real_t power_tolerance = 1e-8);
584 mutable Vector helperVector;
615void SLI(
const Operator &A,
const Vector &
b, Vector &x,
616 int print_iter = 0,
int max_num_iter = 1000,
620void SLI(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
621 int print_iter = 0,
int max_num_iter = 1000,
649void CG(
const Operator &A,
const Vector &
b, Vector &x,
650 int print_iter = 0,
int max_num_iter = 1000,
654void PCG(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
655 int print_iter = 0,
int max_num_iter = 1000,
699int GMRES(
const Operator &A, Vector &x,
const Vector &
b, Solver &M,
700 int &max_iter,
int m,
real_t &tol,
real_t atol,
int printit);
703void GMRES(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
704 int print_iter = 0,
int max_num_iter = 1000,
int m = 50,
731int BiCGSTAB(
const Operator &A, Vector &x,
const Vector &
b, Solver &M,
735void BiCGSTAB(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
736 int print_iter = 0,
int max_num_iter = 1000,
767void MINRES(
const Operator &A,
const Vector &
b, Vector &x,
int print_it = 0,
768 int max_it = 1000,
real_t rtol = 1e-12,
real_t atol = 1e-24);
771void MINRES(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
772 int print_it = 0,
int max_it = 1000,
809 const real_t fnorm)
const;
816 const real_t fnorm)
const;
858 const real_t rtol_max = 0.9,
873 for (
int i = 0; i <
skArray.Size(); i++)
885 for (
int i = 0; i <
m; i++)
918 { MFEM_WARNING(
"L-BFGS won't use the given preconditioner."); }
920 { MFEM_WARNING(
"L-BFGS won't use the given solver."); }
930int aGMRES(
const Operator &A, Vector &x,
const Vector &
b,
931 const Operator &M,
int &max_iter,
932 int m_max,
int m_min,
int m_step,
real_t cf,
936class HiopOptimizationProblem;
963 mutable bool new_x =
true;
974 bool NewX()
const {
return new_x; }
986 { MFEM_ABORT(
"The objective gradient is not implemented."); }
1024 { MFEM_ABORT(
"Not meaningful for this solver."); }
1026 { MFEM_ABORT(
"Not meaningful for this solver."); }
1202 bool final)
override;
1206#ifdef MFEM_USE_SUITESPARSE
1293 std::unique_ptr<DenseMatrixInverse[]> block_solvers;
1313 bool ownA,
bool ownS0,
bool ownS1)
1314 :
Solver(A_->
NumRows()), A(A_, ownA), S0(S0_, ownS0), S1(S1_, ownS1) { }
1337 const bool parallel;
1339 mutable int global_size;
1368 Solver *solver =
nullptr;
1372 void Orthogonalize(
const Vector &v,
Vector &v_ortho)
const;
1387 void Mult(
const Vector &x,
Vector &y,
bool transpose)
const;
1390 bool op_is_symmetric =
true,
bool own_aux_map =
false);
1393 {
Mult(x, y,
true); }
1400#ifdef MFEM_USE_LAPACK
1438 { res_change_termination_tol_ = tol; }
1502 mutable int max_nnz_;
1509 real_t res_change_termination_tol_;
1519 mutable bool NNLS_qrres_on_;
1522 mutable Vector row_scaling_;
T * GetData()
Returns the data.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
HypreSmoother & GetSmoother()
AuxSpaceSmoother(const HypreParMatrix &op, HypreParMatrix *aux_map, bool op_is_symmetric=true, bool own_aux_map=false)
void Mult(const Vector &x, Vector &y) const override
Operator application: y=A(x).
void MultTranspose(const Vector &x, Vector &y) const override
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
BiCGSTABSolver(MPI_Comm comm_)
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the BiCGSTAB method.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
Reordering
The reordering method used by the BlockILU factorization.
BlockILU(int block_size_, Reordering reordering_=Reordering::MINIMUM_DISCARDED_FILL, int k_fill_=0)
void Mult(const Vector &b, Vector &x) const
Solve the system LUx = b, where L and U are the block ILU factors.
void SetOperator(const Operator &op)
Conjugate gradient method.
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the Conjugate Gradient method.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
Inner product operator constrained to a list of indices/dofs. The method Eval() computes the inner pr...
virtual real_t Eval(const Vector &x, const Vector &y) override
Compute the inner product (x,y) of vectors x and y, only on the constrained entries.
Vector xr
List of constrained indices.
ConstrainedInnerProduct(MPI_Comm comm_, const Array< int > &list)
Restricted vectors.
Array< int > constraint_list
virtual void Mult(const Vector &x, Vector &y) const override
Apply the constraint to vector x and return in y.
void SetIndices(const Array< int > &list)
Set/update the list of constraint indices.
ConstrainedInnerProduct(const Array< int > &list)
Constructor from a list of constraint indices/dofs. Specify a list of indices to constrain,...
ConstrainedInnerProduct(MPI_Comm comm_)
Constructor from MPI communicator.
Data type dense matrix using column-major storage.
Rank 3 tensor (array of matrices)
Block diagonal solver for A, each block is inverted by direct solver.
void Mult(const Vector &x, Vector &y) const override
Direct solution of the block diagonal linear system.
DirectSubBlockSolver(const SparseMatrix &A, const SparseMatrix &block_dof)
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the FGMRES method.
FGMRESSolver(MPI_Comm comm_)
void SetKDim(int dim)
Set the number of iteration to perform between restarts, default is 50.
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the GMRES method.
GMRESSolver(MPI_Comm comm_)
Internal class - adapts the OptimizationProblem class to HiOp's interface.
Wrapper for hypre's ParCSR matrix class.
Parallel smoothers in hypre.
Abstract class for defining inner products. The method Eval() must be implemented in derived classes ...
Abstract base class for an iterative solver controller.
IterativeSolverController()
virtual void MonitorSolution(int it, real_t norm, const Vector &x, bool final)
Monitor the solution vector x.
const class IterativeSolver * iter_solver
The last IterativeSolver to which this controller was attached.
virtual void MonitorResidual(int it, real_t norm, const Vector &r, bool final)
Monitor the solution vector r.
virtual bool RequiresUpdatedSolution() const
Indicates if the controller requires an updated solution every iteration.
void SetIterativeSolver(const IterativeSolver &solver)
This method is invoked by IterativeSolver::SetController(), informing the controller which IterativeS...
virtual ~IterativeSolverController()
Abstract base class for iterative solver.
real_t abs_tol
Absolute tolerance.
InnerProductOperator * dot_oper
real_t rel_tol
Relative tolerance.
PrintLevel print_options
Output behavior for the iterative solver.
void SetController(IterativeSolverController &c)
Set the iterative solver controller.
real_t GetFinalNorm() const
Returns the final residual norm after termination of the solver during the last call to Mult().
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
void SetInnerProduct(InnerProductOperator *ipo)
Set a user-defined inner product operator (not owned)
virtual real_t Dot(const Vector &x, const Vector &y) const
Return the standard (l2, i.e., Euclidean) inner product of x and y.
void SetRelTol(real_t rtol)
real_t GetFinalRelNorm() const
Returns the final residual norm after termination of the solver during the last call to Mult(),...
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
bool ControllerRequiresUpdate() const
Indicated if the controller requires an update of the solution.
int print_level
(DEPRECATED) Legacy print level definition, which is left for compatibility with custom iterative sol...
int GetNumIterations() const
Returns the number of iterations taken during the last call to Mult()
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
int max_iter
Limit for the number of iterations the solver is allowed to do.
void SetMaxIter(int max_it)
bool Monitor(int it, real_t norm, const Vector &r, const Vector &x, bool final=false) const
Monitor both the residual r and the solution x.
IterativeSolverController * controller
MPI_Comm GetComm() const
Return the associated MPI communicator, or MPI_COMM_NULL if no communicator is set.
real_t GetInitialNorm() const
Returns the initial residual norm from the last call to Mult().
static int GuessLegacyPrintLevel(PrintLevel)
Use some heuristics to guess a legacy print level corresponding to the given PrintLevel.
void SetMonitor(IterativeSolverMonitor &m)
An alias of SetController() for backward compatibility.
bool GetConverged() const
Returns true if the last call to Mult() converged successfully.
PrintLevel FromLegacyPrintLevel(int)
Convert a legacy print level integer to a PrintLevel object.
void SetAbsTol(real_t atol)
real_t Norm(const Vector &x) const
Return the inner product norm of x, using the inner product defined by Dot()
Direct sparse solver using KLU.
void MultTranspose(const Vector &b, Vector &x) const override
Direct solution of the transposed linear system using KLU.
KLUSolver(SparseMatrix &A)
void Mult(const Vector &b, Vector &x) const override
Direct solution of the linear system using KLU.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
LBFGSSolver(MPI_Comm comm_)
Array< Vector * > skArray
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
void InitializeStorageVectors()
void SetHistorySize(int dim)
void DeleteStorageVectors()
void SetSolver(Solver &solver) override
Set the linear solver for inverting the Jacobian.
void Mult(const Vector &b, Vector &x) const override
Solve the nonlinear system with right-hand side b.
Array< Vector * > ykArray
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the MINRES method.
MINRESSolver(MPI_Comm comm_)
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
void SetNormalize(bool n)
Set a flag to determine whether to call NormalizeConstraints().
void SetResidualChangeTolerance(real_t tol)
Set threshold on relative change in residual over nStallCheck_ iterations.
void SetRHSDelta(real_t d)
Set RHS vector constant shift, defining rhs_lb and rhs_ub in Solve().
void Solve(const Vector &rhs_lb, const Vector &rhs_ub, Vector &soln) const
Solve the NNLS problem. Specifically, we find a vector soln, such that rhs_lb < mat*soln < rhs_ub is ...
QRresidualMode
Enumerated types of QRresidual mode. Options are 'off': the residual is calculated normally,...
void SetZeroTolerance(real_t tol)
Set the magnitude of projected residual entries that are considered zero. Increasing this value relax...
void SetInnerIterations(int n)
Set the maximum number of inner iterations in Solve().
void Mult(const Vector &w, Vector &sol) const override
Compute the non-negative least squares solution to the underdetermined system.
void SetQRResidualMode(const QRresidualMode qr_residual_mode)
Set the residual calculation mode for the NNLS solver. See QRresidualMode enum above for details.
void SetOperator(const Operator &op) override
The operator must be a DenseMatrix.
void SetStallCheck(int n)
Set the number of iterations to use for stall checking.
void NormalizeConstraints(Vector &rhs_lb, Vector &rhs_ub) const
Normalize the constraints such that the tolerances for each constraint (i.e. (UB - LB)/2) are equal....
void SetTolerance(real_t tol)
Set the target absolute residual norm tolerance for convergence.
void SetOuterIterations(int n)
Set the maximum number of outer iterations in Solve().
void SetMinNNZ(int min_nnz)
Set the minimum number of nonzeros required for the solution.
void SetMaxNNZ(int max_nnz)
Set the maximum number of nonzeros required for the solution, as an early termination condition.
void SetVerbosity(int v)
Set verbosity. If set to 0: print nothing; if 1: just print results; if 2: print short update on ever...
Newton's method for solving F(x)=b for a given operator F.
void SetAdaptiveLinRtol(const int type=2, const real_t rtol0=0.5, const real_t rtol_max=0.9, const real_t alpha=0.5 *(1.0+sqrt(5.0)), const real_t gamma=1.0)
Enable adaptive linear solver relative tolerance algorithm.
void AdaptiveLinRtolPreSolve(const Vector &x, const int it, const real_t fnorm) const
Method for the adaptive linear solver rtol invoked before the linear solve.
NewtonSolver(MPI_Comm comm_)
virtual real_t ComputeScalingFactor(const Vector &x, const Vector &b) const
This method can be overloaded in derived classes to implement line search algorithms.
void Mult(const Vector &b, Vector &x) const override
Solve the nonlinear system with right-hand side b.
void AdaptiveLinRtolPostSolve(const Vector &x, const Vector &b, const int it, const real_t fnorm) const
Method for the adaptive linear solver rtol invoked after the linear solve.
virtual void ProcessNewState(const Vector &x) const
This method can be overloaded in derived classes to perform computations that need knowledge of the n...
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
virtual void SetSolver(Solver &solver)
Set the linear solver for inverting the Jacobian.
Chebyshev accelerated smoothing with given vector, no matrix necessary.
void SetOperator(const Operator &op_)
Set/update the solver for the given operator.
void Mult(const Vector &x, Vector &y) const
Approach the solution of the linear system by applying Chebyshev smoothing.
void MultTranspose(const Vector &x, Vector &y) const
Approach the solution of the transposed linear system by applying Chebyshev smoothing.
OperatorChebyshevSmoother(const Operator &oper_, const Vector &d, const Array< int > &ess_tdof_list, int order, real_t max_eig_estimate)
~OperatorChebyshevSmoother()
OperatorChebyshevSmoother(const Operator &oper_, const Vector &d, const Array< int > &ess_tdof_list, int order, int power_iterations=10, real_t power_tolerance=1e-8, int power_seed=12345)
Pointer to an Operator of a specified type.
OpType * As() const
Return the Operator pointer statically cast to a specified OpType. Similar to the method Get().
Jacobi smoothing for a given bilinear form (no matrix necessary).
void Setup(const Vector &diag)
~OperatorJacobiSmoother()
OperatorJacobiSmoother(const real_t damping=1.0)
Default constructor: the diagonal will be computed by subsequent calls to SetOperator() using the Ope...
void SetPositiveDiagonal(bool pos_diag=true)
Replace diagonal entries with their absolute values.
void SetOperator(const Operator &op)
Recompute the diagonal using the method AssembleDiagonal of the given new Operator,...
void MultTranspose(const Vector &x, Vector &y) const
Approach the solution of the transposed linear system by applying Jacobi smoothing.
void Mult(const Vector &x, Vector &y) const
Approach the solution of the linear system by applying Jacobi smoothing.
int width
Dimension of the input / number of columns in the matrix.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
int NumRows() const
Get the number of rows (size of output) of the Operator. Synonym with Height().
virtual void CalcObjectiveGrad(const Vector &x, Vector &grad) const
The result grad is expected to enter with the correct size.
const Vector * GetEqualityVec() const
const Operator * C
Not owned, some can remain unused (NULL).
void SetSolutionBounds(const Vector &xl, const Vector &xh)
void SetEqualityConstraint(const Vector &c)
int GetNumConstraints() const
virtual real_t CalcObjective(const Vector &x) const =0
Objective F(x). In parallel, the result should be reduced over tasks.
const Vector * GetInequalityVec_Hi() const
const Operator * GetC() const
const Vector * GetBoundsVec_Hi() const
const Operator * GetD() const
OptimizationProblem(int insize, const Operator *C_, const Operator *D_)
In parallel, insize is the number of the local true dofs.
const Vector * GetInequalityVec_Lo() const
const Vector * GetBoundsVec_Lo() const
void SetInequalityConstraint(const Vector &dl, const Vector &dh)
Abstract solver for OptimizationProblems.
~OptimizationSolver() override
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
void Mult(const Vector &xt, Vector &x) const override=0
Operator application: y=A(x).
const OptimizationProblem * problem
virtual void SetOptimizationProblem(const OptimizationProblem &prob)
OptimizationSolver(MPI_Comm comm_)
Solver wrapper which orthogonalizes the input and output vector.
void SetOperator(const Operator &op) override
Set the Operator that is the OrthoSolver is to invert (approximately).
OrthoSolver(MPI_Comm mycomm_)
void SetSolver(Solver &s)
Set the solver used by the OrthoSolver.
void Mult(const Vector &b, Vector &x) const override
Perform the action of the OrthoSolver: P * solver * P where P is the projection to the subspace of ve...
void Mult(const Vector &x, Vector &y) const override
Solution of the linear system using a product of subsolvers.
ProductSolver(Operator *A_, Solver *S0_, Solver *S1_, bool ownA, bool ownS0, bool ownS1)
void MultTranspose(const Vector &x, Vector &y) const override
Solution of the transposed linear system using a product of subsolvers.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
Monitor that checks whether the residual is zero at a given set of dofs.
void MonitorResidual(int it, real_t norm, const Vector &r, bool final) override
Monitor the solution vector r.
const Array< int > * ess_dofs_list
Not owned.
ResidualBCMonitor(const Array< int > &ess_dofs_list_)
void Mult(const Vector &xt, Vector &x) const override
SLBQPOptimizer(MPI_Comm comm_)
void SetBounds(const Vector &lo_, const Vector &hi_)
void SetLinearConstraint(const Vector &w_, real_t a_)
void print_iteration(int it, real_t r, real_t l) const
void SetOptimizationProblem(const OptimizationProblem &prob) override
real_t solve(real_t l, const Vector &xt, Vector &x, int &nclip) const
Solve QP at fixed lambda.
Stationary linear iteration: x <- x + B (b - A x)
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using Stationary Linear Iteration.
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
SLISolver(MPI_Comm comm_)
Direct sparse solver using UMFPACK.
UMFPackSolver(bool use_long_ints_=false)
For larger matrices, if the solver fails, set the parameter use_long_ints_ = true.
real_t Control[UMFPACK_CONTROL]
void SetOperator(const Operator &op) override
Factorize the given Operator op which must be a SparseMatrix.
void MultTranspose(const Vector &b, Vector &x) const override
Direct solution of the transposed linear system using UMFPACK.
real_t Info[UMFPACK_INFO]
void SetPrintLevel(int print_lvl)
Set the print level field in the Control data member.
UMFPackSolver(SparseMatrix &A, bool use_long_ints_=false)
Factorize the given SparseMatrix using the defaults. For larger matrices, if the solver fails,...
void Mult(const Vector &b, Vector &x) const override
Direct solution of the linear system using UMFPACK.
void median(const Vector &lo, const Vector &hi)
v = median(v,lo,hi) entrywise. Implementation assumes lo <= hi.
void SetSize(int s)
Resize the vector to size s.
Inner product weighted by operators, X and Y. The method Eval() computes the inner product of two vec...
Vector wx
Weighting operator for y.
WeightedInnerProduct(Operator *X, Operator *Y)
Constructor from weighting operators.
void SetOperator(Operator *XY)
Set/update the same weighting operator (not owned) for both terms.
virtual real_t Eval(const Vector &x, const Vector &y) override
Compute the inner product (Y(y),X(x)) of vectors x and y, weighted by the operators X and Y.
MemoryClass mem_class
Weighted vectors.
virtual void Mult(const Vector &x, Vector &y) const override
Apply the weighting operator to vector x and return in y=Y(X(x)).
WeightedInnerProduct(MPI_Comm comm_)
Constructor from MPI communicator.
void SetOperator(Operator *X, Operator *Y)
Set/update the weighting operators (not owned) for each term.
Operator * operY
Weighting operator for x.
int BiCGSTAB(const Operator &A, Vector &x, const Vector &b, Solver &M, int &max_iter, real_t &tol, real_t atol, int printit)
BiCGSTAB method. (tolerances are squared)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
void add(const Vector &v1, const Vector &v2, Vector &v)
MemoryClass
Memory classes identify sets of memory types.
int GMRES(const Operator &A, Vector &x, const Vector &b, Solver &M, int &max_iter, int m, real_t &tol, real_t atol, int printit)
GMRES method. (tolerances are squared)
int aGMRES(const Operator &A, Vector &x, const Vector &b, const Operator &M, int &max_iter, int m_max, int m_min, int m_step, real_t cf, real_t &tol, real_t &atol, int printit)
void SLI(const Operator &A, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Stationary linear iteration. (tolerances are squared)
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
void CG(const Operator &A, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Conjugate gradient method. (tolerances are squared)
void MINRES(const Operator &A, const Vector &b, Vector &x, int print_it, int max_it, real_t rtol, real_t atol)
MINRES method without preconditioner. (tolerances are squared)
MFEM_HOST_DEVICE real_t norm(const Complex &z)
Settings for the output behavior of the IterativeSolver.
PrintLevel & Iterations()
bool errors
If a fatal problem has been detected the failure will be reported to mfem::err.
bool iterations
Detailed information about each iteration will be reported to mfem::out.
PrintLevel & FirstAndLast()
PrintLevel()=default
Initializes the print level to suppress.
bool warnings
If a non-fatal problem has been detected some context-specific information will be reported to mfem::...
bool first_and_last
Information about the first and last iteration will be printed to mfem::out.
bool summary
A summary of the solver process will be reported after the last iteration to mfem::out.