public class OJalgoHook extends Object implements ILPSolver
VERBOSITY_HIGH, VERBOSITY_LOW, VERBOSITY_NONE
Constructor and Description |
---|
OJalgoHook() |
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 |
printModelInfo() |
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 |
setBinary(int colId)
Set the column / variable as an binary integer variable
|
void |
setBounds(int colId,
double lower,
double upper)
Set bounds of variable in the specified position.
|
void |
setFloat(int colId)
Set the column/variable as a float variable
|
void |
setInteger(int colId)
Set the column/variable as an integer variable
|
void |
setLowerBound(int colId,
double l) |
void |
setMaximize(boolean d)
Sets the direction of the objective function.
|
void |
setTimeout(int limit)
Set a time limit for solver optimization.
|
void |
setUnboundLowerBound(int colId)
Set upper bound to unbounded (infinite)
|
void |
setUnboundUpperBound(int colId)
Set lower bound to unbounded (infinite)
|
void |
setUpperBound(int colId,
double u) |
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.
|
public void setBounds(int colId, double lower, double upper)
colId
- position of the variablelower
- domain lower boundupper
- domain upper boundpublic void setUnboundUpperBound(int colId)
colId
- position of the variablepublic void setUpperBound(int colId, double u)
public void setUnboundLowerBound(int colId)
colId
- position of the variablepublic void setLowerBound(int colId, double l)
public void setInteger(int colId)
colId
- position of the variablepublic void setBinary(int colId)
colId
- position of the variablepublic void setFloat(int colId)
colId
- position of the variablepublic void setMaximize(boolean d)
ILPSolver
setMaximize
in interface ILPSolver
d
- true
if the objective function is to be maximized.public int addBooleanVariable(double c)
ILPSolver
addBooleanVariable
in interface ILPSolver
c
- The objective function coefficient for the new Boolean variable.public int addRealVariable(double c)
ILPSolver
addRealVariable
in interface ILPSolver
c
- The objective function coefficient for the new Real variable.public int addIntegerVariable(double c)
ILPSolver
addIntegerVariable
in interface ILPSolver
c
- The objective function coefficient for the new Integer variable.public int[] addDiscreteVariable(double[] c)
true
at any given time.addDiscreteVariable
in interface ILPSolver
c
- The objective function coefficients for the new Boolean variables.public void addEqualityConstraint(int[] i, double[] a, double b)
ILPSolver
ILPSolver.addBooleanVariable(double)
or ILPSolver.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.addEqualityConstraint
in interface ILPSolver
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.public void addGreaterThanConstraint(int[] i, double[] a, double b)
ILPSolver
ILPSolver.addBooleanVariable(double)
or ILPSolver.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.addGreaterThanConstraint
in interface ILPSolver
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.public void addLessThanConstraint(int[] i, double[] a, double b)
ILPSolver
ILPSolver.addBooleanVariable(double)
or ILPSolver.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.addLessThanConstraint
in interface ILPSolver
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.public boolean solve() throws Exception
ILPSolver
public boolean isSolved()
ILPSolver
ILPSolver
instance has been solved
already.public boolean getBooleanValue(int index)
ILPSolver
getBooleanValue
in interface ILPSolver
index
- The index of the variable whose value is requested.public double getRealValue(int index)
ILPSolver
getRealValue
in interface ILPSolver
index
- The index of the variable whose value is requested.public int getIntegerValue(int index)
ILPSolver
getIntegerValue
in interface ILPSolver
index
- The index of the variable whose value is requested.public double objectiveValue()
ILPSolver
objectiveValue
in interface ILPSolver
public double objectiveCoeff(int index)
ILPSolver
objectiveCoeff
in interface ILPSolver
public void reset()
ILPSolver
ILPSolver
instance back to the state it was in when
first constructed.public void write(StringBuffer buffer)
ILPSolver
public void setTimeout(int limit)
limit
- the time limitpublic void printModelInfo()
Copyright © 2017. All rights reserved.