edu.uci.eecs.doc.clepsydra.ipet
Interface ILPSolver

All Known Implementing Classes:
GLPKAdapter, LPSolveAdapter

public interface ILPSolver

A common interface to integer linear programming libraries such as GLPK and lp_solve.

Author:
Trevor Harmon

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.
 

Method Detail

createProblem

void createProblem(int columns)
Initializes an ILP problem whose equation matrix will contain the specified number of columns (i.e., variables). After this method is called, all of the coefficients (i.e., rows) passed into this interface must be of length columns.

Parameters:
columns - the number of columns in the ILP equation matrix

setColumnName

void setColumnName(int column,
                   String name)
Provides a human-friendly name for the specified column in the ILP equation matrix.

Parameters:
column - a column index (first column is at index 1, not 0)
name - a human-friendly name for this column

getColumnName

String getColumnName(int column)
Returns the human-friendly name for the specified column in the ILP equation matrix, if one was set.

Parameters:
column - a column index (first column is at index 1, not 0)
Returns:
the name of the column, or null if no name has been set

addConstraint

void addConstraint(double[] coefficients,
                   int equalTo)
Adds an equality equation (i.e., row) to the ILP equation matrix. For example, if the ILP equation has 4 variables (x1, x2, x3, and x4), adding an equation of the form x2 + 5 x3 = 42 would be accomplished like this:
 double[] coefficients = {0, 1, 5, 0};
 ilpsolver.addConstraint(coefficients, 42);
 

Parameters:
coefficients - the coefficients of the equation (including zero coefficients)
equalTo - the right-hand side (a constant) of the equation

addInequalityConstraint

void addInequalityConstraint(double[] coefficients,
                             int lessThanOrEqualTo)
Adds an inequality equation (i.e., row) to the ILP equation matrix. For example, if the ILP equation has 4 variables (x1, x2, x3, and x4), adding an equation of the form x2 + 5 x3 <= 42 would be accomplished like this:
 double[] coefficients = {0, 1, 5, 0};
 ilpsolver.addInequalityConstraint(coefficients, 42);
 

Parameters:
coefficients - the coefficients of the equation (including zero coefficients)
lessThanOrEqualTo - the right-hand side (a constant) of the inequality

setMaximizeFunction

void setMaximizeFunction(double[] coefficients)
Provides the ILP solver with an equation to maximize.

Parameters:
coefficients - the coefficients of the equation (including zero coefficients)

getSolution

int getSolution()
Solves the ILP problem and returns the result.


saveModel

void saveModel(String filename)
               throws IOException
Saves a representation of the ILP problem to disk. The format is the "free" variant of the Mathematical Programming System (MPS) format.

Parameters:
filename - the name of a file in which to store the representation
Throws:
IOException - if the representation could not be saved to disk

destroyProblem

void destroyProblem()
Deallocates resources that had been allocated to solve the ILP problem.