Class Solver
java.lang.Object
solvers.linearSystemSolver.Solver
- All Implemented Interfaces:
SolverInterface
- Direct Known Subclasses:
ParallelSolver, SimpleSolver
Class which defines several methods every Solver object must
support.
- Author:
- Michail Makaronidis, 2010
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BigRational[][]Holds the initial version of A, as calling solve(..) destroys A's contents (the calculations are performed in-place).protected BigRational[]The vector b of the linear system Ax = b.protected BigRational[][]Holds the initial version of A, as calling solve(..) destroys A's contents (the calculations are performed in-place).protected intRepresents how many times the elements in the positions list UList have been increased by 1.protected static final BigRationalIt is used to determine wheter the matrix A is singular.protected intThe number of unknowns.protected TimerThe Timer object corresponding to this Solver is responsible for storing and providing the total runtime.The positions of elements of A that may need to be increased between successive invocations of solve(..).The set of indices of possible zero-columns of A. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetTimer()Returns the Timer object corresponding to this particular Solver.voidgoToULevel(int level) Sets matrices A and cleanA equal to the original A used during initialisation plus "level" increments in the positions needed.voidinitialise(BigRational[][] A) Initialises the solver object.voidinitialise(BigRational[][] A, List<Tuple<Integer, Integer>> UList, Set<Integer> uncomputables) Initialises the solver object, taking into account a list of positions of A that may need to be updated when requested.voidinitialise(BigRational[][] A, List<Tuple<Integer, Integer>> UList, Set<Integer> uncomputables, int maxA, BigInteger maxb, BigRational maxG) Initialises the solver object, taking into account a list of positions of A that may need to be updated when requested.voidshutdown()Shutsdown the solver, terminating all pools of threads and child processes if any exist.solve(BigRational[] b) Solves the linear system.
-
Field Details
-
t
The Timer object corresponding to this Solver is responsible for storing and providing the total runtime. -
A
Holds the initial version of A, as calling solve(..) destroys A's contents (the calculations are performed in-place). -
cleanA
Holds the initial version of A, as calling solve(..) destroys A's contents (the calculations are performed in-place). -
b
The vector b of the linear system Ax = b. -
curULevel
protected int curULevelRepresents how many times the elements in the positions list UList have been increased by 1. -
UList
-
uncomputables
-
N
protected int NThe number of unknowns. -
EPSILON
It is used to determine wheter the matrix A is singular.
-
-
Constructor Details
-
Solver
public Solver()Constructs a Solver object.
-
-
Method Details
-
initialise
Initialises the solver object.- Specified by:
initialisein interfaceSolverInterface- Parameters:
A- The matrix A of the linear system Ax = b- Throws:
OperationNotSupportedException- Thrown when the matrix A is not square
-
initialise
public void initialise(BigRational[][] A, List<Tuple<Integer, Integer>> UList, Set<Integer> uncomputables) throws OperationNotSupportedExceptionInitialises the solver object, taking into account a list of positions of A that may need to be updated when requested. This is needed by the MoM algorithm.- Specified by:
initialisein interfaceSolverInterface- Parameters:
A- The matrix A of the linear system Ax = bUList- The list containing these positions as Tuple objectsuncomputables- the uncomputables- Throws:
OperationNotSupportedException- Thrown when the matrix A is not square
-
initialise
public void initialise(BigRational[][] A, List<Tuple<Integer, Integer>> UList, Set<Integer> uncomputables, int maxA, BigInteger maxb, BigRational maxG) throws OperationNotSupportedException, InternalErrorExceptionInitialises the solver object, taking into account a list of positions of A that may need to be updated when requested. This is needed by the MoM algorithm. Furthermore, some bounds of the maximum elements contained in the linear systems (max A, max B, max Solution = max G) are given.- Parameters:
A- The matrix A of the linear system Ax = bUList- The list containing these positions as Tuple objectsuncomputables- The set of indices of possible zero-columns of AmaxA- The maximum possible element in matrix Amaxb- The maximum possible element of vector bmaxG- The maximum possible legal solution value- Throws:
OperationNotSupportedException- Thrown when the matrix A is not squareInternalErrorException- Thrown when any unrecoverable internal error is encountered during initialisation
-
goToULevel
public void goToULevel(int level) Sets matrices A and cleanA equal to the original A used during initialisation plus "level" increments in the positions needed. See how the MoM algorithm updates A during the iterations.- Specified by:
goToULevelin interfaceSolverInterface- Parameters:
level- The number of applications with regard to the original A
-
solve
public BigRational[] solve(BigRational[] b) throws OperationNotSupportedException, InconsistentLinearSystemException, InternalErrorException Solves the linear system.- Specified by:
solvein interfaceSolverInterface- Parameters:
b- The vector b of the linear system Ax = b- Returns:
- A vector containing the solutions of the linear system
- Throws:
OperationNotSupportedException- Thrown always, as this Solver does not support actual solution of the systemInconsistentLinearSystemException- Thrown when the algorithm should return an undeterminable, from the initial linear system, value.InternalErrorException- Thrown when an unrecoverable internal error has been detected by the solver.
-
getTimer
Returns the Timer object corresponding to this particular Solver.- Specified by:
getTimerin interfaceSolverInterface- Returns:
- The Timer object
-
shutdown
public void shutdown()Shutsdown the solver, terminating all pools of threads and child processes if any exist.
-