Class IPProblemImpl1
- java.lang.Object
-
- dev.nm.solver.multivariate.constrained.integer.IPProblemImpl1
-
- All Implemented Interfaces:
IPProblem
,ConstrainedOptimProblem
,OptimProblem
- Direct Known Subclasses:
BruteForceIPProblem
public class IPProblemImpl1 extends Object implements IPProblem
This is an implementation of a general Integer Programming problem in which some variables take only integers.
-
-
Constructor Summary
Constructors Constructor Description IPProblemImpl1(RealScalarFunction f, EqualityConstraints equal, LessThanConstraints less, int[] integers)
Construct a constrained optimization problem with integral constraints.IPProblemImpl1(RealScalarFunction f, EqualityConstraints equal, LessThanConstraints less, int[] integers, double epsilon)
Construct a constrained optimization problem with integral constraints.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.EqualityConstraints
getEqualityConstraints()
Gets the equality constraints, hi(x) = 0int
getFirstNonIntegralIndices(double[] x)
Get the index of the first integral variable whose value is not an integer, violating the integral constraints.int[]
getIntegerIndices()
Get the indices of the integral variables.LessThanConstraints
getLessThanConstraints()
Gets the less-than-or-equal-to constraints, gi(x) ≤ 0int[]
getNonIntegralIndices(double[] x)
Check which elements in x do not satisfy the integral constraints.
-
-
-
Constructor Detail
-
IPProblemImpl1
public IPProblemImpl1(RealScalarFunction f, EqualityConstraints equal, LessThanConstraints less, int[] integers, double epsilon)
Construct a constrained optimization problem with integral constraints.- Parameters:
f
- the objective function to be minimizedequal
- the set of equality constraints; Usenull
if the set is empty.less
- the set of less-than-or-equal-to inequality constraints; Usenull
if the set is empty.integers
- the set of indices of the integral variables, counting from 1epsilon
- a precision parameter: when a number |x| ≤ ε, it is considered 0
-
IPProblemImpl1
public IPProblemImpl1(RealScalarFunction f, EqualityConstraints equal, LessThanConstraints less, int[] integers)
Construct a constrained optimization problem with integral constraints.- Parameters:
f
- the objective function to be minimizedequal
- the set of equality constraints; Usenull
if the set is empty.less
- the set of less-than-or-equal-to inequality constraints; Usenull
if the set is empty.integers
- the set of indices of the integral variables, counting from 1
-
-
Method Detail
-
getIntegerIndices
public int[] getIntegerIndices()
Description copied from interface:IPProblem
Get the indices of the integral variables.- Specified by:
getIntegerIndices
in interfaceIPProblem
- 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 interfaceIPProblem
- 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.
-
getFirstNonIntegralIndices
public int getFirstNonIntegralIndices(double[] x)
Get the index of the first integral variable whose value is not an integer, violating the integral constraints. The indices count from 1.- Parameters:
x
- an argument to the objective function- Returns:
- the index of the first integral variable whose value is not an integer. 0 indicates that the values of all integral variables in x are integers.
-
epsilon
public double epsilon()
Description copied from interface:IPProblem
Get the threshold to check whether a variable is an integer.
-
getLessThanConstraints
public LessThanConstraints getLessThanConstraints()
Description copied from interface:ConstrainedOptimProblem
Gets the less-than-or-equal-to constraints, gi(x) ≤ 0- Specified by:
getLessThanConstraints
in interfaceConstrainedOptimProblem
- Returns:
- the less-than-or-equal-to constraints
-
getEqualityConstraints
public EqualityConstraints getEqualityConstraints()
Description copied from interface:ConstrainedOptimProblem
Gets the equality constraints, hi(x) = 0- Specified by:
getEqualityConstraints
in interfaceConstrainedOptimProblem
- Returns:
- the equality constraints
-
dimension
public int dimension()
Description copied from interface:OptimProblem
Get the number of variables.- Specified by:
dimension
in interfaceOptimProblem
- Returns:
- the number of variables.
-
f
public RealScalarFunction f()
Description copied from interface:OptimProblem
Get the objective function.- Specified by:
f
in interfaceOptimProblem
- Returns:
- the objective function
-
-