Class LinearOptimizer
- java.lang.Object
-
- org.apache.commons.math3.optim.BaseOptimizer<PAIR>
-
- org.apache.commons.math3.optim.BaseMultivariateOptimizer<PointValuePair>
-
- org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer
-
- org.apache.commons.math3.optim.linear.LinearOptimizer
-
- Direct Known Subclasses:
SimplexSolver
public abstract class LinearOptimizer extends MultivariateOptimizer
Base class for implementing linear optimizers.- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description private LinearObjectiveFunction
function
Linear objective function.private java.util.Collection<LinearConstraint>
linearConstraints
Linear constraints.private boolean
nonNegative
Whether to restrict the variables to non-negative values.-
Fields inherited from class org.apache.commons.math3.optim.BaseOptimizer
evaluations, iterations
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LinearOptimizer()
Simple constructor with default settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Collection<LinearConstraint>
getConstraints()
protected LinearObjectiveFunction
getFunction()
protected boolean
isRestrictedToNonNegative()
PointValuePair
optimize(OptimizationData... optData)
Stores data and performs the optimization.protected void
parseOptimizationData(OptimizationData... optData)
Scans the list of (required and optional) optimization data that characterize the problem.-
Methods inherited from class org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer
computeObjectiveValue, getGoalType
-
Methods inherited from class org.apache.commons.math3.optim.BaseMultivariateOptimizer
getLowerBound, getStartPoint, getUpperBound
-
Methods inherited from class org.apache.commons.math3.optim.BaseOptimizer
doOptimize, getConvergenceChecker, getEvaluations, getIterations, getMaxEvaluations, getMaxIterations, incrementEvaluationCount, incrementIterationCount, optimize
-
-
-
-
Field Detail
-
function
private LinearObjectiveFunction function
Linear objective function.
-
linearConstraints
private java.util.Collection<LinearConstraint> linearConstraints
Linear constraints.
-
nonNegative
private boolean nonNegative
Whether to restrict the variables to non-negative values.
-
-
Method Detail
-
isRestrictedToNonNegative
protected boolean isRestrictedToNonNegative()
- Returns:
true
if the variables are restricted to non-negative values.
-
getFunction
protected LinearObjectiveFunction getFunction()
- Returns:
- the optimization type.
-
getConstraints
protected java.util.Collection<LinearConstraint> getConstraints()
- Returns:
- the optimization type.
-
optimize
public PointValuePair optimize(OptimizationData... optData) throws TooManyIterationsException
Stores data and performs the optimization.The list of parameters is open-ended so that sub-classes can extend it with arguments specific to their concrete implementations.
When the method is called multiple times, instance data is overwritten only when actually present in the list of arguments: when not specified, data set in a previous call is retained (and thus is optional in subsequent calls).
Important note: Subclasses must override
BaseOptimizer.parseOptimizationData(OptimizationData[])
if they need to register their own options; but then, they must also callsuper.parseOptimizationData(optData)
within that method.- Overrides:
optimize
in classMultivariateOptimizer
- Parameters:
optData
- Optimization data. In addition to those documented inMultivariateOptimizer
, this method will register the following data:- Returns:
- a point/value pair that satisfies the convergence criteria.
- Throws:
TooManyIterationsException
- if the maximal number of iterations is exceeded.
-
parseOptimizationData
protected void parseOptimizationData(OptimizationData... optData)
Scans the list of (required and optional) optimization data that characterize the problem.- Overrides:
parseOptimizationData
in classMultivariateOptimizer
- Parameters:
optData
- Optimization data. The following data will be looked for:
-
-