Top Description Fields Constructors Methods
org.apache.commons.math3.optimization.linear

public abstract Class AbstractLinearOptimizer

extends Object
implements LinearOptimizer
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.optimization.linear.LinearOptimizer
Known Direct Subclasses
org.apache.commons.math3.optimization.linear.SimplexSolver
Annotations
@Deprecated
Imports
java.util.Collection, .Collections, org.apache.commons.math3.exception.MathIllegalStateException, .MaxCountExceededException, org.apache.commons.math3.optimization.GoalType, .PointValuePair

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

Modifier and TypeField and Description
public static final int
DEFAULT_MAX_ITERATIONS

Default maximal number of iterations allowed.

private LinearObjectiveFunction
function

Deprecated as a consequence of LinearObjectiveFunction being deprecated.
Linear objective function.
private GoalType
goal

Deprecated as a consequence of GoalType being deprecated.
Type of optimization goal: either GoalType#MAXIMIZE or GoalType#MINIMIZE.
private int
iterations

Number of iterations already performed.

private Collection<LinearConstraint>
linearConstraints

Linear constraints.

private int
maxIterations

Maximal number of iterations allowed.

private boolean
nonNegative

Whether to restrict the variables to non-negative values.

Constructor Summary

AccessConstructor and Description
protected
AbstractLinearOptimizer()

Simple constructor with default settings.

Method Summary

Modifier and TypeMethod and Description
protected abstract PointValuePair

Returns:

the point/value pair giving the optimal value for objective function
doOptimize
()
Deprecated as a consequence of PointValuePair being deprecated.

Perform the bulk of optimization algorithm.

protected Collection<LinearConstraint>

Returns:

the optimization type.
getConstraints
()

protected LinearObjectiveFunction

Returns:

the optimization type.
getFunction
()
Deprecated as a consequence of LinearObjectiveFunction being deprecated.

protected GoalType

Returns:

the optimization type.
getGoalType
()
Deprecated as a consequence of GoalType being deprecated.

public int
getIterations()

Implements org.apache.commons.math3.optimization.linear.LinearOptimizer.getIterations.

Get the number of iterations realized by the algorithm.

public int
getMaxIterations()

Implements org.apache.commons.math3.optimization.linear.LinearOptimizer.getMaxIterations.

Get the maximal number of iterations of the algorithm.

protected void
incrementIterationsCounter()

Increment the iterations counter by 1.

public PointValuePair
optimize(final LinearObjectiveFunction
linear objective function
f
,
final Collection<LinearConstraint>
linear constraints
constraints
,
final GoalType
type of optimization goal: either GoalType#MAXIMIZE or GoalType#MINIMIZE
goalType
,
final boolean
whether to restrict the variables to non-negative values
restrictToNonNegative
)

Implements org.apache.commons.math3.optimization.linear.LinearOptimizer.optimize.

Deprecated as a consequence of LinearObjectiveFunction, GoalType and PointValuePair being deprecated.

Optimizes an objective function.

protected boolean

Returns:

true if the variables are restricted to non-negative values.
restrictToNonNegative
()

public void
setMaxIterations(int
maximal number of function calls
maxIterations
)

Implements org.apache.commons.math3.optimization.linear.LinearOptimizer.setMaxIterations.

Set the maximal number of iterations of the algorithm.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_MAX_ITERATIONSback to summary
public static final int DEFAULT_MAX_ITERATIONS

Default maximal number of iterations allowed.

functionback to summary
private LinearObjectiveFunction function

Deprecated

as a consequence of LinearObjectiveFunction being deprecated. See corresponding docs for further information.

Linear objective function.

Since
2.1
goalback to summary
private GoalType goal

Deprecated

as a consequence of GoalType being deprecated. See corresponding docs for further information.

Type of optimization goal: either GoalType#MAXIMIZE or GoalType#MINIMIZE.

Since
2.1
iterationsback to summary
private int iterations

