|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.optimization.linear.AbstractLinearOptimizer
public abstract class AbstractLinearOptimizer
Base class for implementing linear optimizers.
This base class handles the boilerplate methods associated to thresholds settings and iterations counters.
Field Summary | |
---|---|
static int |
DEFAULT_MAX_ITERATIONS
Default maximal number of iterations allowed. |
protected LinearObjectiveFunction |
function
Linear objective function. |
protected GoalType |
goal
Type of optimization goal: either GoalType.MAXIMIZE or GoalType.MINIMIZE . |
protected Collection<LinearConstraint> |
linearConstraints
Linear constraints. |
protected boolean |
nonNegative
Whether to restrict the variables to non-negative values. |
Constructor Summary | |
---|---|
protected |
AbstractLinearOptimizer()
Simple constructor with default settings. |
Method Summary | |
---|---|
protected abstract RealPointValuePair |
doOptimize()
Perform the bulk of optimization algorithm. |
int |
getIterations()
Get the number of iterations realized by the algorithm. |
int |
getMaxIterations()
Get the maximal number of iterations of the algorithm. |
protected void |
incrementIterationsCounter()
Increment the iterations counter by 1. |
RealPointValuePair |
optimize(LinearObjectiveFunction f,
Collection<LinearConstraint> constraints,
GoalType goalType,
boolean restrictToNonNegative)
Optimizes an objective function. |
void |
setMaxIterations(int maxIterations)
Set the maximal number of iterations of the algorithm. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_MAX_ITERATIONS
protected LinearObjectiveFunction function
protected Collection<LinearConstraint> linearConstraints
protected GoalType goal
GoalType.MAXIMIZE
or GoalType.MINIMIZE
.
protected boolean nonNegative
Constructor Detail |
---|
protected AbstractLinearOptimizer()
The maximal number of evaluation is set to its default value.
Method Detail |
---|
public void setMaxIterations(int maxIterations)
setMaxIterations
in interface LinearOptimizer
maxIterations
- maximal number of function callspublic int getMaxIterations()
getMaxIterations
in interface LinearOptimizer
public int getIterations()
The number of evaluations corresponds to the last call to the
optimize
method. It is 0 if the method has not been called yet.
getIterations
in interface LinearOptimizer
protected void incrementIterationsCounter() throws OptimizationException
OptimizationException
- if the maximal number
of iterations is exceededpublic RealPointValuePair optimize(LinearObjectiveFunction f, Collection<LinearConstraint> constraints, GoalType goalType, boolean restrictToNonNegative) throws OptimizationException
optimize
in interface LinearOptimizer
f
- linear objective functionconstraints
- linear constraintsgoalType
- type of optimization goal: either GoalType.MAXIMIZE
or GoalType.MINIMIZE
restrictToNonNegative
- whether to restrict the variables to non-negative values
OptimizationException
- if no solution fulfilling the constraints
can be found in the allowed number of iterationsprotected abstract RealPointValuePair doOptimize() throws OptimizationException
OptimizationException
- if no solution fulfilling the constraints
can be found in the allowed number of iterations
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |