WebCab Optimization
v2.6
(J2SE Edition)

webcab.lib.math.optimization
Class EasySolver

java.lang.Object
  |
  +--webcab.lib.math.optimization.EasySolver
All Implemented Interfaces:
Serializable

public class EasySolver
extends Object
implements Serializable

This class offers a declarative means by which you can find the solution to uni or multi dimensional (non-linear) optimization problems. In order to find the solution of linear problems, also known as linear programming problems we refer the reader to LinearProgramming.

Declarative Approach

To solve an optimization problem all you will need to do is define the optimization problem you wish to solve (as described below) and then call the intelligent solve. Our intelligent solver will inspect your given problem at hand and then select the most appropriate algorithm from all the available business classes, populate the algorithm with appropriate algorithm and problem specific parameters and then evaluate the solution.

Defining the Optimization Problem and Finding the Solution

By following the below steps you will be able to quickly get your optimization problem solver up and running.

Defining the Problem

All you will to do is:

  1. Set Object Function using setFunction
  2. Set whether a Local or Global Extremum is sought using setLocal(boolean) or setGlobal(boolean) respectively.
  3. Set the type of extremum sought (i.e. maximum or minimum) using setExtremumType(webcab.lib.math.optimization.ExtremumTypes). The default extremum sought is maximum.
  4. Set the boundaries in the case of constrained optimization problems using in the unidimensional case by using setConstraints, and in the multi-dimensional case by using: addGreaterThanInequality, addLessThanInequality, addEqualityConstraint, addLowerBoundConstraint, addUpperBoundConstraint, removeAllConstraints.

Once the Object function has been set you are able to read-off a number of its qualitative properties (and hence check that it has been set correctly) by using the following:

  1. isMultiDimensional
  2. isUniDimensional
  3. isDifferentiable

Setting the Starting Conditions

Though it is only strictly necessary to provide an initial point for constrained multidimensional optimization problems we advise the user to always set an initial point in the case of local unidimensional and multidimensional optimization. In the case of global (i.e. constrained) unidimensional optimization problems it is the number of subintervals which we advise the user to set.

Even if it is not clear which point and number of intervals to considered, through a process of try and error you should be able to quickly find suitable values. You are able to set the either the initial point in the uni and multi dimensional case or the number of subintervals using one of the following set methods:

  1. setInitialPoint(double) - Provide the initial point for unidimensional unconstrained optimization problems.
  2. Set number subintervals: setNoSubIntervals - For the constrained unidimensional case sets the number of intermediate points on the interval considered and hence in doing so provides a set of initial points.
  3. setInitialPoint(double[]) - Provide the initial point for multidimensional optimization problems. For constrained optimization problems you must provide an initial points since no default value in this case is provided.

Finding the Solution

Following these four steps you are able to define any unidimensional or multidimensional optimization problem with or without linear constraints by first calling solve, after which you will be able to read of the properties of the solution found using:

  1. getUniDimensionalSolution - Returns the coordinate value on the real line of the location of the extremum of a unidimensional optimization problem considered.
  2. getMultiDimensionalSolution - Returns the coordinate point of the location of the extremum of a multidimensional optimization problem considered.
  3. getValueAtExtremum - Returns the value of the object function of the unidimensional or multidimensional optimization problem considered.

Moreover, once solve has been called you are able to ascertain which particular algorithm has been applied by calling: getMethodUsed.

Remark: We provide a number of clients examples which illustrate exactly how in practice you are able to write a client using this class which finds the solution to a given optimization problem.

Finding the Solution and the Algorithm Parameters

In the above section we provide the minimum steps required in order to solve an optimization problem. In nearly all cases the solve method will select the optimal algorithm to use, and set values for the tolerance and the maximum number of iterations to there default values, namely 0.00001, and 300 respectively.

However, in order to offer the flexibility to fine tune your client applications we enable the tolerance and maximum number of iterations to be set which are the exiting conditions of the algorithms. That is, either the solution will be found to a given level of tolerance and the algorithm will exit, or the maximum number of iterations will be exceeded before the solution is found to the given level of tolerance which will also result in the algorithm exiting. Clearly, the desirable outcome is for the solution to be found and hence the number of iterations should be chosen generously.

The two model parameters (or exiting conditions) of the tolerance and maximum number of iterations can be set and finely tuned using:

  1. Set Tolerance: setTolerance controls the precision with which the solution you are looking for is evaluated.
  2. Set Maximum number of iterations: setMaxIterations maximum number of iterations with which can be used.

