Package nl.tue.astar.util.ilp
Class LPMatrix.DENSE.GUROBI
- java.lang.Object
-
- nl.tue.astar.util.ilp.LPMatrix.DENSE.GUROBI
-
- All Implemented Interfaces:
LPMatrix<gurobi.GRBModel>
- Enclosing class:
- LPMatrix.DENSE
public static class LPMatrix.DENSE.GUROBI extends java.lang.ObjectThe dense variant for the Gurobi external solver. Needs a GurobiEnvironment as input.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface nl.tue.astar.util.ilp.LPMatrix
LPMatrix.DENSE, LPMatrix.SPARSE
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]colNamesprotected byte[]integerprotected booleanisMinimizingprotected double[]lowBoprotected double[][]matrixprotected double[]objprotected intoffsetprotected double[]rhsprotected java.lang.String[]rowNamesprotected intsolverResultprotected byte[]typesprotected double[]upBo
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadjustMat(int row, int column, double value)adjusts the value at index row, column in the matrix.intbytesUsed()returns the number of bytes occupied by the main arrays in this class.java.lang.StringgetColName(int column)Gets the name of a column, or null if there is none.java.lang.String[]getColNames()Returns the column names or null if there are none.bytegetConstrType(int r)intgetLastSolverResult()returns the last result returned by the external solver.doublegetlowBo(int c)doublegetMat(int row, int column)Return the value at index row, column in the MIP matrix.intgetNcolumns()intgetNrows()doublegetObjective(int column)intgetOffset()doublegetRh(int row)protected double[]getRow(int row)java.lang.StringgetRowName(int r)java.lang.String[]getRowNames()doublegetUpBo(int c)bytegetVarType(int c)doubleobjectiveValue(double[] vars)voidprintLp(java.io.OutputStreamWriter writer, java.lang.String sep)prints the LP to the given outputWriter using the given separator character as separator.voidprintLpToCSV(java.lang.String fileName)Prints the MIP to a CSV file using ";" as a separator character.doubleproduct(double[] vars, int fromIncluding, int toExcluding, int row)voidsetBinary(int c, boolean b)voidsetColName(int column, java.lang.String name)Sets the name of a column.voidsetConstrType(int row, byte type)voidsetInt(int column, boolean isInt)voidsetLowbo(int column, double value)voidsetMat(int row, int column, double value)set the value at index row, column in the matrix.voidsetMaxim()voidsetMinim()voidsetObjective(int column, double value)voidsetRh(int row, double value)voidsetRhVec(double[] rhs)voidsetRowName(int row, java.lang.String name)Sets the name of a row.voidsetUpbo(int column, double value)intsolve(double[] vars)Constructs the solver and solves the MIP represented by this problem.gurobi.GRBModeltoSolver()Constructs the solver in its external representation
-
-
-
Field Detail
-
matrix
protected final double[][] matrix
-
offset
protected final int offset
-
rhs
protected final double[] rhs
-
types
protected final byte[] types
-
rowNames
protected java.lang.String[] rowNames
-
obj
protected final double[] obj
-
upBo
protected final double[] upBo
-
lowBo
protected final double[] lowBo
-
colNames
protected java.lang.String[] colNames
-
integer
protected final byte[] integer
-
isMinimizing
protected boolean isMinimizing
-
solverResult
protected int solverResult
-
-
Constructor Detail
-
GUROBI
public GUROBI(gurobi.GRBEnv env, int rows, int columns)
-
GUROBI
public GUROBI(gurobi.GRBEnv env, LPMatrix<?> matrix)
-
-
Method Detail
-
toSolver
public gurobi.GRBModel toSolver() throws LPMatrixExceptionDescription copied from interface:LPMatrixConstructs the solver in its external representation- Returns:
- Throws:
LPMatrixException
-
solve
public int solve(double[] vars) throws LPMatrixExceptionDescription copied from interface:LPMatrixConstructs the solver and solves the MIP represented by this problem. The returned value is either OPTIMAL, INFEASIBLE or OTHER. The external solver's result can be obtained through getLastSolverResult()- Parameters:
vars- an array dimensioned in the number of columns, i.e. vars.length == getNColumns(). This is not checked!- Returns:
- Throws:
LPMatrixException- if the external solver throws an exception
-
getMat
public double getMat(int row, int column)Description copied from interface:LPMatrixReturn the value at index row, column in the MIP matrix.- Returns:
-
setMat
public void setMat(int row, int column, double value)Description copied from interface:LPMatrixset the value at index row, column in the matrix.
-
adjustMat
public void adjustMat(int row, int column, double value)Description copied from interface:LPMatrixadjusts the value at index row, column in the matrix.
-
getNrows
public int getNrows()
-
getNcolumns
public int getNcolumns()
-
getRow
protected double[] getRow(int row)
-
bytesUsed
public int bytesUsed()
returns the number of bytes occupied by the main arrays in this class.- Returns:
-
getLastSolverResult
public int getLastSolverResult()
Description copied from interface:LPMatrixreturns the last result returned by the external solver. This method only makes sense after a call to solve() that did not throw an exception.- Specified by:
getLastSolverResultin interfaceLPMatrix<S>- Returns:
-
setUpbo
public void setUpbo(int column, double value)
-
setLowbo
public void setLowbo(int column, double value)
-
setColName
public void setColName(int column, java.lang.String name)Description copied from interface:LPMatrixSets the name of a column. Setting names is not required and no memory is reserved for column names until the first name is set on a column.- Specified by:
setColNamein interfaceLPMatrix<S>
-
setRowName
public void setRowName(int row, java.lang.String name)Description copied from interface:LPMatrixSets the name of a row. Setting names is not required and no memory is reserved for row names until the first name is set on a row.- Specified by:
setRowNamein interfaceLPMatrix<S>
-
setConstrType
public void setConstrType(int row, byte type)- Specified by:
setConstrTypein interfaceLPMatrix<S>
-
setObjective
public void setObjective(int column, double value)- Specified by:
setObjectivein interfaceLPMatrix<S>
-
getColName
public java.lang.String getColName(int column)
Description copied from interface:LPMatrixGets the name of a column, or null if there is none.- Specified by:
getColNamein interfaceLPMatrix<S>- Returns:
-
getObjective
public double getObjective(int column)
- Specified by:
getObjectivein interfaceLPMatrix<S>
-
getColNames
public java.lang.String[] getColNames()
Description copied from interface:LPMatrixReturns the column names or null if there are none.- Specified by:
getColNamesin interfaceLPMatrix<S>- Returns:
-
product
public double product(double[] vars, int fromIncluding, int toExcluding, int row)
-
objectiveValue
public double objectiveValue(double[] vars)
- Specified by:
objectiveValuein interfaceLPMatrix<S>
-
printLp
public void printLp(java.io.OutputStreamWriter writer, java.lang.String sep) throws java.io.IOExceptionDescription copied from interface:LPMatrixprints the LP to the given outputWriter using the given separator character as separator. The output of this method on System.out, with "\t" as the separator returns the same representation as LpSolve's printLp() method.
-
printLpToCSV
public void printLpToCSV(java.lang.String fileName) throws java.io.IOExceptionDescription copied from interface:LPMatrixPrints the MIP to a CSV file using ";" as a separator character. If row and column names are provided they are printed, otherwise, they are numbered- Specified by:
printLpToCSVin interfaceLPMatrix<S>- Throws:
java.io.IOException
-
getRowNames
public java.lang.String[] getRowNames()
- Specified by:
getRowNamesin interfaceLPMatrix<S>
-
getVarType
public byte getVarType(int c)
- Specified by:
getVarTypein interfaceLPMatrix<S>
-
getConstrType
public byte getConstrType(int r)
- Specified by:
getConstrTypein interfaceLPMatrix<S>
-
getRowName
public java.lang.String getRowName(int r)
- Specified by:
getRowNamein interfaceLPMatrix<S>
-
-