Package com.hexaly.optimizer
Interface HxDoubleExternalGradient
public interface HxDoubleExternalGradient
Gradient interface associated with a
HxDoubleExternalFunction.
This interface should be used to create a
HxModel.createDoubleExternalFunction(HxDoubleExternalFunction, HxDoubleExternalGradient).
It requires implementing the HxDoubleExternalGradient call method. The call
method must take a HxExternalArgumentValues and must return a double
array value of the same size. The argument values contain the values of the
expressions passed to the gradient, and must match the size and order of those
in the associated HxDoubleExternalFunction. The returned array must be
filled with the partial derivatives of the function with respect to each argument
value, in the same order.
Note 1: Most of the time your external gradient will be
called when the optimizer is in state HxState.Running. Do not attempt to
call any method of the optimizer (to retrieve statistics, values of HxExpressions
or whatever) in that state or an exception will be thrown.
Note 2: Your gradients must be thread-safe. According to the
"nbThreads" parameter, Hexaly Optimizer 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
Hexaly Optimizer to one thread with HxParam.setNbThreads(int).
Note 3: To optimize performance, you can return the same array object per thread from one call to another.
- Since:
- 15.0
-
Method Summary
Modifier and TypeMethodDescriptiondouble[]call(HxExternalArgumentValues argumentValues) The gradient to call.
-
Method Details
-
call
The gradient to call. The argument values contain the arguments to pass to your gradient. The output should have the same size as the argument values.- Parameters:
argumentValues- Argument values containing the arguments of the gradient.- Returns:
- The value of the HxExpression.
-