Class MutableSolver
java.lang.Object
org.ojalgo.matrix.task.iterative.MutableSolver
- All Implemented Interfaces:
MatrixTask<Double>, SolverTask<Double>
- Direct Known Subclasses:
IterativeASS.SchurComplementSolver
Lightweight mutable wrapper around a list of
Equation rows that delegates solving to an
IterativeSolverTask.
Purpose
- Build and update an equation system incrementally by adding/removing
Equationrows. - Reuse an iterative solver across solves without rebuilding matrices.
- Support workflows where the active rows/columns change between iterations.
- Subclass to define the problem size and to provide the delegate iterative solver.
- Call
add(Equation)andremove(Equation)to maintain the active set of rows. Rows are kept sorted by theirEquation.index. - Call
resolve(PhysicalStore)(orresolve(PhysicalStore, Access1D)) to solve [A][x]=[b] using the current rows and right-hand sides stored in eachEquation. - All methods that solve or preallocate simply forward to the delegate.
- Every added
Equationmust haveEquation.size()equal to the problem size passed to the constructor; otherwise anIllegalArgumentExceptionis thrown. - The provided
solutionvector represents the active variable subspace; residuals are formed against that vector and the current row bodies only. - Thread-safety: instances are not thread-safe; do not mutate the row set while solving.
- A subclass can also implement
MatrixStoreand dynamically assemble a Schur-complement-style system by adding/removing rows, and then callresolve(PhysicalStore)to compute the unknowns.
-
Nested Class Summary
Nested classes/interfaces inherited from interface SolverTask
SolverTask.Factory<N> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclear()protected doubledoubleValue(int row, int col) protected final IterativeSolverTaskpreallocate(int nbEquations, int nbVariables, int nbSolutions) booleandoubleresolve(PhysicalStore<Double> solution) A variation of solve(Access2D, Access2D, PhysicalStore) where the system body has already been set up usingadd(Equation).doubleresolve(PhysicalStore<Double> solution, Access1D<?> rhs) Same asresolve(PhysicalStore)but replaces the RHS values before solving.solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<Double> current) Exactly how (if at all) a specific implementation makes use ofpreallocatedis not specified by this interface.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SolverTask
preallocate, solve, toSolutionProvider
-
Field Details
-
myDelegate
-
myRows
-
mySize
private final int mySize
-
-
Constructor Details
-
MutableSolver
-
-
Method Details
-
add
-
clear
public void clear() -
preallocate
- Specified by:
preallocatein interfaceSolverTask<Double>
-
remove
-
resolve
A variation of solve(Access2D, Access2D, PhysicalStore) where the system body has already been set up usingadd(Equation). Solves the current [A][x]=[b] using the delegate iterative solver. -
resolve
Same asresolve(PhysicalStore)but replaces the RHS values before solving. -
solve
public MatrixStore<Double> solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<Double> current) throws RecoverableCondition Description copied from interface:SolverTaskExactly how (if at all) a specific implementation makes use of
preallocatedis not specified by this interface. It must be documented for each implementation.Should produce the same results as calling
SolverTask.solve(Access2D, Access2D).Use
SolverTask.preallocate(Structure2D, Structure2D)to obtain a suitbalepreallocated.- Specified by:
solvein interfaceSolverTask<Double>- Parameters:
rhs- The Right Hand Side, wont be modfiedcurrent- Preallocated memory for the results, possibly some intermediate results. You must assume this is modified, but you cannot assume it will contain the full/ /correct solution.- Returns:
- The solution
- Throws:
RecoverableCondition
-
doubleValue
protected double doubleValue(int row, int col) -
equations
-
getDelegate
-