This page is for an old version of Hexaly Optimizer.
We recommend that you update your version and read the documentation for the
latest stable release.
LSBBNativeFunction Interface¶
-
delegate double
localsolver.
LSBBNativeFunction
(LSBBNativeContext context)¶ Native function delegate. To connect your blackbox function with LocalSolverBlackBox, you have to proceed in 3 steps:
- Implement the delegate in a method. The method must take the native context and must return a double value. This native context contains the values of the expressions passed to the function. A distinction is made between integer arguments (bool, int) and floating point arguments (double).
- Instanciate the function as an
LSBBExpression
withLSBBModel.CreateNativeFunction
. - Pass arguments to your function and call it. For that, you have to
create expressions of type
LSBBOperator.Call
. The first operand must be your native function. The other operands must be LSExpressions decisions. Their value will be made accessible to your native function through the native context.
Note: Most of the time your native function will be called when the solver is in state
LSBBState.Running
. Do not attempt to call any method of the solver (to retrieve statistics, values of LSExpressions or whatever) in that state or an exception will be thrown. The only accessible function isLocalSolverBlackBox.Stop
.