|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.uci.eecs.doc.clepsydra.ipet.LPSolveAdapter
public class LPSolveAdapter
Provides an implementation of the ILPSolver
interface for lp_solve.
Constructor Summary | |
---|---|
LPSolveAdapter()
|
Method Summary | |
---|---|
void |
addConstraint(double[] coefficients,
int equalTo)
Adds an equality equation (i.e., row) to the ILP equation matrix. |
void |
addInequalityConstraint(double[] coefficients,
int lessThanOrEqualTo)
Adds an inequality equation (i.e., row) to the ILP equation matrix. |
void |
createProblem(int columns)
Initializes an ILP problem whose equation matrix will contain the specified number of columns (i.e., variables). |
void |
destroyProblem()
Deallocates resources that had been allocated to solve the ILP problem. |
String |
getColumnName(int column)
Returns the human-friendly name for the specified column in the ILP equation matrix, if one was set. |
int |
getSolution()
Solves the ILP problem and returns the result. |
void |
saveModel(String filename)
Saves a representation of the ILP problem to disk. |
void |
setColumnName(int column,
String name)
Provides a human-friendly name for the specified column in the ILP equation matrix. |
void |
setMaximizeFunction(double[] coefficients)
Provides the ILP solver with an equation to maximize. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LPSolveAdapter()
Method Detail |
---|
public void createProblem(int columns)
columns
.
createProblem
in interface ILPSolver
columns
- the number of columns in the ILP equation matrix
ILPException
- if the problem could not be createdpublic void setColumnName(int column, String name)
setColumnName
in interface ILPSolver
column
- a column index (first column starts at 1, not 0)name
- a human-friendly name for this column
ILPException
- if the column name could not be setpublic String getColumnName(int column)
getColumnName
in interface ILPSolver
column
- a column index (first column is at index 1, not 0)
ILPException
- if the column name could not be retrievedpublic void addConstraint(double[] coefficients, int equalTo)
x2 + 5 x3 = 42
would be accomplished like this:
double[] coefficients = {0, 1, 5, 0}; ilpsolver.addConstraint(coefficients, 42);
addConstraint
in interface ILPSolver
coefficients
- the coefficients of the equation (including zero coefficients)equalTo
- the right-hand side (a constant) of the equation
ILPException
- if the constraint could not be addedpublic void addInequalityConstraint(double[] coefficients, int lessThanOrEqualTo)
x2 + 5 x3 <= 42
would be accomplished like this:
double[] coefficients = {0, 1, 5, 0}; ilpsolver.addInequalityConstraint(coefficients, 42);
addInequalityConstraint
in interface ILPSolver
coefficients
- the coefficients of the equation (including zero coefficients)lessThanOrEqualTo
- the right-hand side (a constant) of the equation
ILPException
- if the constraint could not be addedpublic void setMaximizeFunction(double[] coefficients)
setMaximizeFunction
in interface ILPSolver
coefficients
- the coefficients of the equation (including zero
coefficients)
ILPException
- if the function could not be setpublic int getSolution()
getSolution
in interface ILPSolver
ILPException
- if the solution is infeasible or some other error occurredpublic void saveModel(String filename) throws IOException
saveModel
in interface ILPSolver
filename
- the name of a file in which to store the representation
IOException
- if the representation could not be saved to diskpublic void destroyProblem()
destroyProblem
in interface ILPSolver
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |