WebCab Optimization for COM v2.6

UniDimensionalSolver Class

The UniDimensionalSolver class offers methods for finding the location of the extremum (i.e. minimum or maximum) of a function of one real variable.

For a list of all members of this type, see UniDimensionalSolver Members.

System.Object
   UniDimensionalSolver

public class UniDimensionalSolver

Remarks

That is, we offer procedures for finding the extremum of a function defined over a one dimensional real space (i.e. the real line) with or without upper and lower bounds.

Application of class

Each of the procedures provided within this class proceeds by first being passed the object function of the optimization problem for which the location of the extremum is to be found. We then call one of the optimization procedures giving various parameters used to define procedure specific information such as the tolerance used and in the case of constrained optimization the constraints which must be satisfied. In most instances we are also required to provide an initial point from where the given optimization procedure will start it iterative search of the (local or global) extremum.

Overview of the Optimization

The aim of the theory of optimization is to find the location of the extremum (i.e. maximum or minimum) of a (possibly constrained) function defined over one or more (real) dimensions. An extremum point can be either local or global. A local extremum is a point such that the object function is known to obtain its highest (in the case of maximization) or lowest (in the case of minimization) value within a given sub-region of the entire domain over which the optimization problem is considered. A global extremum is the point at which the (object) function takes it maximum or minimum value over the entire domain for which the optimization problem is considered. Here we offer procedures which are designed for finding both the local and global extremum.

Selecting an Algorithm for your problem

You should select an optimization procedure to use in accordance with the properties of the optimization problem you are considering. For the unidimensional case there are two approaches to selecting the particular algorithm to use, as described below:

Problem Based Approach

This approach focuses on the properties of the problem at hand. In particular, we take into account the following criteria when selecting the particular optimization procedure to use:

  1. Object Function - Nature of the object function namely whether it is linear, continuous or continuously differentiable over the domain for which the optimization problem is considered.
  2. Constraints - Whether the object function is constrained to satisfy upper and lower bounds.
  3. Local or Global - Whether a local or global extremum is sought.

By using this information and taking into account your particular applications needs you will able to select the most appropriate procedure to use.

Method Based Approach

It is also true that in the unidimensional optimization case the algorithms can be roughly broken down into the following three categories:

  1. Quick Algorithms to find Local Extremum.
  2. Slower but more precise Algorithms of finding the Local Extremum.
  3. Algorithms for finding the global extremum on a finite interval of the real line.

Apart from categorizing your problem within one of these three criteria the only other information required in the selection of an approach is whether the object function of your optimization problem is differentiable or not, and in the case of the second and third categories whether you wish to select the set of bracketing and locate algorithms which is used within the procedure.

Using Algorithms with pre-set Bracketing and Locate Algorithms

Unless you particular wish to fine tune the optimization algorithms for your given problem at hand we strongly advise that when wishing to find the local or global extremum over an interval that the algorithms with a preset default set of bracketing and locate algorithms are used. The algorithms with these preset internal algorithms are as follows:

  1. Slower but more precise Algorithms for finding the Local Extremum:
    1. For General Functions: SeekNextExtreme
    2. For Differentiable Functions: SeekNextExtremeDeriv
  2. Algorithms for finding the global extremum on a finite interval of the real line:
    1. For General Functions: GlobalExtreme
    2. For Differentiable Functions: GlobalExtremeDeriv

Remark: The function used within an optimization problem must be provided using SetFunction, which takes as a parameters an instance of a class which implements one of the UniDimensionalFunction sub-interfaces. When we refer to a function being general we refer to the fact that only the GetValueAt method, giving the functions value at a points has been implemented. By differentiable function we refer to the fact that in addition to the implementation of this method you have also implemented GetDerivativeAt.

Using Algorithms with user selected Bracketing and Locate Algorithms

To offer the greatest power and flexibility we provide methods which allow the Bracketing and Locate algorithms used within the optimization procedures to be selected and configured. This allows the algorithm to be finely tuned to find the exact requirements of your problem at hand and the level of precision and robustness required. We offer the following four procedures, two for finding the local extremum and two for finding the global extremum:

  1. Slower but more precise Algorithms for finding the Local Extremum.
    1. For General Functions: SeekNextExtreme
    2. For Differentiable Functions: SeekNextExtremeDeriv
  2. Algorithms for finding the global extremum on a finite interval of the real line.
    1. For General Functions: GlobalExtreme
    2. For Differentiable Functions: GlobalExtremeDeriv

Using "Quick Algorithms for finding Local Extremum"

For those who require speed at the expense of precision we offer the following methods for finding the local extremum of a general function which are not even necessarily continuous.

  1. SeekExtremeValueUnidir - Finds the value of the unidimensional object function at a local extremum (maximum or minimum) found, where the specific bracketing and locate algorithms from the classs BracketingAlgorithm and LocateAlgorithm are set and the initial point given.
  2. SeekExtremeUnidir - Evaluates the location of a (local) extremum (maximum or minimum) of a unidimensional object function and returns the type Extremum which contains the coordinate value of the extremum sought of the type of extremum found (i.e. whether maximum or minimum).
  3. SeekExtremeBidir - Evaluates the location of a local minimum of a unidimensional function with a iterative search started in two directions, when the bracketing and locate algorithms and initial point are given.

For all three of these methods the specific bracketing and locate algorithms used within the algorithm must be selected (i.e. given via a parameter) from the class's BracketingAlgorithm and LocateAlgorithm.

Selecting the Bracketing and Locate Algorithms by Trial and Error

A very effective means by which to select the optimal Bracketing and Locate algorithm combination for your particular problem, is to just try the 16 combinations of algorithms and then compare the results found. To assist (and demonstrate) this approach we provide within this package client examples which solve various unidimensional optimization problems using the various combinations of Bracketing and Locate algorithms. By adopting these examples (i.e. set your function rather than use the preset object function) you will be able to select the optimal bracketing and locate algorithm combination for your particular optimization problem but just comparing the results given by the various algorithms.

Further Remarks on Unidimensional Optimization Problems

Constrained Optimization

For unidimensional optimization problems the constraints can only take very simple forms, for example lowerBound ≤ x ≤ upperBound, where lowerBound, upperBound are two given real numbers. Therefore we are able to offer a number of refined algorithms to deal with the unidimensional constrained case, two such examples are GlobalExtremeDeriv, and GlobalExtreme.

Continuous and Differentiable Object Functions

As mentioned above the algorithms implemented within this class work most efficiently when the functions are `well behaved'. Generally speaking what we mean by `well behaved' is that the smoother the function, the more `well behaved' the function is. This is important to our study here since generally the more `well behaved' a function the more efficient and stable the optimization algorithms contained within this class will be when applied to the given function at hand. This principle is true for both general or differentiable functions.

The reason for this is that the `greedy type' algorithms implemented here have as a basis that at each iterative step we move to the extremum point within a given neighborhood lying in one of a number of chosen directions. Such `greedy type' or calculus inspired arguments work increasingly more effectively as the function on which they are applied gets smoother.

Remark: In practice, the requirement that the majority of the procedures within this class require that the object function is continuous or even differentiable is not a restriction with most practical applications. The reason being that processes generated from real world systems such as economic systems will result in the study of object functions which are in nearly all cases are continuous and even differentiable.

Object Functions which take NaN values

It is also important to point out that though we may consider non-continuous functions with some of the algorithms these functions must never return a NaN (Not a number). In order to guarantee this we must ensure that for all points within the domain over which the optimization problem is considered the object function does not return such as value. If such an value is returned, the algorithms will exit and throw an InvalidUniDimensionalFunctionException exception. If this exception is thrown, you will then be able to call methods within the Exception class which provide the coordinate value of the point where the function evaluates to a Double.NaN. By modifying your given function at points where it returns a NaN you should be able to modify the object function of the optimization problem so that the essential features of the underlying problem are preserved but the optimization algorithm can be successfully applied.

Local and Global Extremum

The local extremum (i.e. minimum or maximum) is just the extremum in a neighborhood of a point, where the global extremum is the extremum on the whole domain over which the optimization problem is considered. In practice it is generally the global extremum which is desired and for constrained optimization problems (i.e. with an upper and lower bound) we provide effective algorithms which treat this case, namely:

  1. For General Functions: GlobalExtreme
  2. For Differentiable Functions: GlobalExtremeDeriv

For unconstrained optimization problems since you can never be certain that the local extremum is in fact the global extremum. There are no iterative algorithms which are effective at finding the global extremum of a unconstrained problem.

Setting the Optimization Problems Object Function

Before any of the optimization procedures offered within this class are called the uni-dimensional object function must be set using either SetFunction, or by passing the object function with the constructor of this UniDimensionalSolver class.

Remark: If your clients uses threads then it should be pointed out that set the functions using SetFunction is not thread safe.

UniDimensionalException and setting the Object Function

The UniDimensionalException is thrown if a function is not set and one of the optimization solver algorithms is called. If the algorithm requires a differential object function and a differentiable function has not been set then a UniDimensionalException will be thrown. For details concerning the implementation and the setting of a function please see the documentation of SetFunction.

Detailed Overview of Uni-Dimensional Algorithms Available

Quick Algorithms for Local Uni-Dimensional Optimization

  1. SeekExtremeValueUnidir - Finds the location of the (local) extremum (maximum or minimum) of the unidimensional function, where the specific bracketing and locate algorithm from the class's BracketingAlgorithm and LocateAlgorithm used by the algorithm must be selected.
  2. SeekExtremeUnidir - Evaluates the value of the unidimensional object function at the (local) extremum (maximum or minimum), where the specific bracketing and locate algorithm from the class's BracketingAlgorithm and LocateAlgorithm used by the algorithm must be selected.
  3. SeekExtremeBidir - Seeks a local minimum of the unidimensional function, where the specific bracketing and locate algorithm from the class's BracketingAlgorithm and LocateAlgorithm used by the algorithm must be selected.

More Precise (but slower) Algorithms for Local Uni-Dimensional Optimization

  1. SeekNextExtreme - Seek local minimum for a general function using a default set of Bracketing and Locate algorithms.
  2. SeekNextExtreme - Same as above but you are able to select the set of Bracketing and Locate algorithms used.
  3. SeekNextExtremeDeriv - Seeks local minimum of a unidimensional differentiable function using a default set of Bracketing and Locate algorithms.
  4. SeekNextExtremeDeriv - Same as above but you are able to select the set of Bracketing and Locate algorithms used.

Algorithms for Global Uni-Dimensional Optimization

  1. GlobalExtreme - Seek global extremum within an interval of the real line for a general unidimensional function.
  2. GlobalExtreme - Same as above except you are able to select set of the Locate and Bracketing algorithms used.
  3. GlobalExtremeDeriv - Seeks the global extremum within the real line of differentiable unidimensional function, using a default set of Bracketing and Locate algorithms.
  4. GlobalExtremeDeriv - Same as above but you are able to select the set of Bracketing and Locate algorithms used.

Requirements

Namespace: WebCab.COM.Math.Optimization.UniDimensional

Assembly: WebCab.COM.Optimization (in WebCab.COM.Optimization.dll)

See Also

UniDimensionalSolver Members | WebCab.COM.Math.Optimization.UniDimensional Namespace