Remark: If you wish to override solve method selection or use a particular algorithm for a given problem then we refer you to the MultiDimensionalSolver and UniDimensionalSolver classs.

Categorizing Optimization Problems

Within this component we will categorize sufficiently optimization problems such that we are able to:

  1. Select the optimal algorithm to use from the range of algorithms provided.
  2. Provide where appropriate algorithm and model parameters. Please note that you are not obliged to set these model specific properties since the intelligent easy solve will select appropriate model parameters if you choose not to.

In particular, we will categorize Optimization problems in accordance with:

  1. Uni or Multi Dimensional - Whether the domain over which the optimization problem is defined over a one or many dimensional.
  2. Object Function - Nature of the object function namely whether it is linear, continuous or continuously differentiable of the domain over which the problem is considered.
  3. Constraints - Whether the object function is constrained to satisfy inequality or equality constraints.
  4. Local or Global - Specify whether a local or global extremum is sought.
  5. Extremum Type - Specify whether a maximum or a minimum is sought.

In addition to these problem specific parameters you also have the option if you wish to set the following algorithm parameters which are also exiting conditions:

  1. Tolerance - Controls the precision requires of the solution which is returned by the algorithm.
  2. Maximum number of iterations - The maximum number of iterations which can be used by the algorithms.

Uni or Multi Dimensionality and Object Functions

Optimization problems can be unidimensional (that is, the object function has only one variable) or multidimensional (that is, the object function has more than one variable). We provide specialized algorithms which deal with the uni-dimensional and multidimensional cases. Optimization problems are also categorized by the qualitative properties of there object functions and for the following types of functions we provide specialized algorithms:

  1. General Functions which are not necessarily continuous. However, our algorithms which deal with this case in general will be more effective if the object function is continuous.
  2. Differentiable functions where the differential is not necessarily continuous. However, our algorithms which deal with this case in general will be more effective if the differential of the object function is continuous.
  3. Linear functions - See LinearProgramming for an extensive treatment of linear programming problems including the Simplex algorithm and duality based techniques. This includes Linear Programming where the linear object function is constrained by linear constraints.

Uni-dimensional example

     EasySolver sineOptimizationProblem = new EasySolver ();
     sineOptimizationProblem.setFunction (new SineFunction ());
     sineOptimizationProblem.solve ();

     double localMaximum = sineOptimizationProblem.getUniDimensionalSolution ();
 

The initial point for local uni-dimensional extremum problems is 0. You can change it by calling the setInitialPoint method.

See Also:
Serialized Form

Constructor Summary
EasySolver()
          Creates an instance of this class.
 
