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 intdimension()Get the number of variables.doubleepsilon()Get the threshold to check whether a variable is an integer.RealScalarFunctionf()Get the objective function.EqualityConstraintsgetEqualityConstraints()Gets the equality constraints, hi(x) = 0intgetFirstNonIntegralIndices(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.LessThanConstraintsgetLessThanConstraints()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; Usenullif the set is empty.less- the set of less-than-or-equal-to inequality constraints; Usenullif 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; Usenullif the set is empty.less- the set of less-than-or-equal-to inequality constraints; Usenullif 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:IPProblemGet the indices of the integral variables.- Specified by:
getIntegerIndicesin interfaceIPProblem- Returns:
- the integral variable indices
-
getNonIntegralIndices
public int[] getNonIntegralIndices(double[] x)
Description copied from interface:IPProblemCheck which elements in x do not satisfy the integral constraints. The indices count from 1.- Specified by:
getNonIntegralIndicesin 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:IPProblemGet the threshold to check whether a variable is an integer.
-
getLessThanConstraints
public LessThanConstraints getLessThanConstraints()
Description copied from interface:ConstrainedOptimProblemGets the less-than-or-equal-to constraints, gi(x) ≤ 0- Specified by:
getLessThanConstraintsin interfaceConstrainedOptimProblem- Returns:
- the less-than-or-equal-to constraints
-
getEqualityConstraints
public EqualityConstraints getEqualityConstraints()
Description copied from interface:ConstrainedOptimProblemGets the equality constraints, hi(x) = 0- Specified by:
getEqualityConstraintsin interfaceConstrainedOptimProblem- Returns:
- the equality constraints
-
dimension
public int dimension()
Description copied from interface:OptimProblemGet the number of variables.- Specified by:
dimensionin interfaceOptimProblem- Returns:
- the number of variables.
-
f
public RealScalarFunction f()
Description copied from interface:OptimProblemGet the objective function.- Specified by:
fin interfaceOptimProblem- Returns:
- the objective function
-
-