ImageEn, unit ievision

TIEVisionMath.optimizeWith_NelderMeadSimplexMethod

TIEVisionMath.optimizeWith_NelderMeadSimplexMethod


Declaration

function optimizeWith_NelderMeadSimplexMethod(func: TIEVisionOptimizerFunction; funcUserData: pointer; solutions: TIEVisionVectorDouble; out optimalValue: double; length: double = 1.0; timeout: int32_t = 1000; eps: double = 1.0e-20): bool32; safecall;


Description

Optimizes (minimizes) the specified function using Nelder Mead Simplex method.
Returns true on success.

Parameter Description
func Function to optimize (minimize)
funcUserData A user pointer sent to function to optimize
solutions Initial veriables and output minimizing variables
optimalValue Optimal value
length Initial length of the simplex
timeout Maximum number of iterations
eps Small real number to test convergence


Demos

Demo  Demos\IEVision\GetFaces\GetFaces.dpr
Demo  Demos\IEVision\GetWithClassifier\GetMisc.dpr
Demo  Demos\IEVision\NumberPlateBlurring\GetPlate.dpr
Demo  Demos\IEVision\FaceDetection\FaceDetection.dpr
Demo  Demos\IEVision\FaceDetection_LowLevel\FaceDetection_LowLevel.dpr
Demo  Demos\IEVision\TrackObjects\TrackObjects.dpr
Demo  Demos\IEVision\TrackObjects_LowLevel\TrackObjects_LowLevel.dpr


Example

// finds values (x0=vars[0] and x1=vars[1]) that minimze (x0-1)*(x0-1) + (x1-6)*(x1-6)
function optFunc(userData: pointer; vars: TIEVisionVectorDouble): double; stdcall;
var
  x0, x1: double;
begin
  x0 := vars.getDouble(0);
  x1 := vars.getDouble(1);
  result := (x0-1)*(x0-1) + (x1-6)*(x1-6);
end;

....
  // vector of input and output variables
  vec := IEVisionLib.createVectorDouble();
  // initial values
  vec.push_back(-1.2);
  vec.push_back(1.0);
  // find minimizing values
  if not IEVisionLib.createMath().optimizeWith_NelderMeadSimplexMethod(@optFunc, nil, vec, optValue, 1.0, 1000, 1e-20) then
  begin
    x0 := vec.getDouble(0); // should be "1"
    x1 := vec.getDouble(1); // should be "6"
    // ...and optValue shoud be "0"
  end;
....