Class Solver

java.lang.Object
solvers.linearSystemSolver.Solver
All Implemented Interfaces:
SolverInterface
Direct Known Subclasses:
ParallelSolver, SimpleSolver

public class Solver extends Object implements SolverInterface
Class which defines several methods every Solver object must support.
Author:
Michail Makaronidis, 2010
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected 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 int
    Represents how many times the elements in the positions list UList have been increased by 1.
    protected static final BigRational
    It is used to determine wheter the matrix A is singular.
    protected int
    The number of unknowns.
    protected Timer
    The 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(..).
    protected Set<Integer>
    The set of indices of possible zero-columns of A.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a Solver object.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the Timer object corresponding to this particular Solver.
    void
    goToULevel(int level)
    Sets matrices A and cleanA equal to the original A used during initialisation plus "level" increments in the positions needed.
    void
    Initialises the solver object.
    void
    initialise(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.
    void
    initialise(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.
    void
    Shutsdown the solver, terminating all pools of threads and child processes if any exist.
    Solves the linear system.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • t

      protected Timer t
      The Timer object corresponding to this Solver is responsible for storing and providing the total runtime.
    • A

      protected BigRational[][] A
      Holds the initial version of A, as calling solve(..) destroys A's contents (the calculations are performed in-place).
    • cleanA

      protected BigRational[][] cleanA
      Holds the initial version of A, as calling solve(..) destroys A's contents (the calculations are performed in-place).
    • b

      protected BigRational[] b
      The vector b of the linear system Ax = b.
    • curULevel

      protected int curULevel
      Represents how many times the elements in the positions list UList have been increased by 1.
    • UList

      protected List<Tuple<Integer,Integer>> UList
      The positions of elements of A that may need to be increased between successive invocations of solve(..). This is a requirement of the MoM algorithm, which was embedded in the Solver for performance reasons.
    • uncomputables

      protected Set<Integer> uncomputables
      The set of indices of possible zero-columns of A.
    • N

      protected int N
      The number of unknowns.
    • EPSILON

      protected static final BigRational EPSILON
      It is used to determine wheter the matrix A is singular.
  • Constructor Details

    • Solver

      public Solver()
      Constructs a Solver object.
  • Method Details

    • initialise

      public void initialise(BigRational[][] A) throws OperationNotSupportedException
      Initialises the solver object.
      Specified by:
      initialise in interface SolverInterface
      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 OperationNotSupportedException
      Initialises 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:
      initialise in interface SolverInterface
      Parameters:
      A - The matrix A of the linear system Ax = b
      UList - The list containing these positions as Tuple objects
      uncomputables - 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, InternalErrorException
      Initialises 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 = b
      UList - The list containing these positions as Tuple objects
      uncomputables - The set of indices of possible zero-columns of A
      maxA - The maximum possible element in matrix A
      maxb - The maximum possible element of vector b
      maxG - The maximum possible legal solution value
      Throws:
      OperationNotSupportedException - Thrown when the matrix A is not square
      InternalErrorException - 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:
      goToULevel in interface SolverInterface
      Parameters:
      level - The number of applications with regard to the original A
    • solve

      Solves the linear system.
      Specified by:
      solve in interface SolverInterface
      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 system
      InconsistentLinearSystemException - 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

      public Timer getTimer()
      Returns the Timer object corresponding to this particular Solver.
      Specified by:
      getTimer in interface SolverInterface
      Returns:
      The Timer object
    • shutdown

      public void shutdown()
      Shutsdown the solver, terminating all pools of threads and child processes if any exist.