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_costFunction
regularization_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 to x
  • reg2::Real: Second-order regularization cost (sum of squared second differences)
  • jac2::Vector{<:Real}: Gradient of the second-order regularization with respect to x

Examples

x = [0.0, 0.1, 0.3, 0.2, 0.1]
reg1, jac1, reg2, jac2 = regularization_cost(x)
source
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 vector
  • f::Function: Transformation function to apply to each element of x
  • df::Function: Derivative of the transformation function

Returns

A tuple with four elements:

  • reg1::Real: First-order regularization cost on the transformed parameters
  • jac1::Vector{<:Real}: Gradient of the first-order regularization with respect to original parameters
  • reg2::Real: Second-order regularization cost on the transformed parameters
  • jac2::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)
source
RobustGRAPE.regularization_cost_phaseFunction
regularization_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)
source

Note: Add other regularization functions from Regularization.jl as they are implemented.