public interface ILPSolver
Modifier and Type | Field and Description |
---|---|
static int |
VERBOSITY_HIGH
A possible setting for
#verbosity . |
static int |
VERBOSITY_LOW
A possible setting for
#verbosity . |
static int |
VERBOSITY_NONE
A possible setting for
#verbosity . |
Modifier and Type | Method and Description |
---|---|
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. |
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.
|
int |
addIntegerVariable(double c)
Adds a new Integer variable with the specified coefficient in the objective function to the
problem.
|
void |
addLessThanConstraint(int[] i,
double[] a,
double b)
Adds a new upper bounded constraint to the problem.
|
int |
addRealVariable(double c)
Adds a new Real variable with the specified coefficient in the objective function 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.
|
int |
getIntegerValue(int index)
When the problem has been solved, use this method to retrieve the value of any Integer
inference variable.
|
double |
getRealValue(int index)
When the problem has been solved, use this method to retrieve the value of any Real inference
variable.
|
boolean |
isSolved()
Tests whether the problem represented by this
ILPSolver instance has been solved
already. |
double |
objectiveCoeff(int index)
The coefficient of the variable in the objective function.
|
double |
objectiveValue()
When the problem has been solved, use this method to retrieve the value of the objective
function at the solution.
|
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(StringBuffer buffer)
Creates a textual representation of the ILP problem in an algebraic notation.
|
static final int VERBOSITY_NONE
#verbosity
.static final int VERBOSITY_LOW
#verbosity
.static final int VERBOSITY_HIGH
#verbosity
.void setMaximize(boolean d)
d
- true
if the objective function is to be maximized.int addBooleanVariable(double c)
c
- The objective function coefficient for the new Boolean variable.int addRealVariable(double c)
c
- The objective function coefficient for the new Real variable.int addIntegerVariable(double c)
c
- The objective function coefficient for the new Integer variable.int[] addDiscreteVariable(double[] c)
true
at any given time.c
- The objective function coefficients for the new Boolean variables.void addEqualityConstraint(int[] i, double[] a, double b)
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.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.void addGreaterThanConstraint(int[] i, double[] a, double b)
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.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.void addLessThanConstraint(int[] i, double[] a, double b)
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.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.boolean solve() throws Exception
Exception
boolean isSolved()
ILPSolver
instance has been solved
already.boolean getBooleanValue(int index)
index
- The index of the variable whose value is requested.int getIntegerValue(int index)
index
- The index of the variable whose value is requested.double getRealValue(int index)
index
- The index of the variable whose value is requested.double objectiveValue()
double objectiveCoeff(int index)
void reset()
ILPSolver
instance back to the state it was in when
first constructed.void write(StringBuffer buffer)
buffer
- The created textual representation will be appended here.Copyright © 2017. All rights reserved.