Module ojalgo

Class IterativeSolverTask

  • All Implemented Interfaces:
    MatrixTask<java.lang.Double>, SolverTask<java.lang.Double>
    Direct Known Subclasses:
    ConjugateGradientSolver, GaussSeidelSolver, JacobiSolver, MINRESSolver, ParallelGaussSeidelSolver, QMRSolver

    public abstract class IterativeSolverTask
    extends java.lang.Object
    implements SolverTask<java.lang.Double>
    Base class for iterative solvers of large linear systems [A][x]=[b]. Subclasses provide concrete stationary or Krylov algorithms while sharing input conversion, configuration, and stopping logic. Characteristics
    • Accepts both sparse and dense inputs by converting the system to a List<Equation> where rows can be iterated efficiently without assuming dense, contiguous storage.
    • Minimises allocations in hot loops by reusing buffers and operating directly on PhysicalStore and R064Store vectors.
    • Provides a common configuration and termination policy via NumberContext and an iteration limit.
    Selected/reordered rows and columns
    • Implementations must work when the effective system is a selected or reordered subset of the original problem. The equation list may represent only some rows, and column indices may need to be remapped or compacted.
    • Do not assume a dense, contiguous column space. Always form row products using Equation.dot(org.ojalgo.structure.Access1D) and access the diagonal through Equation.getPivot().
    • The provided solution vector defines the active variable subspace; form residuals against that vector and the current row bodies only.
    • RHS values are carried by each Equation; use resolve(List, PhysicalStore, org.ojalgo.structure.Access1D) to update RHS between solves.
    Preconditioners and solver compatibility Stopping criterion
    • Subclasses should measure a residual norm and stop when NumberContext.isSmall(double, double) deems it small relative to the RHS norm (or absolutely small when the RHS is zero), or when the iteration limit is reached.
    • Constructor Detail

      • IterativeSolverTask

        IterativeSolverTask()
    • Method Detail

      • preallocate

        public final PhysicalStore<java.lang.Double> preallocate​(int nbEquations,
                                                                 int nbVariables,
                                                                 int nbSolutions)
        Specified by:
        preallocate in interface SolverTask<java.lang.Double>
      • resolve

        public abstract double resolve​(java.util.List<Equation> equations,
                                       PhysicalStore<java.lang.Double> solution)
      • debug

        protected final void debug​(int iteration,
                                   double error,
                                   Access1D<?> current)
      • getAccuracyContext

        protected final NumberContext getAccuracyContext()
      • getIterationsLimit

        protected final int getIterationsLimit()
      • getPreconditioner

        protected final Preconditioner getPreconditioner()
      • getRelaxationFactor

        protected final double getRelaxationFactor()
      • isDebugPrinterSet

        protected final boolean isDebugPrinterSet()
      • setAccuracyContext

        protected final void setAccuracyContext​(NumberContext accuracyContext)
      • setDebugPrinter

        protected final void setDebugPrinter​(BasicLogger debugPrinter)
      • setIterationsLimit

        protected final void setIterationsLimit​(int iterationsLimit)
      • setPreconditioner

        protected final void setPreconditioner​(Preconditioner preconditioner)
      • setRelaxationFactor

        protected final void setRelaxationFactor​(double relaxation)