Class AbstractLinearOptimizer
java.lang.Object
org.apache.commons.math3.optimization.linear.AbstractLinearOptimizer
- All Implemented Interfaces:
LinearOptimizer
- Direct Known Subclasses:
SimplexSolver
Deprecated.
As of 3.1 (to be removed in 4.0).
Base class for implementing linear optimizers.
This base class handles the boilerplate methods associated to thresholds settings and iterations counters.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Deprecated.Default maximal number of iterations allowed.private LinearObjectiveFunction
Deprecated.Linear objective function.private GoalType
Deprecated.Type of optimization goal: eitherGoalType.MAXIMIZE
orGoalType.MINIMIZE
.private int
Deprecated.Number of iterations already performed.private Collection
<LinearConstraint> Deprecated.Linear constraints.private int
Deprecated.Maximal number of iterations allowed.private boolean
Deprecated.Whether to restrict the variables to non-negative values. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Deprecated.Simple constructor with default settings. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract PointValuePair
Deprecated.Perform the bulk of optimization algorithm.protected Collection
<LinearConstraint> Deprecated.protected LinearObjectiveFunction
Deprecated.protected GoalType
Deprecated.int
Deprecated.Get the number of iterations realized by the algorithm.int
Deprecated.Get the maximal number of iterations of the algorithm.protected void
Deprecated.Increment the iterations counter by 1.optimize
(LinearObjectiveFunction f, Collection<LinearConstraint> constraints, GoalType goalType, boolean restrictToNonNegative) Deprecated.Optimizes an objective function.protected boolean
Deprecated.void
setMaxIterations
(int maxIterations) Deprecated.Set the maximal number of iterations of the algorithm.
-
Field Details
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONSDeprecated.Default maximal number of iterations allowed.- See Also:
-
function
Deprecated.Linear objective function.- Since:
- 2.1
-
linearConstraints
Deprecated.Linear constraints.- Since:
- 2.1
-
goal
Deprecated.Type of optimization goal: eitherGoalType.MAXIMIZE
orGoalType.MINIMIZE
.- Since:
- 2.1
-
nonNegative
private boolean nonNegativeDeprecated.Whether to restrict the variables to non-negative values.- Since:
- 2.1
-
maxIterations
private int maxIterationsDeprecated.Maximal number of iterations allowed. -
iterations
private int iterationsDeprecated.Number of iterations already performed.
-
-
Constructor Details
-
AbstractLinearOptimizer
protected AbstractLinearOptimizer()Deprecated.Simple constructor with default settings.The maximal number of evaluation is set to its default value.
-
-
Method Details
-
restrictToNonNegative
protected boolean restrictToNonNegative()Deprecated.- Returns:
true
if the variables are restricted to non-negative values.
-
getGoalType
Deprecated.- Returns:
- the optimization type.
-
getFunction
Deprecated.- Returns:
- the optimization type.
-
getConstraints
Deprecated.- Returns:
- the optimization type.
-
setMaxIterations
public void setMaxIterations(int maxIterations) Deprecated.Set the maximal number of iterations of the algorithm.- Specified by:
setMaxIterations
in interfaceLinearOptimizer
- Parameters:
maxIterations
- maximal number of function calls
-
getMaxIterations
public int getMaxIterations()Deprecated.Get the maximal number of iterations of the algorithm.- Specified by:
getMaxIterations
in interfaceLinearOptimizer
- Returns:
- maximal number of iterations
-
getIterations
public int getIterations()Deprecated.Get the number of iterations realized by the algorithm.The number of evaluations corresponds to the last call to the
optimize
method. It is 0 if the method has not been called yet.- Specified by:
getIterations
in interfaceLinearOptimizer
- Returns:
- number of iterations
-
incrementIterationsCounter
Deprecated.Increment the iterations counter by 1.- Throws:
MaxCountExceededException
- if the maximal number of iterations is exceeded
-
optimize
public PointValuePair optimize(LinearObjectiveFunction f, Collection<LinearConstraint> constraints, GoalType goalType, boolean restrictToNonNegative) throws MathIllegalStateException Deprecated.Optimizes an objective function.- Specified by:
optimize
in interfaceLinearOptimizer
- Parameters:
f
- linear objective functionconstraints
- linear constraintsgoalType
- type of optimization goal: eitherGoalType.MAXIMIZE
orGoalType.MINIMIZE
restrictToNonNegative
- whether to restrict the variables to non-negative values- Returns:
- point/value pair giving the optimal value for objective function
- Throws:
MathIllegalStateException
- if no solution fulfilling the constraints can be found in the allowed number of iterations
-
doOptimize
Deprecated.Perform the bulk of optimization algorithm.- Returns:
- the point/value pair giving the optimal value for objective function
- Throws:
MathIllegalStateException
- if no solution fulfilling the constraints can be found in the allowed number of iterations
-