OptimizationFunction
SciMLBase.OptimizationFunction — Type
OptimizationFunction(nlpmodel::AbstractNLPModel, adtype::AbstractADType = NoAD())Returns an OptimizationFunction from the NLPModel defined in nlpmodel where the available derivatives are re-used from the model, and the rest are populated with the Automatic Differentiation backend specified by adtype.
OptimizationBase.instantiate_function — Function
instantiate_function(f, x, ::AbstractADType, p, num_cons = 0)::OptimizationFunctionThis function is used internally by OptimizationBase.jl to construct the necessary extra functions (gradients, Hessians, etc.) before OptimizationBase. Each of the ADType dispatches use the supplied automatic differentiation type in order to specify how the construction process occurs.
If no ADType is given, then the default NoAD dispatch simply defines closures on any supplied gradient function to enclose the parameters to match the interfaces for the specific optimization libraries (i.e. (G,x)->f.grad(G,x,p)). If a function is not given and the NoAD dispatch is used, or if the AD dispatch is currently not capable of defining said derivative, then the constructed OptimizationFunction will simply use nothing to specify and undefined function.
The return of instantiate_function is an OptimizationFunction which is then used in the optimization process. If an optimizer requires a function that is not defined, an error is thrown.
For more information on the use of automatic differentiation, see the documentation of the AbstractADType types.
OptimizationBase.lag_hess_structure — Function
lag_hess_structure(prototype::SparseMatrixCSC) -> (rows, cols)The canonical coordinates of the entries that the vector-form Lagrangian Hessian callback lag_h(h, θ, σ, λ[, p]) writes, in the exact order it writes them. Solver wrappers that declare a sparse Hessian structure and fill it from the vector lag_h MUST derive their structure with this function — entry k of the value buffer corresponds to (rows[k], cols[k]). Wrappers whose convention requires lower-triangle coordinates (e.g. NLPModels) mirror each (i, j) to (j, i); the mirrored sequence is still in lag_h's value order.
The write order is: the upper-triangle entries (i ≤ j) of the sparse Lagrangian Hessian prototype, enumerated in findnz (CSC, column-major) order. This order is part of the public API contract of lag_h and is frozen: changing it silently breaks every consumer that declared a structure against it.