Class TrustRegionMinimizer solves both constrained and unconstrained nonlinear least squares problems using the Trust Region method.

Namespace:  CenterSpace.NMath.Analysis
Assembly:  NMath (in NMath.dll) Version: 5.1.0.0

Syntax

C#
[SerializableAttribute]
public class TrustRegionMinimizer : IBoundedNonlinearLeastSqMinimizer, 
	INonlinearLeastSqMinimizer, ICloneable
Visual Basic (Declaration)
<SerializableAttribute> _
Public Class TrustRegionMinimizer _
	Implements IBoundedNonlinearLeastSqMinimizer, INonlinearLeastSqMinimizer, ICloneable
Visual C++
[SerializableAttribute]
public ref class TrustRegionMinimizer : IBoundedNonlinearLeastSqMinimizer, 
	INonlinearLeastSqMinimizer, ICloneable

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);
CopyC#
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);

Inheritance Hierarchy

System..::.Object
  CenterSpace.NMath.Analysis..::.TrustRegionMinimizer

See Also