WebCab Optimization for COM v2.6

EasySolver Class

This class offers a declarative means by which you can find the solution to uni or multi dimensional (non-linear) optimization problems.

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

System.Object
   EasySolver

public class EasySolver

Remarks

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 or SetGlobal respectively.
  3. Set the type of extremum sought (i.e. maximum or minimum) using SetExtremumType. 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.

Requirements

Namespace: WebCab.COM.Math.Optimization

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

See Also

EasySolver Members | WebCab.COM.Math.Optimization Namespace