Class TopLevelBlock
java.lang.Object
solvers.linearSystem.btf.ComponentBlock
solvers.linearSystem.btf.topLevelBlocks.TopLevelBlock
- Direct Known Subclasses:
ATopLevelBlock, B1Block, B2Block, CBlock
This class is a superclass for the five main components of the BTF linear system: X, Y, B1, B2 and C.
It is composed of MacroBlocks and implements the methods that intialise and handle them.
A MacroBlockSelectionPolicy must be specified by any concrete implementation, this will
be used to select which MacroBlocks to use in lower class linear systems.
- Author:
- Jack Bradshaw
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MacroBlock[]The list of Macro Blocks contained in the TopLevelBlockprotected MacroBlockSelectionPolicyEncapsulated policy for selecting macro blocks when creating sub-blocks for lower classesFields inherited from class ComponentBlock
basis, cols_printed, current_class, position, qnm, size -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTopLevelBlock(QNModel qnm, CoMoMBasis basis, Position position) Constructor - First phase of construction Initialises everything up to but not including the list of macro blocksprotectedTopLevelBlock(TopLevelBlock full_block, int current_class) Copy Constructor -
Method Summary
Modifier and TypeMethodDescriptionintaddCE(int position, PopulationChangeVector n, int queue) Adds the appropriate coefficients of a Convolution Expression to the blockintaddPC(int position, PopulationChangeVector n, int _class) Adds the appropriate coefficients of a Population Constraint to the blockprotected intfindMacroBlock(int position) Finds the macro which contains a specified column (row)voidSecond Phase of Construction This method intialises the list component macro blocks.voidmultiply(BigRational[] result) Carries out the appropriate matrix multiplication operation for the blockprotected abstract MacroBlocknewMacroBlock(Position position, int h) Factory Method for Macro Blocks To be overridden by subclasses in order to create the appropriate subclass of MacroBlock in the parallel hierarchy.voidprintRow2(int row) Prints a line of the block if the contains therow.voidsolve(BigRational[] rhs) Makes the block carry out its role in the solution of the linear systemsubBlock(int current_class) Builder method that encapsulates the creation of sub-TopLevelBlocksprotected abstract TopLevelBlocksubBlockCopy(int current_class) Factory Method for sub-block creation This method is to be overridden by subclasses to instantiate a copy of the current block of correct typeMethods inherited from class ComponentBlock
getStartingCol, getStartingRow, newLine, size
-
Field Details
-
macro_blocks
The list of Macro Blocks contained in the TopLevelBlock -
selection_policy
Encapsulated policy for selecting macro blocks when creating sub-blocks for lower classes
-
-
Constructor Details
-
TopLevelBlock
protected TopLevelBlock(QNModel qnm, CoMoMBasis basis, Position position) throws BTFMatrixErrorException, InternalErrorException, InconsistentLinearSystemException Constructor - First phase of construction Initialises everything up to but not including the list of macro blocks- Parameters:
qnm- The Model under considerationbasis- The corresponding basis for the modelposition- The starting position (top right hand corner) of the block- Throws:
BTFMatrixErrorExceptionInternalErrorExceptionInconsistentLinearSystemException- See Also:
-
TopLevelBlock
Copy Constructor
-
-
Method Details
-
initialise
public void initialise() throws BTFMatrixErrorException, InternalErrorException, InconsistentLinearSystemExceptionSecond Phase of Construction This method intialises the list component macro blocks. -
newMacroBlock
protected abstract MacroBlock newMacroBlock(Position position, int h) throws InternalErrorException, InconsistentLinearSystemException Factory Method for Macro Blocks To be overridden by subclasses in order to create the appropriate subclass of MacroBlock in the parallel hierarchy. i.e. XBlocks are composed of XMacroBlocks- Parameters:
position- Starting position for the new macro blockh- Number of non-zeros associated with the macro block- Throws:
InternalErrorExceptionInconsistentLinearSystemException
-
subBlockCopy
protected abstract TopLevelBlock subBlockCopy(int current_class) throws BTFMatrixErrorException, InternalErrorException, InconsistentLinearSystemException Factory Method for sub-block creation This method is to be overridden by subclasses to instantiate a copy of the current block of correct type- Parameters:
current_class- The class for which the copy is created- Returns:
- A shallow copy of calling block, for the current_class. Without macro blocks.
- Throws:
BTFMatrixErrorExceptionInternalErrorExceptionInconsistentLinearSystemException
-
subBlock
public TopLevelBlock subBlock(int current_class) throws BTFMatrixErrorException, InternalErrorException, InconsistentLinearSystemException Builder method that encapsulates the creation of sub-TopLevelBlocks- Parameters:
current_class- The class for which the copy is created- Returns:
- A shallow copy of calling block, containing the correct macro blocks for the current_class
- Throws:
BTFMatrixErrorExceptionInternalErrorExceptionInconsistentLinearSystemException
-
findMacroBlock
Finds the macro which contains a specified column (row)- Parameters:
position- The number of the column (row)- Returns:
- The index of containing MacroBlock in the list
macro_blocks - Throws:
BTFMatrixErrorException
-
addCE
public int addCE(int position, PopulationChangeVector n, int queue) throws BTFMatrixErrorException, InternalErrorException Description copied from class:ComponentBlockAdds the appropriate coefficients of a Convolution Expression to the block- Specified by:
addCEin classComponentBlock- Parameters:
position- Carries information on where to insert the equation depending on the context (can be interpreted differently by subclasses)n- The Population Change Vector n to which the equation relatesqueue- The queue k to which the equation relates; 1 <= k <= M- Returns:
- The row at which the equation was inserted
- Throws:
BTFMatrixErrorExceptionInternalErrorException
-
addPC
public int addPC(int position, PopulationChangeVector n, int _class) throws BTFMatrixErrorException, InternalErrorException Description copied from class:ComponentBlockAdds the appropriate coefficients of a Population Constraint to the block- Specified by:
addPCin classComponentBlock- Parameters:
position- Carries information on where to insert the equation depending on the context (can be interpreted differently by subclasses)n- The Population Change Vector n to which the equation relates_class- The class r to which the equation relates; 1 <= r <= R- Returns:
- The row at which the equation was inserted
- Throws:
BTFMatrixErrorExceptionInternalErrorException
-
multiply
Description copied from class:ComponentBlockCarries out the appropriate matrix multiplication operation for the block- Specified by:
multiplyin classComponentBlock- Parameters:
result- Result vector- Throws:
BTFMatrixErrorException
-
solve
public void solve(BigRational[] rhs) throws BTFMatrixErrorException, OperationNotSupportedException, InconsistentLinearSystemException, InternalErrorException Description copied from class:ComponentBlockMakes the block carry out its role in the solution of the linear system- Specified by:
solvein classComponentBlock- Parameters:
rhs- The intermediate basis used during the computation of the solution- Throws:
BTFMatrixErrorExceptionOperationNotSupportedExceptionInconsistentLinearSystemExceptionInternalErrorException
-
printRow2
public void printRow2(int row) Description copied from class:ComponentBlockPrints a line of the block if the contains therow. The number of columns printed for the current row is incremented accordingly.- Specified by:
printRow2in classComponentBlock- Parameters:
row- The absolute row of the overall matrix to be printed.
-