Regularization
Regularization Functions
This page documents the regularization functions available in RobustGRAPE.jl, which are used to enforce desirable properties on the optimized control pulses such as smoothness and bounded amplitudes.
RobustGRAPE.regularization_cost
— Functionregularization_cost(x::Vector{<:Real})
Compute regularization costs and their gradients to promote smoothness in control pulses.
This function calculates two regularization terms:
- First-order regularization (
reg1
): Penalizes large changes between consecutive elements (first derivative) - Second-order regularization (
reg2
): Penalizes large changes in the rate of change (second derivative)
Arguments
x::Vector{<:Real}
: The control parameter vector to regularize
Returns
A tuple with four elements:
reg1::Real
: First-order regularization cost (sum of squared differences)jac1::Vector{<:Real}
: Gradient of the first-order regularization with respect tox
reg2::Real
: Second-order regularization cost (sum of squared second differences)jac2::Vector{<:Real}
: Gradient of the second-order regularization with respect tox
Examples
x = [0.0, 0.1, 0.3, 0.2, 0.1]
reg1, jac1, reg2, jac2 = regularization_cost(x)
regularization_cost(x::Vector{<:Real}, f::Function, df::Function)
Compute regularization costs and their gradients for transformed control parameters.
This function applies a transformation function f
to the control parameters before calculating regularization, and then applies the chain rule using df
to compute the gradient with respect to the original parameters.
Arguments
x::Vector{<:Real}
: The original control parameter vectorf::Function
: Transformation function to apply to each element ofx
df::Function
: Derivative of the transformation function
Returns
A tuple with four elements:
reg1::Real
: First-order regularization cost on the transformed parametersjac1::Vector{<:Real}
: Gradient of the first-order regularization with respect to original parametersreg2::Real
: Second-order regularization cost on the transformed parametersjac2::Vector{<:Real}
: Gradient of the second-order regularization with respect to original parameters
Examples
x = [0.0, 0.1, 0.3, 0.2, 0.1]
f(x) = sin(x)
df(x) = cos(x)
reg1, jac1, reg2, jac2 = regularization_cost(x, f, df)
RobustGRAPE.regularization_cost_phase
— Functionregularization_cost_phase(ϕs::Vector{<:Real})
Compute regularization costs and their gradients for phase-based control parameters.
This function calculates regularization terms for both sine and cosine of the phase values, which promotes smoothness in the complex phasor representation of the phase controls. This is particularly useful when optimizing phase-based control sequences where the physical meaning depends on the periodic nature of phases.
Arguments
ϕs::Vector{<:Real}
: The vector of phase values (in radians) to regularize
Returns
A tuple with four elements:
reg1::Real
: First-order regularization cost (sum of cos and sin components)jac1::Vector{<:Real}
: Gradient of the first-order regularization with respect toϕs
reg2::Real
: Second-order regularization cost (sum of cos and sin components)jac2::Vector{<:Real}
: Gradient of the second-order regularization with respect toϕs
Examples
ϕs = [0.0, 0.1, 0.3, 0.2, 0.1]
reg1, jac1, reg2, jac2 = regularization_cost_phase(ϕs)
Note: Add other regularization functions from Regularization.jl as they are implemented.