LBJ2.infer
Interface ILPSolver

All Known Implementing Classes:
GLPKHook, XpressMPHook

public interface ILPSolver

Classes that implement this interface contain implementations of algorithms that solve Integer Linear Programming problems.


Method Summary
 int addBooleanVariable(double c)
          Adds a new Boolean variable (an integer variable constrained to take either the value 0 or the value 1) with the specified coefficient in the objective function to the problem.
 int[] addDiscreteVariable(double[] c)
          Adds a general, multi-valued discrete variable, which is implemented as a set of Boolean variables, one per value of the discrete variable, with exactly one of those variables set true at any given time.
 int[] addDiscreteVariable(Score[] c)
          Adds a general, multi-valued discrete variable, which is implemented as a set of Boolean variables, one per value of the discrete variable, with exactly one of those variables set true at any given time.
 void addEqualityConstraint(int[] i, double[] a, double b)
          Adds a new fixed constraint to the problem.
 void addGreaterThanConstraint(int[] i, double[] a, double b)
          Adds a new lower bounded constraint to the problem.
 void addLessThanConstraint(int[] i, double[] a, double b)
          Adds a new upper bounded constraint to the problem.
 boolean getBooleanValue(int index)
          When the problem has been solved, use this method to retrieve the value of any Boolean inference variable.
 boolean isSolved()
          Tests whether the problem represented by this ILPSolver instance has been solved already.
 void reset()
          This method clears the all constraints and variables out of the ILP solver's problem representation, bringing the ILPSolver instance back to the state it was in when first constructed.
 void setMaximize(boolean d)
          Sets the direction of the objective function.
 boolean solve()
          Solves the ILP problem, saving the solution internally.
 void write(java.lang.StringBuffer buffer)
          Creates a textual representation of the ILP problem in an algebraic notation.
 

Method Detail

setMaximize

void setMaximize(boolean d)
Sets the direction of the objective function.

Parameters:
d - true if the objective function is to be maximized.

addBooleanVariable

int addBooleanVariable(double c)
Adds a new Boolean variable (an integer variable constrained to take either the value 0 or the value 1) with the specified coefficient in the objective function to the problem.

Parameters:
c - The objective function coefficient for the new Boolean variable.
Returns:
The indexes of the created variable.

addDiscreteVariable

int[] addDiscreteVariable(double[] c)
Adds a general, multi-valued discrete variable, which is implemented as a set of Boolean variables, one per value of the discrete variable, with exactly one of those variables set true at any given time.

Parameters:
c - The objective function coefficients for the new Boolean variables.
Returns:
The indexes of the newly created variables.

addDiscreteVariable

int[] addDiscreteVariable(Score[] c)
Adds a general, multi-valued discrete variable, which is implemented as a set of Boolean variables, one per value of the discrete variable, with exactly one of those variables set true at any given time.

Parameters:
c - An array of Scores containing the objective function coefficients for the new Boolean variables.
Returns:
The indexes of the newly created variables.

addEqualityConstraint

void addEqualityConstraint(int[] i,
                           double[] a,
                           double b)
Adds a new fixed constraint to the problem. The two array arguments must be the same length, as their elements correspond to each other. Variables whose coefficients are zero need not be mentioned. Variables that are mentioned must have previously been added via addBooleanVariable(double) or addDiscreteVariable(double[]). The resulting constraint has the form:
xi * a = b
where xi represents the inference variables whose indexes are contained in the array i and * represents dot product.

Parameters:
i - The indexes of the variables with non-zero coefficients.
a - The coefficients of the variables with the given indexes.
b - The new constraint will enforce equality with this constant.

addGreaterThanConstraint

void addGreaterThanConstraint(int[] i,
                              double[] a,
                              double b)
Adds a new lower bounded constraint to the problem. The two array arguments must be the same length, as their elements correspond to each other. Variables whose coefficients are zero need not be mentioned. Variables that are mentioned must have previously been added via addBooleanVariable(double) or addDiscreteVariable(double[]). The resulting constraint has the form:
xi * a >= b
where xi represents the inference variables whose indexes are contained in the array i and * represents dot product.

Parameters:
i - The indexes of the variables with non-zero coefficients.
a - The coefficients of the variables with the given indexes.
b - The lower bound for the new constraint.

addLessThanConstraint

void addLessThanConstraint(int[] i,
                           double[] a,
                           double b)
Adds a new upper bounded constraint to the problem. The two array arguments must be the same length, as their elements correspond to each other. Variables whose coefficients are zero need not be mentioned. Variables that are mentioned must have previously been added via addBooleanVariable(double) or addDiscreteVariable(double[]). The resulting constraint has the form:
xi * a <= b
where xi represents the inference variables whose indexes are contained in the array i and * represents dot product.

Parameters:
i - The indexes of the variables with non-zero coefficients.
a - The coefficients of the variables with the given indexes.
b - The upper bound for the new constraint.

solve

boolean solve()
              throws java.lang.Exception
Solves the ILP problem, saving the solution internally. This method may throw an exception if something doesn't go right.

Throws:
java.lang.Exception

isSolved

boolean isSolved()
Tests whether the problem represented by this ILPSolver instance has been solved already.


getBooleanValue

boolean getBooleanValue(int index)
When the problem has been solved, use this method to retrieve the value of any Boolean inference variable. The result of this method is undefined when the problem has not yet been solved.

Parameters:
index - The index of the variable whose value is requested.
Returns:
The value of the variable.

reset

void reset()
This method clears the all constraints and variables out of the ILP solver's problem representation, bringing the ILPSolver instance back to the state it was in when first constructed.


write

void write(java.lang.StringBuffer buffer)
Creates a textual representation of the ILP problem in an algebraic notation.

Parameters:
buffer - The created textual representation will be appended here.