LocalSolver logo
is now
Hexaly logo

We're excited to share that we are moving forward. We're leaving behind the LocalSolver brand and transitioning to our new identity: Hexaly. This represents a leap forward in our mission to enable every organization to make better decisions faster when faced with operational and strategic challenges.

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.

LSArrayBlackBoxFunction Interface

template<typename T>
class LSArrayBlackBoxFunction

Array black-box function interface. To use your own black-box functions within LocalSolver, first you have to implement the LSArrayBlackBoxFunction interface with the call method. The call method must take a LSBlackBoxArgumentValues as first argument and the reference of a vector of lsint or lsdouble as second argument. 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). The vector must be filled with the values to be returned by your function.

Then:

  1. Instantiate the function as an LSExpression with LSModel::createBlackBoxFunction() or the dedicated shortcut LSModel::blackBoxFunction().
  2. Pass arguments to your function and call it using LSModel::call(). The first operand must the LSExpression returned by createBlackBoxFunction. The other operands must be LSExpressions, whose values will be made accessible to your black-box function when it is called.

Note 1: LocalSolver does not manage memory of objects created outside of its environment. You are responsible for the lifetime of your LSArrayBlackBoxFunction, which must last as long as the search is active.

Node 2: You can provide additional data for your function (such as the maximum number of evaluations) with the help of the LSBlackBoxContext associated with your function (see LSExpression::getBlackBoxContext()).

Since:11.0

Summary

Functions
call The function to call.
~LSArrayBlackBoxFunction Default virtual destructor.

Functions

virtual void LSArrayBlackBoxFunction::call(const LSBlackBoxArgumentValues &argumentValues, std::vector<T> &returnValues) = 0

The function to call. The argument values contain the arguments to pass to your function. The vector of return values must be filled with the values to be returned by your function.

Parameters:
  • argumentValues – Values of the arguments passed to the function.
  • returnValues – Vector of return values of the function.
virtual LSArrayBlackBoxFunction::~LSArrayBlackBoxFunction()

Default virtual destructor.