@@ -24,26 +24,33 @@ is_hessian_required(::EvaluationTargets{<:Any, <:Any, H}) where {H} = H
2424(targets:: EvaluationTargets )(arg_tuple:: Tuple ) = targets (arg_tuple... )
2525
2626"""
27- evaluate!(objective, gradient, hessian [, lossfun], model, params)
27+ evaluate!(objective, gradient, hessian, loss::AbstractLoss, params)
28+ evaluate!(objective, gradient, hessian, model::AbstractSem, params)
2829
2930Evaluates the objective, gradient, and/or Hessian at the given parameter vector.
30- If a loss function is passed, only this specific loss function is evaluated, otherwise,
31- the sum of all loss functions in the model is evaluated.
31+
32+ If a single loss term (`loss`) is passed, only this specific term is evaluated,
33+ otherwise, if the entire SEM `model` is passed, the weighted sum of all loss terms
34+ in the model is evaluated.
3235
3336If objective, gradient or hessian are `nothing`, they are not evaluated.
3437For example, since many numerical optimization algorithms don't require a Hessian,
35- the computation will be turned off by setting `hessian` to `nothing`.
38+ its computation will be turned off by setting `hessian` to `nothing`.
39+
40+ During the evaluation, the internal state of the loss term or of the model
41+ could be modified.
3642
3743# Arguments
3844- `objective`: a Number if the objective should be evaluated, otherwise `nothing`
3945- `gradient`: a pre-allocated vector the gradient should be written to, otherwise `nothing`
4046- `hessian`: a pre-allocated matrix the Hessian should be written to, otherwise `nothing`
41- - `lossfun::SemLossFunction `: loss function to evaluate
47+ - `loss::AbstractLoss `: loss function to evaluate
4248- `model::AbstractSem`: model to evaluate
4349- `params`: vector of parameters
4450
4551# Implementing a new loss function
46- To implement a new loss function, a new method for `evaluate!` has to be defined.
52+ To implement a new loss (subtype of `SemLoss` for SEM terms, or of `AbstractLoss` for
53+ regularization terms), a new method for `evaluate!` has to be defined.
4754This is explained in the online documentation on [Custom loss functions](@ref).
4855"""
4956function evaluate! end
@@ -191,43 +198,33 @@ hessian!(model::AbstractSemOrLoss, par, model) =
191198"""
192199 objective!(model::AbstractSem, params)
193200
194- Returns the objective value at `params`.
195- The model object can be modified.
201+ Calculates the objective value at `params`.
196202
197- # Implementation
198- To implement a new `SemImplied` or `SemLossFunction` subtype, you need to add a method for
199- objective!(newtype::MyNewType, params, model::AbstractSemSingle)
203+ The model object can be modified during calculation.
200204
201- To implement a new `AbstractSem` subtype, you need to add a method for
202- objective!(model::MyNewType, params)
205+ See also [`evaluate!`](@ref).
203206"""
204207function objective! end
205208
206209"""
207210 gradient!(gradient, model::AbstractSem, params)
208211
209- Writes the gradient value at `params` to `gradient`.
212+ Calculates the model's gradient at `params` and writes it to `gradient`.
210213
211- # Implementation
212- To implement a new `SemImplied` or `SemLossFunction` type, you can add a method for
213- gradient!(newtype::MyNewType, params, model::AbstractSemSingle)
214+ The model object can be modified during calculation.
214215
215- To implement a new `AbstractSem` subtype, you can add a method for
216- gradient!(gradient, model::MyNewType, params)
216+ See also [`evaluate!`](@ref).
217217"""
218218function gradient! end
219219
220220"""
221221 hessian!(hessian, model::AbstractSem, params)
222222
223- Writes the hessian value at `params` to `hessian`.
223+ Calculates the model's hessian at `params` and writes it to `hessian`.
224224
225- # Implementation
226- To implement a new `SemImplied` or `SemLossFunction` type, you can add a method for
227- hessian!(newtype::MyNewType, params, model::AbstractSemSingle)
225+ The model object can be modified during calculation.
228226
229- To implement a new `AbstractSem` subtype, you can add a method for
230- hessian!(hessian, model::MyNewType, params)
227+ See also [`evaluate!`](@ref).
231228"""
232229function hessian! end
233230
0 commit comments