Class MacroBlock
java.lang.Object
solvers.linearSystem.btf.ComponentBlock
solvers.linearSystem.btf.macroBlocks.MacroBlock
- Direct Known Subclasses:
B1MacroBlock, B2MacroBlock, CMacroBlock, XMacroBlock, YMacroBlock
This class is a superclass for the Macro Blocks of the five main components of the BTF linear system: X, Y, B1, B2 and C.
A MacroBlock is composed of MicroBlocks and implements the methods that intialise and handle them.
A MicroBlockSelectionPolicy must be specified by any concrete implementation, this will
be used to select which MicroBlocks are to use in lower class linear systems.
- Author:
- Jack Bradshaw
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intNumber of non-zeros in n associated to macro blockprotected MicroBlock[]Array of contained micro blocksprotected MicroBlockSelectionPolicyEncapsulated policy for selecting micro blocks when creating sub-blocks for lower classesFields inherited from class ComponentBlock
basis, cols_printed, current_class, position, qnm, size -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMacroBlock(QNModel qnm, CoMoMBasis basis, Position position, int h) Constructor - First phase of construction Initialises everything up to but not including the list of micro blocksprotectedMacroBlock(MacroBlock 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 blockvoidSecond Phase of Construction This method initialises the list component micro blocks.voidmultiply(BigRational[] result) Carries out the appropriate matrix multiplication operation for the blockprotected abstract MicroBlocknewMicroBlock(Position block_position, int h) Factory Method for Micro Blocks To be overridden by subclasses in order to create the appropriate subclass of MacroBlock in the parallel hierarchy.protected intMethod numberOfMicroBlocks.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-MacroBlockprotected abstract MacroBlocksubBlockCopy(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 the correct type) For instance, a copy of an XMacroBlocks needs to be a XMacroBlockMethods inherited from class ComponentBlock
getStartingCol, getStartingRow, newLine, size
-
Field Details
-
micro_blocks
Array of contained micro blocks -
selection_policy
Encapsulated policy for selecting micro blocks when creating sub-blocks for lower classes -
h
protected int hNumber of non-zeros in n associated to macro block
-
-
Constructor Details
-
MacroBlock
protected MacroBlock(QNModel qnm, CoMoMBasis basis, Position position, int h) throws InternalErrorException, InconsistentLinearSystemException Constructor - First phase of construction Initialises everything up to but not including the list of micro blocks- Parameters:
qnm- The Model under considerationbasis- The corresponding basis for the modelposition- The starting position (top right hand corner) of the block- Throws:
InternalErrorExceptionInconsistentLinearSystemException- See Also:
-
MacroBlock
Copy Constructor- Parameters:
full_block- Block to be copiedcurrent_class- The class for which the copy is being created
-
-
Method Details
-
initialise
Second Phase of Construction This method initialises the list component micro blocks. -
newMicroBlock
protected abstract MicroBlock newMicroBlock(Position block_position, int h) throws InternalErrorException, InconsistentLinearSystemException Factory Method for Micro Blocks To be overridden by subclasses in order to create the appropriate subclass of MacroBlock in the parallel hierarchy. i.e. XMacroBlocks are composed of XMicroBlocks- Parameters:
block_position- Starting position for the new macro blockh- Number of non-zeros associated with the macro block- Throws:
InternalErrorExceptionInconsistentLinearSystemException
-
subBlock
Builder method that encapsulates the creation of sub-MacroBlock- Parameters:
current_class- The class for which the copy is being created- Returns:
- A shallow copy of calling block, containing the correct micro blocks for the current_class
-
subBlockCopy
Factory Method for sub-block creation This method is to be overridden by subclasses to instantiate a copy of the current block (of the correct type) For instance, a copy of an XMacroBlocks needs to be a XMacroBlock- Parameters:
current_class- The class for which the copy is created- Returns:
- A shallow copy of calling block, for the current_class. Without micro blocks.
-
numberOfMicroBlocks
protected int numberOfMicroBlocks()Method numberOfMicroBlocks.- Returns:
- The number of micro blocks contain in this macro block
-
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.
-