Class AbstractLinearOptimizer
- java.lang.Object
-
- org.apache.commons.math3.optimization.linear.AbstractLinearOptimizer
-
- All Implemented Interfaces:
LinearOptimizer
- Direct Known Subclasses:
SimplexSolver
@Deprecated public abstract class AbstractLinearOptimizer extends java.lang.Object implements LinearOptimizer
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
Fields Modifier and Type Field Description static intDEFAULT_MAX_ITERATIONSDeprecated.Default maximal number of iterations allowed.private LinearObjectiveFunctionfunctionDeprecated.Linear objective function.private GoalTypegoalDeprecated.Type of optimization goal: eitherGoalType.MAXIMIZEorGoalType.MINIMIZE.private intiterationsDeprecated.Number of iterations already performed.private java.util.Collection<LinearConstraint>linearConstraintsDeprecated.Linear constraints.private intmaxIterationsDeprecated.Maximal number of iterations allowed.private booleannonNegativeDeprecated.Whether to restrict the variables to non-negative values.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractLinearOptimizer()Deprecated.Simple constructor with default settings.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract PointValuePairdoOptimize()Deprecated.Perform the bulk of optimization algorithm.protected java.util.Collection<LinearConstraint>getConstraints()Deprecated.protected LinearObjectiveFunctiongetFunction()Deprecated.protected GoalTypegetGoalType()Deprecated.intgetIterations()Deprecated.Get the number of iterations realized by the algorithm.intgetMaxIterations()Deprecated.Get the maximal number of iterations of the algorithm.protected voidincrementIterationsCounter()Deprecated.Increment the iterations counter by 1.PointValuePairoptimize(LinearObjectiveFunction f, java.util.Collection<LinearConstraint> constraints, GoalType goalType, boolean restrictToNonNegative)Deprecated.Optimizes an objective function.protected booleanrestrictToNonNegative()Deprecated.voidsetMaxIterations(int maxIterations)Deprecated.Set the maximal number of iterations of the algorithm.
-
-
-
Field Detail
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONS
Deprecated.Default maximal number of iterations allowed.- See Also:
- Constant Field Values
-
function
private LinearObjectiveFunction function
Deprecated.Linear objective function.- Since:
- 2.1
-
linearConstraints
private java.util.Collection<LinearConstraint> linearConstraints
Deprecated.Linear constraints.- Since:
- 2.1
-
goal
private GoalType goal
Deprecated.Type of optimization goal: eitherGoalType.MAXIMIZEorGoalType.MINIMIZE.- Since:
- 2.1
-
nonNegative
private boolean nonNegative
Deprecated.Whether to restrict the variables to non-negative values.- Since:
- 2.1
-
maxIterations
private int maxIterations
Deprecated.Maximal number of iterations allowed.
-
iterations
private int iterations
Deprecated.Number of iterations already performed.
-
-
Method Detail
-
restrictToNonNegative
protected boolean restrictToNonNegative()
Deprecated.- Returns:
trueif the variables are restricted to non-negative values.
-
getGoalType
protected GoalType getGoalType()
Deprecated.- Returns:
- the optimization type.
-
getFunction
protected LinearObjectiveFunction getFunction()
Deprecated.- Returns:
- the optimization type.
-
getConstraints
protected java.util.Collection<LinearConstraint> getConstraints()
Deprecated.- Returns:
- the optimization type.
-
setMaxIterations
public void setMaxIterations(int maxIterations)
Deprecated.Set the maximal number of iterations of the algorithm.- Specified by:
setMaxIterationsin interfaceLinearOptimizer- Parameters:
maxIterations- maximal number of function calls
-
getMaxIterations
public int getMaxIterations()
Deprecated.Get the maximal number of iterations of the algorithm.- Specified by:
getMaxIterationsin 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
optimizemethod. It is 0 if the method has not been called yet.- Specified by:
getIterationsin interfaceLinearOptimizer- Returns:
- number of iterations
-
incrementIterationsCounter
protected void incrementIterationsCounter() throws MaxCountExceededExceptionDeprecated.Increment the iterations counter by 1.- Throws:
MaxCountExceededException- if the maximal number of iterations is exceeded
-
optimize
public PointValuePair optimize(LinearObjectiveFunction f, java.util.Collection<LinearConstraint> constraints, GoalType goalType, boolean restrictToNonNegative) throws MathIllegalStateException
Deprecated.Optimizes an objective function.- Specified by:
optimizein interfaceLinearOptimizer- Parameters:
f- linear objective functionconstraints- linear constraintsgoalType- type of optimization goal: eitherGoalType.MAXIMIZEorGoalType.MINIMIZErestrictToNonNegative- 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
protected abstract PointValuePair doOptimize() throws MathIllegalStateException
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
-
-