Method Summary
 void addEqualityConstraint(double[] coefficients, double equalToValue)
          Adds an equality constraint to the multidimensional optimization problem being considered.
 void addGreaterThanInequality(double[] coefficients, double greaterThanValue)
          Adds a linear constraint of `greater than type' to the multidimensional optimization problem being considered.
 void addLessThanInequality(double[] coefficients, double lessThanValue)
          Adds a linear constraint of `less than type' to the multidimensional optimization problem being considered.
 void addLowerBoundConstraint(int variableIndex, double greaterThanValue)
          Adds a lower bound constraint to the multidimensional optimization problem being considered.
 void addUpperBoundConstraint(int variableIndex, double lessThanValue)
          Adds an upper bound constraint to the multidimensional optimization problem being considered.
 ExtremumTypes getExtremumType()
          Returns the type of extremum -- minimum or maximum -- the solver is looking for when calculating a solution to the given problem.
 Function getFunction()
          Returns the instance of the function which was sent to the setFunction method.
 double getLowerBound()
          Returns the value of the lower bound of the interval over which the solution of the constrained optimization problem is sought.
 int getMaxIterations()
          Returns the maximum number of iterations which can be used by solve, of the underlying algorithm in order to find the solution of the optimization problem to the given level of accuracy specified by setTolerance.
 String getMethodUsed()
          Returns a text description of the method used in calculating the solution to the given optimization problem.
 double[] getMultiDimensionalInitialPoint()
          Returns the array representing the points in the multidimensional space where the search for the extremum of the multidimensional optimization problem is performed.
 double[] getMultiDimensionalSolution()
          After the solution for a uni-dimensional function has been calculated (i.e. after you called the solve method), this method will return the n-dimensional point at which the solution was found.
 int getNoSubIntervals()
          Returns the number of intermediate values used in the case of finding the solution of the unidimensional global optimization problem.
 double getTolerance()
          Returns the precision with which solve, looks for solutions.
 double getUniDimensionalInitialPoint()
          Returns the coordinate value of the point on the real line from which the solution of the unidimensional optimization problem is sought.
 double getUniDimensionalSolution()
          After the solution for a uni-dimensional function has been calculated (i.e. after you called the solve method), this method will return the point at which the solution was found.
 double getUpperBound()
          Returns the value of the upper bound of the interval over which the solution of the constrained optimization problem is sought.
 double getValueAtExtremum()
          After the solution for your function has been calculated (i.e.
 boolean isDifferentiable()
          Returns true if your the function to be optimized is differentiable, or false if it is not differentiable or you cannot provide its differential.
 boolean isFunctionSet()
          Indicates whether a function has been set for optimization by the client.
 boolean isGlobal()
          Indicates whether the optimization solver is currently set to look for global extrema.
 boolean isLocal()
          Indicates whether the optimization solver is currently set to look for local extrema.
 boolean isMultiDimensional()
          Returns true if the your optimization problem is multi-dimensional, or false if it is uni-dimensional.
 boolean isSolutionCalculated()
          Indicates whether a solution to the given optimization problem has been found.
 boolean isUniDimensional()
          Returns true if the your optimization problem is uni-dimensional, or false if it is multi-dimensional.
 void removeAllConstraints()
          Removes all the multidimensional constraints which have been set using: (double[] coefficients, double greaterThanValue) addGreaterThanInequality, (double[] coefficients, double lessThanValue) addLessThanInequality, (double[] coefficients, double equalToValue) addEqualityConstraint, (int variableIndex, double greaterThanValue) addLowerBoundConstraint, (int variableIndex, double lessThanValue) addUpperBoundConstraint.
 void setConstraints(double lowerBound, double upperBound)
          Sets the upper and lower bounds of a Unidimensional Constrained optimization problem.
 void setExtremumType(ExtremumTypes extremumType)
          Selects the type of extremum you are looking for, minimum or maximum.
 void setFunction(Function instanceOfFunction)
          Allows you to set the function you wish to optimize.
 void setGlobal(boolean global)
          Set whether the nature of the sought extremum is global.
 void setInitialPoint(double initialPoint)
          Sets the initial point from which the solution of the (local) Unidimensional Optimization problem will be sought.
 void setInitialPoint(double[] initialPoint)
          Sets the initial point from which the multidimensional optimization problem will be applied.
 void setLocal(boolean local)
          Allows you to set whether the nature of the sought extremum is local.
 void setMaxIterations(int maxIterations)
          The maximum number of iterations with which solve, can use of the underlying algorithm in order to find the solution of the optimization problem to the given level of tolerance specified by setTolerance.
 void setNoSubIntervals(int noSubIntervals)
          Sets the number of intermediate "safety" points to be used in the case of solving a unidimensional global optimization problem.
 void setTolerance(double tolerance)
          Controls the precision with which the solution you are looking for is evaluated.
 void solve()
          Call this method after setting the optimization problem which you are considering; this will involve setting the object function using setFunction and the other properties of this class that are relevant to your problem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EasySolver

public EasySolver()
Creates an instance of this class. All properties which you can set after creating this instance are initially set to their default values, as described in their documentation.

Method Detail

isMultiDimensional

public boolean isMultiDimensional()

Returns true if the your optimization problem is multi-dimensional, or false if it is uni-dimensional.

The uni-dimensional or multi-dimensional nature of your optimization problem is derived directly from the type of function you send to the setFunction method. If your function class implements the MultiDimensionalSolver interface, your problem will be treated as multi-dimensional; if your class implements the UniDimensionalSolver interface, your problem will be treated as uni-dimensional.


isUniDimensional

public boolean isUniDimensional()

Returns true if the your optimization problem is uni-dimensional, or false if it is multi-dimensional.

The uni-dimensional or multi-dimensional nature of your optimization problem is derived directly from the type of function you send to the setFunction method. If your class implements the UniDimensionalSolver interface, your problem will be treated as uni-dimensional; if your function class implements the MultiDimensionalSolver interface, your problem will be treated as multi-dimensional.


isDifferentiable

public boolean isDifferentiable()

Returns true if your the function to be optimized is differentiable, or false if it is not differentiable or you cannot provide its differential.

The differentiability of the optimized function is determined from the type of your function, as sent to the setFunction method before invoking this method.

If your function class implements the Derivative or Gradient interface (according to whether your function is uni or multi-dimensional), then your function is differentiable. If it implements only the UniDimensionalSolver or MultiDimensionalSolver interface, then it is not going to be treated as differentiable.


isFunctionSet

public boolean isFunctionSet()

Indicates whether a function has been set for optimization by the client.

This method returns true if called after a successful call to the setFunction method. If the setFunction method was never called or the last call was unsuccessful (an exception was thrown), this method will return false, to indicate that the function has not been set yet.

See Also:
setFunction

setLocal

public void setLocal(boolean local)
Allows you to set whether the nature of the sought extremum is local. If you pass a true value to this method, this optimization solver will look for a local extremum, next time it looks for a solution.

See Also:
setGlobal

isLocal

public boolean isLocal()
Indicates whether the optimization solver is currently set to look for local extrema. The way to change the behavior from local to global or the other way around is by calling the setLocal and setGlobal setGlobal methods.

The default value for this property is true.

See Also:
isGlobal

setGlobal

public void setGlobal(boolean global)
Set whether the nature of the sought extremum is global. If you pass a true value to this method, this optimization solver will look for a global extremum, next time it looks for a solution.

See Also:
setLocal

isGlobal

public boolean isGlobal()
Indicates whether the optimization solver is currently set to look for global extrema. The way to change the behavior from local to global or the other way around is by calling the setLocal and setGlobal methods.

The default value for this property is false.

See Also:
isLocal

setFunction

public void setFunction(Function instanceOfFunction)
                 throws ReferencedServiceException
Allows you to set the function you wish to optimize. The type of the function must be either derived from UniDimensionalFunction or MultiDimensionalFunction.

After having set the function, you can set other properties such as the initial point and when you are done, you can make a call to the solve method in order to find a solution.

Providing the Function

In order to provide a function which is to be used within the algorithms contained within this class you are required to implement one of the following interfaces:

  1. UniDimensionalFunction - In order to provide a uni-dimensional function for which the derivative is not known.
  2. Derivative - In order to provide a uni-dimensional function for which the derivative is known. Note that the Derivative interface inherits the UniDimensionalFunction interface.
  3. MultiDimensionalFunction - In order to provide a multi-dimensional function for which the gradient is not known.
  4. Gradient - In order to provide a multi-dimensional function for which the gradient is known. Note that the Gradient interface inherits from the MultiDimensionalFunction interface.

For further explicit details concerning how these interfaces are implemented (including source code) please see documentation accompanying the relevant interface.

Throws:
ReferencedServiceException - Thrown by one of the optimization classes while attempting to pass on the given function to it.
See Also:
solve

getFunction

public Function getFunction()
Returns the instance of the function which was sent to the setFunction method.


setExtremumType

public void setExtremumType(ExtremumTypes extremumType)

Selects the type of extremum you are looking for, minimum or maximum.

The two values you can choose from are located in the ExtremumTypes enumeration class, which lists these values as constants. By default, the type of extremum to optimize for is set to maximum.


getExtremumType

public ExtremumTypes getExtremumType()
Returns the type of extremum -- minimum or maximum -- the solver is looking for when calculating a solution to the given problem. By default, the algorithms look for a maximum, but you can change the type of the extremum by calling the setExtremumType method.

See Also:
setExtremumType(webcab.lib.math.optimization.ExtremumTypes)

setConstraints

public void setConstraints(double lowerBound,
                           double upperBound)
Sets the upper and lower bounds of a Unidimensional Constrained optimization problem. Naturally you should only set these constraints if you are solving a constrained unidimensional optimization problem.

Note: By default to solution of a unidimensional optimization problem is sought over the maximum possible range.

Parameters:
lowerBound - the coordinate value on the real line of the beginning of the interval over which the extremum is sought.
upperBound - the coordinate value on the real line of the end of the interval over which the extremum is sought.

getLowerBound

public double getLowerBound()
Returns the value of the lower bound of the interval over which the solution of the constrained optimization problem is sought.

See Also:
setConstraints(double, double)

getUpperBound

public double getUpperBound()
Returns the value of the upper bound of the interval over which the solution of the constrained optimization problem is sought.

See Also:
setConstraints(double, double)

addGreaterThanInequality

public void addGreaterThanInequality(double[] coefficients,
                                     double greaterThanValue)
Adds a linear constraint of `greater than type' to the multidimensional optimization problem being considered.

Providing a `greater than' Linear Constraint

For an optimization problem in n-dimensional space, you are able add the following linear constraint:

coeff0 * x0 + coeff1 * x1 + ..... + coeffn-1 * xn-1 >= greaterThanValue,

where coeffi, is the coefficient of the coordinate variable xi and greaterThanValue is just a constant. In order to pass this linear constraint as parameters to this method you need to set:

  1. Parameter `coefficients' = { coeff0, coeff0, ..., coeffn-1}
  2. Parameter `greaterThanValue = greaterThanValue

See Also:
Very similar method except allow the addition of `less than' linear constraints to multidimensional optimization problems., Adds equality constraints to multidimensional optimization problem being considered., Adds lower bound constraints to a multidimensional optimization problem being considered., Adds lower bound constraints to a multidimensional optimization problem being considered., Removes all the constraints which have been set for a multidimensional optimization problem being considered.

addLessThanInequality

public void addLessThanInequality(double[] coefficients,
                                  double lessThanValue)
Adds a linear constraint of `less than type' to the multidimensional optimization problem being considered.

Providing a `less than' Linear Constraint

For an optimization problem in n-dimensional space, you are able add the following linear constraint:

coeff0 * x0 + coeff1 * x1 + ..... + coeffn-1 * xn-1 <= greaterThanValue,

where coeffi, is the coefficient of the coordinate variable xi and greaterThanValue is just a constant. In order to pass this linear constraint as parameters to this method you need to set:

  1. Parameter `coefficients' = { coeff0, coeff0, ..., coeffn-1}
  2. Parameter `greaterThanValue = greaterThanValue

See Also:
Very similar method except allow the addition of `greater than' linear constraints to multidimensional optimization problems., Adds equality constraints to multidimensional optimization problem being considered., Adds lower bound constraints to a multidimensional optimization problem being considered., Adds lower bound constraints to a multidimensional optimization problem being considered., Removes all the constraints which have been set for a multidimensional optimization problem being considered.

addEqualityConstraint

public void addEqualityConstraint(double[] coefficients,
                                  double equalToValue)
Adds an equality constraint to the multidimensional optimization problem being considered.

Providing an Equality Constraint

For an optimization problem in n-dimensional space, you are able add the following equality constraint:

coeff0 * x0 + coeff1 * x1 + ..... + coeffn-1 * xn-1 = equalToValue,

where coeffi, is the coefficient of the coordinate variable xi and equalToValue is just a constant. In order to pass this linear constraint as parameters to this method you need to set:

  1. Parameter `coefficients' = { coeff0, coeff0, ..., coeffn-1}
  2. Parameter `equalToValue = equalToValue

See Also:
Add a `greater than' linear constraints to multidimensional optimization problem being considered., Add a `less than' linear constraints to multidimensional optimization problem being considered., Adds a lower bound constraints to a multidimensional optimization problem being considered., Adds an upper bound constraint to a multidimensional optimization problem being considered., Removes all the constraints which have been set for a multidimensional optimization problem being considered.

addLowerBoundConstraint

public void addLowerBoundConstraint(int variableIndex,
                                    double greaterThanValue)
Adds a lower bound constraint to the multidimensional optimization problem being considered.

Providing a Lower Bound Constraint

For an optimization problem in n-dimensional space, you are able add the following lower bound inequality constraint:

xk >= greaterThanValue,

where xk, is the k+1-th coordinate variable where k take one of the values {0, 1, ..., n-1}, and greaterThanValue is just a constant. In order to pass this lower bound constraint as parameters to this method you need to set:

  1. Parameter `variableIndex' = k
  2. Parameter `greaterThanValue' = greaterThanValue

See Also:
Add a `greater than' linear constraints to multidimensional optimization problem being considered., Add a `less than' linear constraints to multidimensional optimization problem being considered., Adds equality constraints to multidimensional optimization problem being considered., Adds an upper bound constraint to a multidimensional optimization problem being considered., Removes all the constraints which have been set for a multidimensional optimization problem being considered.

addUpperBoundConstraint

public void addUpperBoundConstraint(int variableIndex,
                                    double lessThanValue)
Adds an upper bound constraint to the multidimensional optimization problem being considered.

Providing an Upper Bound Constraint

For an optimization problem in n-dimensional space, you are able to add the following upper bound inequality constraint:

xk <= lessThanValue,

where xk, is the k+1-th coordinate variable where k take one of the values {0, 1, ..., n-1}, and lessThanValue is just a constant. In order to pass this upper bound constraint as parameters to this method you need to set:

  1. Parameter `variableIndex' = k
  2. Parameter `lessThanValue' = lessThanValue

See Also:
Add a `greater than' linear constraints to multidimensional optimization problem being considered., Add a `less than' linear constraints to multidimensional optimization problem being considered., Adds equality constraints to multidimensional optimization problem being considered., Adds a lower bound constraints to a multidimensional optimization problem being considered., Removes all the constraints which have been set for a multidimensional optimization problem being considered.

removeAllConstraints

public void removeAllConstraints()
Removes all the multidimensional constraints which have been set using: (double[] coefficients, double greaterThanValue) addGreaterThanInequality, (double[] coefficients, double lessThanValue) addLessThanInequality, (double[] coefficients, double equalToValue) addEqualityConstraint, (int variableIndex, double greaterThanValue) addLowerBoundConstraint, (int variableIndex, double lessThanValue) addUpperBoundConstraint.

See Also:
Add a `greater than' linear constraints to multidimensional optimization problem being considered., Add a `less than' linear constraints to multidimensional optimization problem being considered., Adds equality constraints to multidimensional optimization problem being considered., Adds a lower bound constraints to a multidimensional optimization problem being considered., Adds an upper bound constraint to a multidimensional optimization problem being considered., Removes all the constraints which have been set for a multidimensional optimization problem being considered.

setTolerance

public void setTolerance(double tolerance)
Controls the precision with which the solution you are looking for is evaluated. The default behavior is to look for a solution accurate to 5 decimal places (described by 1e-5, or 0.00001).

You can set this to a smaller number for more accurate results, or use a larger number to increase the speed of the optimization.


getTolerance

public double getTolerance()
Returns the precision with which solve, looks for solutions. By default, the precision is set to 5 decimal places, but you can change it by calling the setTolerance method.

Note: The tolerance acts as an exiting condition and whenever a solution is sought by solve, then either a solution to a given level of tolerance will be found and the algorithm will exit or the maximum number of iterations given by setMaxIterations, will be reached.

See Also:
setTolerance

setMaxIterations

public void setMaxIterations(int maxIterations)
The maximum number of iterations with which solve, can use of the underlying algorithm in order to find the solution of the optimization problem to the given level of tolerance specified by setTolerance.

Note: The tolerance acts as an exiting condition and whenever a solution is sought by solve, then either a solution to a given level of tolerance will be found and the algorithm will exit or the maximum number of iterations given by setMaxIterations, will be reached.

Parameters:
maxIterations - the maximum number of iterative steps taken before the algorithm exits and a TooManyMultiDimensionalIterationsException is thrown. A reasonable number to use for this parameter is 300.
See Also:
getMaxIterations()

getMaxIterations

public int getMaxIterations()
Returns the maximum number of iterations which can be used by solve, of the underlying algorithm in order to find the solution of the optimization problem to the given level of accuracy specified by setTolerance.


setNoSubIntervals

public void setNoSubIntervals(int noSubIntervals)
Sets the number of intermediate "safety" points to be used in the case of solving a unidimensional global optimization problem. In all other instances other than constrained unidimensional optimization there is no need to set this quantity.

The purpose of the parameters is to ensure that the advance steps do not get to large. The larger the parameter given the less likely we are to miss any local extremum in the search for the global extremum. We provide this parameter with a default value of 100, which is a reasonable value in most instances. However, as is the case with most model parameters this parameter is provided to allow you to fine tune the algorithm for your particular problem at hand. If you decide to fine tune this parameter then it a certain amount of trial and error may be necessary.

Remark: In this instance the number of subintervals play the role of the initial point within local optimizations problems.

Parameters:
noSubIntervals - the number of intermediate "safety" points to be used, in order to ensure that the advance steps do not get to large. Note that the larger the parameter the less likely we are to miss any local extremum in the search for the global extremum.

getNoSubIntervals

public int getNoSubIntervals()
Returns the number of intermediate values used in the case of finding the solution of the unidimensional global optimization problem.


setInitialPoint

public void setInitialPoint(double initialPoint)
Sets the initial point from which the solution of the (local) Unidimensional Optimization problem will be sought. This method for the setting of the initial point from which the unidimensional problems solution is sought is only relevant for local problems for the global constrained and bounded unidimensional case the initial point is not required. Even in the local case the initial point is not required is order for solve, to be able to run since in such instances the default point of the origin will be used.

Remark: The selection of the initial point ideally should be made with reference to the given problem at hand. In particular, by using insight into the particular problem at hand you may be able to select of points which is close to the extremum sought which will increase the speed with which the solution is found.

Parameters:
initialPoint - a double which corresponds to the coordinate value of a point on the real line from which the iterative search for the extremum will begin.

getUniDimensionalInitialPoint

public double getUniDimensionalInitialPoint()
Returns the coordinate value of the point on the real line from which the solution of the unidimensional optimization problem is sought.


setInitialPoint

public void setInitialPoint(double[] initialPoint)
Sets the initial point from which the multidimensional optimization problem will be applied. In the unconstrained multidimensional case you may set the initial point (with the origin being used it the initial points is not set), however in the constrained case you must set the initial point in order to run solve.

Remark: The selection of the initial point ideally should be made with reference to the given problem at hand. In particular, by using insight into the particular problem at hand you may be able to select of points which is close to the extremum sought which will increase the speed with which the solution is found.

Parameters:
initialPoint - an array of doubles where the k-th term corresponds to the coordinate value in the k-th coordinate variable of the initial point from which the search for the extremum is performed.

getMultiDimensionalInitialPoint

public double[] getMultiDimensionalInitialPoint()
Returns the array representing the points in the multidimensional space where the search for the extremum of the multidimensional optimization problem is performed. The k-th term of the returned array represents the k-th coordinate value of the initial point from where the extremum is sought.


solve

public void solve()
           throws ReferencedServiceException
Call this method after setting the optimization problem which you are considering; this will involve setting the object function using setFunction and the other properties of this class that are relevant to your problem.

This method will attempt to solve your optimization problem according to the given information regarding your type of function, type of extremum, and other specific parameters.

If successful, this method will return quietly and store internally the value of the solution and the value of the function at the solution point.

To retrieve the actual values of the point where the solution was found call either getUniDimensionalSolution or getMultiDimensionalSolution depending on whether your function is uni or multi-dimensional.

To retrieve the value of the extremum, call the getValueAtExtremum method.

Throws:
ReferencedServiceException - Thrown when one of the optimization algorithms in another class fails to find a solution.
See Also:
Retrieving the uni-dimensional solution, Retrieving the multi-dimensional solution, Retrieving the value of the extremum, Setting the function

getMethodUsed

public String getMethodUsed()
Returns a text description of the method used in calculating the solution to the given optimization problem.

This method can be called after a call to the solve method, regardless of whether a solution was found or not. If the function is changed, subsequent calls to this method should be made only after calling solve again.


isSolutionCalculated

public boolean isSolutionCalculated()

Indicates whether a solution to the given optimization problem has been found.

This method returns `true' if called after a successful call to the solve method. If the calculateSolution method was never called since the last function set (see isFunctionSet), or the last call was unsuccessful, this method will return `false', to indicate that no solution is available yet.


getUniDimensionalSolution

public double getUniDimensionalSolution()

After the solution for a uni-dimensional function has been calculated (i.e. after you called the solve method), this method will return the point at which the solution was found.

See Also:
getValueAtExtremum()

getMultiDimensionalSolution

public double[] getMultiDimensionalSolution()

After the solution for a uni-dimensional function has been calculated (i.e. after you called the solve method), this method will return the n-dimensional point at which the solution was found.

The n-dimensional solution point (x1, x2, ..., xn) is described by a one-dimensional array of numbers (double values), with as many elements as number of dimensions (i.e. n). The first element of the array corresponds to the coordinate on the first dimension x1, the second element is the position on the second dimension x2, and so on.

Note: The indexing of the array starts from 0, so that in order to access the coordinate on the first dimension, you will need to read off the element at the zero-th index. This means that in order to access the ith dimension, you would read off the element whose index is i-1 in the returned array, where i ranges from 1 to n.

See Also:
getValueAtExtremum()

getValueAtExtremum

public double getValueAtExtremum()

After the solution for your function has been calculated (i.e. after you called the solve method), this method will return the value of the function at the point of the solution.


WebCab Optimization
v2.6
(J2SE Edition)