Click or drag to resize

TrustRegionMinimizer Class

Class TrustRegionMinimizer solves both constrained and unconstrained nonlinear least squares problems using the Trust Region method.
Inheritance Hierarchy
SystemObject
  CenterSpace.NMath.CoreTrustRegionMinimizer

Namespace: CenterSpace.NMath.Core
Assembly: NMath (in NMath.dll) Version: 7.4
Syntax
[SerializableAttribute]
public class TrustRegionMinimizer : IBoundedNonlinearLeastSqMinimizer, 
	INonlinearLeastSqMinimizer, ICloneable

The TrustRegionMinimizer type exposes the following members.

Constructors
 NameDescription
Public methodTrustRegionMinimizer Default constructor.
Public methodTrustRegionMinimizer(Double) Constructs a TrustRegionMinimizer instance with the given error tolerance.
Public methodTrustRegionMinimizer(Int32) Constructs a TrustRegionMinimizer instance with the given maximum number of iterations.
Public methodTrustRegionMinimizer(Double, Int32) Constructs a TrustRegionMinimizer instance with the given maximum number of iterations.
Top
Properties
 NameDescription
Public propertyCheckParameters Used to specify the level of input parameter checking done by the solver. During the solve, the objective function is repeatedly evaluated at various points. If one of these evaluation results in a non-real value (NaN, positive or negative infinity) it can cause the solver to hang. Having the solver check each evaluated value can incur significant overhead and so it is not done by default. You can enable checks with the CheckParameter property. The possible values are: TrustRegionMinimizer.Check.None - do no checking. The default TrustRegionMinimizer.Check.Initial - check only the initial starting point and the objective function evaluated at this point. Do not check parameters on each solver iteration TrustRegionMinimizer.Check.Always - check initial parameters and parameters at each iteration.
Public propertyStatic memberDefaultMaxIterations Gets and sets the default maximum number of iterations.
Public propertyStatic memberDefaultTolerance Gets and sets the default error tolerance.
Public propertyFinalResidual Gets the residual associated with the last computed solution.
Public propertyInitialResidual Gets the residual associated with the starting point.
Public propertyInitialStepBound Gets and sets the initial step bound. In most cases this should be between 0.1 and 100.0.
Public propertyIterations Gets the number of iterations used in the estimate of the mimimum just computed.
Public propertyMaxIterations Gets and sets the maximum number of iterations used in computing minima estimates.
Public propertyMaxIterationsMet Returns true if the minimum just computed stopped because the maximum number of iterations was reached; otherwise, false.
Public propertyMaxTrialIterations Gets and sets the maximum number of iterations of trial step calculation.
Public propertyStopCriterion The reason for stopping.
Public propertyToleranceFunctionValue Gets and sets the tolerance used to check the function value.
Public propertyToleranceImprovement Gets and sets the tolerance used to check the improvement between steps.
Public propertyToleranceJacobian Gets and sets the tolerance used to check the Jacobian.
Public propertyToleranceTrialStep Gets and sets the tolerance used to check the trial step.
Public propertyToleranceTrustRegionArea Gets and sets the tolerance used to check the trust region area.
Top
Methods
 NameDescription
Public methodClone Creates a deep copy of self.
Public methodMinimize(DoubleMultiVariableFunction, DoubleVector) Minimizes the given function near the given starting point.
Public methodMinimize(FuncDoubleVector, DoubleVector, DoubleVector, Int32) Minimizes the given function near the given starting point.
Public methodMinimize(FuncDouble, Double, DoubleVector, Int32) Minimizes the given function near the given starting point.
Public methodMinimize(DoubleMultiVariableFunction, DoubleVector, DoubleVector, DoubleVector) Minimizes the given function near the given starting point, within the specified contraints.
Public methodMinimize(FuncDoubleVector, DoubleVector, DoubleVector, Int32, FuncDoubleVector, DoubleVector) Minimizes the given function near the given starting point, using the given array of partial derivatives.
Public methodMinimize(FuncDouble, Double, DoubleVector, Int32, FuncDouble, Double) Minimizes the given function near the given starting point, using the given array of partial derivatives.
Public methodMinimize(FuncDoubleVector, DoubleVector, DoubleVector, Int32, DoubleVector, DoubleVector) Minimizes the given function near the given starting point, within the specified contraints.
Public methodMinimize(FuncDouble, Double, DoubleVector, Int32, DoubleVector, DoubleVector) Minimizes the given function near the given starting point, within the specified contraints.
Public methodMinimize(FuncDoubleVector, DoubleVector, DoubleVector, Int32, FuncDoubleVector, DoubleVector, DoubleVector, DoubleVector) Minimizes the given function near the given starting point, within the specified contraints, and using the given array of partial derivatives.
Public methodMinimize(FuncDouble, Double, DoubleVector, Int32, FuncDouble, Double, DoubleVector, DoubleVector) Minimizes the given function near the given starting point, within the specified contraints, and using the given array of partial derivatives.
Public methodSetAllTolerances Sets all the error tolerances used in computing minima estimates.
Top
Fields
 NameDescription
Protected fieldStatic memberDEFAULT_MAX_ITERThe default maximum number of iterations.
Protected fieldStatic memberDEFAULT_TOLERANCEThe default error tolerance.
Top
Remarks
Solving a nonlinear least squares problem involves finding the best approximation to vector yValues with a model function that has nonlinear dependence on variables x, by minimizing the sum of squares of residuals.
The Trust Region method maintains a region around the current search point where a quadratic model is "trusted" to be correct. If an adequate model of the objective function is found within the trust region, the region is expanded. Otherwise, the region is contracted.
The Trust Region algorithm requires the partial derivatives of the function, but a numerical approximation may be used if the closed form is not available.
For example, the following code minimizes a function, without constraints, using a numerical approximation of the partial derivatives, and starting at point (3.0, -1.0, 0.0, 1.0);
C#
TrustRegionMinimizer minimizer = new TrustRegionMinimizer();

NMathFunctions.DoubleVectorDoubleVectorFunction f = delegate(DoubleVector x)
{
  DoubleVector fx = new DoubleVector(x.Length);
  for (int i = 0; i < (x.Length) / 4; i++)
  {
    fx[4 * i] = x[4 * i] + 10.0 * x[4 * i + 1];
    fx[4 * i + 1] = 2.2360679774997896964091736687313 * (x[4 * i + 2] - x[4 * i + 3]);
    fx[4 * i + 2] = (x[4 * i + 1] - 2.0 * x[4 * i + 2]) * (x[4 * i + 1] - 2.0 * x[4 * i + 2]);
    fx[4 * i + 3] = 3.1622776601683793319988935444327 * (x[4 * i] - x[4 * i + 3]) * (x[4 * i] - x[4 * i + 3]);
  }
  return fx;
};

DoubleVector start = new DoubleVector("3.0 -1.0 0.0 1.0");
int ydim = 4;
DoubleVector solution = minimizer.Minimize(f, start, ydim);

Console.WriteLine("solution = " + solution);
Console.WriteLine("iterations = " + minimizer.Iterations);
Console.WriteLine("initial error = " + minimizer.InitialResidual);
Console.WriteLine("final error = " + minimizer.FinalResidual);
Console.WriteLine("stop criterion = " + minimizer.StopCriterion);
See Also