LSBlackBoxFunction Delegate

delegate double localsolver.LSDoubleBlackBoxFunction(LSBlackBoxArgumentValues argumentValues)

Double black-box function delegate. To use double black-box functions with LocalSolver, you have to proceed in 3 steps:

  1. Implement the delegate in a method. The method must take a LSBlackBoxArgumentValues and must return a double value. The argument values contain the values of the expressions passed to the function. A distinction is made between integer arguments (bool, int) and floating point arguments (double).
  2. Instantiate the function as an LSExpression with LSModel.CreateDoubleBlackBoxFunction or the dedicated shortcut LSModel.DoubleBlackBoxFunction.
  3. Pass arguments ot your function and call it. For that, you have to create expressions of type LSOperator.Call. The first operand must be the LSExpression corresponding to your black-box function. The other operands must be LSExpressions that will be used as arguments. Their value will be made accessible to your black-box function through the LSBlackBoxArgumentValues.

Note: You can provide additional data for your function (such as bounds or the maximum number of evaluations) with the help of the LSBlackBoxContext associated with your function (see LSExpression.GetBlackBoxContext).