Number of iterations already performed.

linearConstraintsback to summary
private Collection<LinearConstraint> linearConstraints

Linear constraints.

Since
2.1
maxIterationsback to summary
private int maxIterations

Maximal number of iterations allowed.

nonNegativeback to summary
private boolean nonNegative

Whether to restrict the variables to non-negative values.

Since
2.1

Constructor Detail

AbstractLinearOptimizerback to summary
protected AbstractLinearOptimizer()

Simple constructor with default settings.

The maximal number of evaluation is set to its default value.

Method Detail

doOptimizeback to summary
protected abstract PointValuePair doOptimize() throws MathIllegalStateException

Deprecated

as a consequence of PointValuePair being deprecated. See corresponding docs for further information.

Perform the bulk of optimization algorithm.

Returns:PointValuePair

the point/value pair giving the optimal value for objective function

Exceptions
MathIllegalStateException:
if no solution fulfilling the constraints can be found in the allowed number of iterations
getConstraintsback to summary
protected Collection<LinearConstraint> getConstraints()
Returns:Collection<LinearConstraint>

the optimization type.

getFunctionback to summary
protected LinearObjectiveFunction getFunction()

Deprecated

as a consequence of LinearObjectiveFunction being deprecated. See corresponding docs for further information.

Returns:LinearObjectiveFunction

the optimization type.

getGoalTypeback to summary
protected GoalType getGoalType()

Deprecated

as a consequence of GoalType being deprecated. See corresponding docs for further information.

Returns:GoalType

the optimization type.

getIterationsback to summary
public int getIterations()

Implements org.apache.commons.math3.optimization.linear.LinearOptimizer.getIterations.

Doc from org.apache.commons.math3.optimization.linear.LinearOptimizer.getIterations.

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.

Returns:int

number of iterations

getMaxIterationsback to summary
public int getMaxIterations()

Implements org.apache.commons.math3.optimization.linear.LinearOptimizer.getMaxIterations.

Doc from org.apache.commons.math3.optimization.linear.LinearOptimizer.getMaxIterations.

Get the maximal number of iterations of the algorithm.

Returns:int

maximal number of iterations

incrementIterationsCounterback to summary
protected void incrementIterationsCounter() throws MaxCountExceededException

Increment the iterations counter by 1.

Exceptions
MaxCountExceededException:
if the maximal number of iterations is exceeded
optimizeback to summary
public PointValuePair optimize(final LinearObjectiveFunction f, final Collection<LinearConstraint> constraints, final GoalType goalType, final boolean restrictToNonNegative) throws MathIllegalStateException

Implements org.apache.commons.math3.optimization.linear.LinearOptimizer.optimize.

Doc from org.apache.commons.math3.optimization.linear.LinearOptimizer.optimize.

Deprecated

as a consequence of LinearObjectiveFunction, GoalType and PointValuePair being deprecated. See corresponding docs for further information.

Optimizes an objective function.

Parameters
f:LinearObjectiveFunction

linear objective function

constraints:Collection<LinearConstraint>

linear constraints

goalType:GoalType

type of optimization goal: either GoalType#MAXIMIZE or GoalType#MINIMIZE

restrictToNonNegative:boolean

whether to restrict the variables to non-negative values

Returns:PointValuePair

point/value pair giving the optimal value for objective function

Exceptions
MathIllegalStateException:
if no solution fulfilling the constraints can be found in the allowed number of iterations
restrictToNonNegativeback to summary
protected boolean restrictToNonNegative()
Returns:boolean

true if the variables are restricted to non-negative values.

setMaxIterationsback to summary
public void setMaxIterations(int maxIterations)

Implements org.apache.commons.math3.optimization.linear.LinearOptimizer.setMaxIterations.

Doc from org.apache.commons.math3.optimization.linear.LinearOptimizer.setMaxIterations.

Set the maximal number of iterations of the algorithm.

Parameters
maxIterations:int

maximal number of function calls