HxDoubleExternalGradient Interface¶
-
class
HxDoubleExternalGradient¶ Gradient interface associated with a double
HxExternalFunction. This interface should be used to create a double external function with gradient usingHxModel::createExternalFunction(). To define your HxDoubleExternalGradient, you must define the call method. It must take aHxExternalArgumentValuesas first argument and the reference of a vector of hxdouble as second argument. The argument values contain the values of the expressions passed to the gradient, and must match the size and order of those in the associatedHxExternalFunction. The vector 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
S_Running. Do not attempt to call any method of the optimizer (to retrieve statistics, values of HxExpressions, etc.) 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 gradient 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().Note 3: Hexaly Optimizer does not manage memory of objects created outside of its environment. You are responsible for the lifetime of your HxExternalFunction, which must last as long as the search is active.
Since: 15.0
Summary¶
call |
The gradient to call. |
~HxDoubleExternalGradient |
Default virtual destructor. |
Functions¶
-
virtual void
HxDoubleExternalGradient::call(const HxExternalArgumentValues &argumentValues, std::vector<hxdouble> &returnValues) = 0¶ The gradient to call. The argument values contain the arguments to pass to your gradient. The vector of return values must be filled with the values to be returned by your function, and have the same size as the number of arguments.
Parameters: - argumentValues – Values of the arguments passed to the gradient.
- returnValues – Vector of return values of the gradient.
-
virtual
HxDoubleExternalGradient::~HxDoubleExternalGradient()¶ Default virtual destructor.