# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.optimization.multivariate.constrained.integer.linear.problem

## Class ILPProblemImpl1

• java.lang.Object
• com.numericalmethod.suanshu.optimization.multivariate.constrained.integer.linear.problem.ILPProblemImpl1
• ### Constructor Summary

Constructors
Constructor and Description
ILPProblemImpl1(Vector cost, LinearGreaterThanConstraints greater, LinearLessThanConstraints less, LinearEqualityConstraints equal, BoxConstraints bounds, int[] integers, double epsilon)
Construct an ILP problem, in which the variables can be real or integral.
• ### Method Summary

All Methods
Modifier and Type Method and Description
ImmutableMatrix A()
Get the coefficients, A, of the greater-than-or-equal-to constraints A * x ≥ b.
ImmutableMatrix Aeq()
Get the coefficients, Aeq, of the equality constraints Aeq * x ≥ beq.
ImmutableVector b()
Get the values, b, of the greater-than-or-equal-to constraints A * x ≥ b.
ImmutableVector beq()
Get the values, beq, of the equality constraints Aeq * x ≥ beq.
ImmutableVector c()
Get the objective function.
int dimension()
Get the number of variables.
double epsilon()
Get the threshold to check whether a variable is an integer.
RealScalarFunction f()
Get the objective function.
LinearEqualityConstraints getEqualityConstraints()
Gets the equality constraints, hi(x) = 0
int[] getIntegerIndices()
Get the indices of the integral variables.
LinearLessThanConstraints getLessThanConstraints()
Gets the less-than-or-equal-to constraints, gi(x) ≤ 0
int[] getNonIntegralIndices(double[] x)
Check which elements in x do not satisfy the integral constraints.
boolean isFree(int i)
Check whether xi is a free variable after handling the box constraints.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### ILPProblemImpl1

public ILPProblemImpl1(Vector cost,
LinearGreaterThanConstraints greater,
LinearLessThanConstraints less,
LinearEqualityConstraints equal,
BoxConstraints bounds,
int[] integers,
double epsilon)
Construct an ILP problem, in which the variables can be real or integral.
Parameters:
cost - the linear objective function
greater - the greater-than-or-equal-to constraints
less - the less-than-or-equal-to constraints
equal - the equality constraints
bounds - the box constraints
integers - the indices of the integral variables
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
• ### Method Detail

• #### epsilon

public double epsilon()
Description copied from interface: IPProblem
Get the threshold to check whether a variable is an integer.
Specified by:
epsilon in interface IPProblem
Returns:
the precision parameter: when a number |x| ≤ ε, it is considered 0
• #### getIntegerIndices

public int[] getIntegerIndices()
Description copied from interface: IPProblem
Get the indices of the integral variables.
Specified by:
getIntegerIndices in interface IPProblem
Returns:
the integral variable indices
• #### getNonIntegralIndices

public int[] getNonIntegralIndices(double[] x)
Description copied from interface: IPProblem
Check which elements in x do not satisfy the integral constraints. The indices count from 1.
Specified by:
getNonIntegralIndices in interface IPProblem
Parameters:
x - an argument to the objective function
Returns:
the set of indices of values in x that do not satisfy the integral constraints. An int[] of length 0 indicates that all integral variables in x are integers.
• #### getLessThanConstraints

public LinearLessThanConstraints getLessThanConstraints()
Description copied from interface: ConstrainedOptimProblem
Gets the less-than-or-equal-to constraints, gi(x) ≤ 0
Specified by:
getLessThanConstraints in interface ConstrainedOptimProblem
Returns:
the less-than-or-equal-to constraints
• #### getEqualityConstraints

public LinearEqualityConstraints getEqualityConstraints()
Description copied from interface: ConstrainedOptimProblem
Gets the equality constraints, hi(x) = 0
Specified by:
getEqualityConstraints in interface ConstrainedOptimProblem
Returns:
the equality constraints
• #### dimension

public int dimension()
Description copied from interface: OptimProblem
Get the number of variables.
Specified by:
dimension in interface OptimProblem
Returns:
the number of variables.
• #### f

public RealScalarFunction f()
Description copied from interface: OptimProblem
Get the objective function.
Specified by:
f in interface OptimProblem
Returns:
the objective function
• #### c

public ImmutableVector c()
Description copied from interface: LPProblem
Get the objective function.
Specified by:
c in interface LPProblem
Returns:
the objective function
• #### A

public ImmutableMatrix A()
Description copied from interface: LPProblem
Get the coefficients, A, of the greater-than-or-equal-to constraints A * x ≥ b.
Specified by:
A in interface LPProblem
Returns:
the coefficients of the greater-than-or-equal-to constraints
• #### b

public ImmutableVector b()
Description copied from interface: LPProblem
Get the values, b, of the greater-than-or-equal-to constraints A * x ≥ b.
Specified by:
b in interface LPProblem
Returns:
the values of the greater-than-or-equal-to constraints
• #### Aeq

public ImmutableMatrix Aeq()
Description copied from interface: LPProblem
Get the coefficients, Aeq, of the equality constraints Aeq * x ≥ beq.
Specified by:
Aeq in interface LPProblem
Returns:
the coefficients of the equality constraints
• #### beq

public ImmutableVector beq()
Description copied from interface: LPProblem
Get the values, beq, of the equality constraints Aeq * x ≥ beq.
Specified by:
beq in interface LPProblem
Returns:
the values of the equality constraints
• #### isFree

public boolean isFree(int i)
Description copied from interface: LPProblem
Check whether xi is a free variable after handling the box constraints.
Specified by:
isFree in interface LPProblem
Parameters:
i - the index of a variable, counting from 1
Returns:
true if xi is free