public interface LSDoubleArrayExternalFunction
LSExternalArgumentValues
and must return a double
array 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).
LSModel.createDoubleArrayExternalFunction(localsolver.LSDoubleArrayExternalFunction)
or the dedicated shortcut
LSModel.doubleArrayExternalFunction(localsolver.LSDoubleArrayExternalFunction)
.
LSOperator.Call
. The first operand must be your
external function. The other operands must be LSExpressions. Their value
will be made accessible to your external function through the
LSExternalArgumentValues
.
Note 1: Most of the time your external function will be
called when the solver is in state LSState.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.
Note 2: Your functions must be thread-safe. According to the
"nbThreads" parameter, LocalSolver can be multi-threaded. In that case, your
external functions must be thread safe. If you cannot guarantee the
thread-safety of your code, we strongly recommend you to limit the search of
LocalSolver to one thread with LSParam.setNbThreads(int)
.
Note 3: To optimize performance, you can return the same array object per thread from one call to another.
Note 4: You can provide additional data for your function (such
as the maximum number of evaluations) with the help of the LSExternalContext
associated with the function (see LSExpression.getExternalContext()
).
Modifier and Type | Method and Description |
---|---|
double[] |
call(LSExternalArgumentValues argumentValues)
The function to call.
|
double[] call(LSExternalArgumentValues argumentValues)
argumentValues
- Argument values containing the arguments of the function.