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

class localsolverblackbox::LSBBNativeFunction

Native function interface.

To use your own functions with LocalSolverBlackBox, you have to proceed in 3 steps:

  1. Implement the LSBBNativeFunction interface with the call method. The call method must take the native context associated to the function 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).
  2. Instanciate the function as an LSBBExpression with LSBBModel#createNativeFunction.
  3. Pass arguments to your function and call it. For that, you have to create expressions of type O_Call. The first operand must be your native function. The other operands must be LSBBExpressions. Their value will be made accessible to your native function through the native context.

Note 1: Most of the time your native function will be called when the solver is in state S_Running. Do not attempt to call any method of the solver (to retrieve statistics, values of LSBBExpressions or whatever) in that state or an exception will be thrown. The only accessible function is LocalSolverBlackBox#stop().

Note 2: You have to free the memory of the native functions you created. LocalSolverBlackBox does not manage memory of objects created outside of its environment.

Summary

Functions
call The function to call.

Functions

virtual lsdouble call(const LSBBNativeContext &context) = 0

The function to call.

The native context contains the arguments to pass to your function.

Return:The value of the LSBBExpression.
Parameters:context - Native context containing the arguments of the function.