net.sourceforge.combean.samples.mathprog.lp.matrixrounding
Class MatrixToRoundAsLP
java.lang.Object
net.sourceforge.combean.mathprog.lp.model.AbstractLPModelComponent
net.sourceforge.combean.mathprog.lp.model.AbstractSimpleIndexLPModelComponent
net.sourceforge.combean.mathprog.lp.model.AbstractSimpleIndexLPConstrainedRows
net.sourceforge.combean.mathprog.lp.model.AbstractSimpleIndexLPConstrainedRowsWithVars
net.sourceforge.combean.samples.mathprog.lp.matrixrounding.MatrixToRoundAsLP
- All Implemented Interfaces:
- AbstractMatrix, LPConstraintSequence, LPModelComponent, LPModelRows, LPVariableSequence
public class MatrixToRoundAsLP
- extends AbstractSimpleIndexLPConstrainedRowsWithVars
- implements LPModelRows, LPConstraintSequence, LPVariableSequence
A matrix rounding problem as linear program.
MatrixToRoundAsLP
public MatrixToRoundAsLP(Matrix matrixToRound)
- Constructor
- Parameters:
matrixToRound
- the matrix to be rounded
getNumColumns
public int getNumColumns()
- Description copied from interface:
AbstractMatrix
- Return the number of columns of the model component.
- Specified by:
getNumColumns
in interface AbstractMatrix
- Returns:
- the number of columns.
getNumRows
public int getNumRows()
- Description copied from interface:
AbstractMatrix
- Return the number of rows of the model component.
- Specified by:
getNumRows
in interface AbstractMatrix
- Returns:
- the number of rows.
getLPVariable
public LPVariable getLPVariable(int localColumn)
- Description copied from interface:
LPVariableSequence
- Return the LP variable for a given local column index.
- Specified by:
getLPVariable
in interface LPVariableSequence
- Parameters:
localColumn
- the local column index.
- Returns:
- the correponding LP variable.
getRowVector
public LPSparseVector getRowVector(int localRow)
- Specified by:
getRowVector
in interface LPModelRows
getLPConstraint
public LPConstraint getLPConstraint(int localRow)
- Description copied from interface:
LPConstraintSequence
- Get the constraint for a given (local) row index.
- Specified by:
getLPConstraint
in interface LPConstraintSequence
- Parameters:
localRow
- a local row index.
- Returns:
- the corresponding LP constraint.
getRoundedMatrix
public double[][] getRoundedMatrix(LPModelSolver solver)
- Translate the result of the solver back into a matrix of doubles
- Parameters:
solver
- the solver which has solved the model "this".
- Returns:
- the result given by the solver converted to a matrix of doubles.