Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.math.optimization.linear
Class AbstractLinearOptimizer

    java.lang.Object
      org.apache.commons.math.optimization.linear.AbstractLinearOptimizer

All Implemented Interfaces:
  LinearOptimizer

Direct Known Subclasses:
  SimplexSolver

    public abstract class AbstractLinearOptimizer

extends Object
implements LinearOptimizer

Base class for implementing linear optimizers.

This base class handles the boilerplate methods associated to thresholds settings and iterations counters.

Since:
  2.0
Version:
  $Revision: 925812 $ $Date: 2010-03-21 16:49:31 +0100 (dim. 21 mars 2010) $

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`.
`private int` | `iterations` Number of iterations already performed.
`protected Collection<LinearConstraint>` | `linearConstraints` Linear constraints.
`private int` | `maxIterations` Maximal number of iterations allowed.
`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

### DEFAULT_MAX_ITERATIONS

    public static final int DEFAULT_MAX_ITERATIONS

  Default maximal number of iterations allowed.

  See Also:
    Constant Field Values

### function

    protected LinearObjectiveFunction function

  Linear objective function.

  Since:
    2.1

### linearConstraints

    protected Collection<LinearConstraint> linearConstraints

  Linear constraints.

  Since:
    2.1

### goal

    protected GoalType goal

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

  Since:
    2.1

### nonNegative

    protected boolean nonNegative

  Whether to restrict the variables to non-negative values.

  Since:
    2.1

### maxIterations

    private int maxIterations

  Maximal number of iterations allowed.

### iterations

    private int iterations

  Number of iterations already performed.

Constructor Detail

### AbstractLinearOptimizer

    protected AbstractLinearOptimizer()

  Simple constructor with default settings.

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

Method Detail

### setMaxIterations

    public void setMaxIterations(int maxIterations)

  Set the maximal number of iterations of the algorithm.

  Specified by:
    `setMaxIterations` in interface `LinearOptimizer`
  Parameters:
    `maxIterations` - maximal number of function calls

### getMaxIterations

    public int getMaxIterations()

  Get the maximal number of iterations of the algorithm.

  Specified by:
    `getMaxIterations` in interface `LinearOptimizer`
  Returns:
    maximal number of iterations

### getIterations

    public int 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.

  Specified by:
    `getIterations` in interface `LinearOptimizer`
  Returns:
    number of iterations

### incrementIterationsCounter

    protected void incrementIterationsCounter()
                                       throws OptimizationException

  Increment the iterations counter by 1.

  Throws:
    `OptimizationException` - if the maximal number of iterations is exceeded

### optimize

    public RealPointValuePair optimize(LinearObjectiveFunction f,
                                       Collection<LinearConstraint> constraints,
                                       GoalType goalType,
                                       boolean restrictToNonNegative)
                                throws OptimizationException

  Optimizes an objective function.

  Specified by:
    `optimize` in interface `LinearOptimizer`
  Parameters:
    `f` - linear objective function
    `constraints` - linear constraints
    `goalType` - type of optimization goal: either `GoalType.MAXIMIZE` or `GoalType.MINIMIZE`
    `restrictToNonNegative` - whether to restrict the variables to non-negative values
  Returns:
    point/value pair giving the optimal value for objective function
  Throws:
    `OptimizationException` - if no solution fulfilling the constraints can be found in the allowed number of iterations

### doOptimize

    protected abstract RealPointValuePair doOptimize()
                                              throws OptimizationException

  Perform the bulk of optimization algorithm.

  Returns:
    the point/value pair giving the optimal value for objective function
  Throws:
    `OptimizationException` - if no solution fulfilling the constraints can be found in the allowed number of iterations

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2003-2013 Apache Software Foundation