Difference between revisions of "Penalty.m"

From Spinach Documentation Wiki
Jump to: navigation, search
(basics of penalty.m (outdated))
(sync with Spinach main f053e432: fb/cb may be arrays, cb scalar only for SNSA)
 
(27 intermediate revisions by 3 users not shown)
Line 1: Line 1:
−
{{DISPLAYTITLE:penalty.m}}
+
{{DISPLAYTITLE:penalty.m}} __NOTOC__
 +
Penalty terms for the Optimal Control module. Returns the penalty function and its gradient for the waveform, which should be supplied as row vector or a horizontal stack thereof.
  
−
This describes penalty terms for pulse waveforms. Returns the penalty function and its gradient for the waveform, which should be supplied as row vector or a horizontal stack thereof. Syntax:
+
==Syntax==
  
−
     [penalty_term,penalty_grad,penalty_hess]=...
+
     [pen_term,pen_grad,pen_hess]=penalty(wf,type,fb,cb)
−
          penalty(waveform,type,floor_bound,ceiling_bound);
 
  
−
If a stack of waveforms is supplied, individual rows of the stack are treated as independent and the penalties are summed together. The penalty terms are usually evaluated within the [[cost_function]] passed as a nested function with its handle to [[fminnewton.m]].
+
==Parameters==
  
−
=Inputs=
+
    wf                          -  control sequence waveform
−
{| class="wikitable"
+
−
|<tt>'waveform'</tt>
+
    type='none'                 -  no waveform penalty.
−
|pulse waveform, supplied as row vector or a horizontal stack thereof.
+
−
|-
+
    type='NS'                   -  norm square, designed to favour
−
|type=<tt>'DNS'</tt>
+
                                  low-power waveforms over high-
−
|derivative norm square penalty term, designed to favour smooth waveforms over jagged ones.
+
                                  power ones.
−
|-
+
−
|type=<tt>'NS'</tt>
+
    type='DNS'                 -  derivative norm square, desig-
−
|norm square penalty term, designed to favour low‐power wave forms over high‐power ones.
+
                                  ned to favour smooth waveforms
−
|-
+
                                  over jagged ones.
−
|type=<tt>'SNS'</tt>
+
−
|spillout norm square penalty term, NS penalty applied to any part of the waveform whose value is outside the floor and ceiling bounds.
+
    type='SNS'                 -  spillout norm square, NS appli-
−
|-
+
                                  ed to the part of the waveform
−
|<tt>'floor_bound'</tt>
+
                                  with values outside the floor
−
|lower bound waveform used in the SNS penalty function.
+
                                  and ceiling bounds.
−
|-
+
−
|<tt>'ceiling_bound'</tt>
+
    type='SNSA'                 -  SNS applied after a transform to
−
|upper bound waveform used in the SNS penalty function.
+
                                  amplitude-phase representation
−
|}
+
                                  Penalises amplitude values outs-
−
If a stack of waveforms is supplied, individual rows of the stack are treated as independent and the penalties are summed together. The waveforms on different channels are assumed to be stored in the rows of the input array. The Hessian elements correspond to the elements of the waveform array ordered as:
+
                                  ide the ceiling bound. Requires
 +
                                  even number of control channels
 +
                                  with waveform rows ordered as:
 +
                                  [Xa Ya Xb Yb ... Xn Yn]
 +
 +
    fb                          - floor bound, a scalar or an array
 +
                                  with the same dimensions as the
 +
                                  waveform used in the SNS penalty
 +
                                  function.
 +
 +
    cb                          -  ceiling bound, a scalar or an ar-
 +
                                  ray with the same dimensions as
 +
                                  the waveform used in the SNS pen-
 +
                                  alty function, scalar only for
 +
                                  the SNSA penalty function.
  
−
    [X1 Y1 Z1 X2 Y2 Z2 ... Xn Yn Zn]
+
==Outputs==
 +
 
 +
    pen_term                    -  value of the penalty term
 +
 +
    pen_grad                    -  gradient of the penalty term with
 +
                                  respect to the waveform vector
 +
 +
    pen_hess                    -  Hessian of the penalty term with
 +
                                  respect to the waveform vector
 +
 
 +
==Notes==
 +
The waveforms on different channels are assumed to be stored in the rows of the input array. The Hessian elements correspond to the elements of the waveform array ordered as:
 +
 
 +
    [X1 Y1 Z1 X2 Y2 Z2 ... Xn Yn Zn]
  
 
where X,Y,Z are different control channels and the index enumerates the time discretization points. Gradient dimensions and element order are the same as the input waveform dimensions and element order.
 
where X,Y,Z are different control channels and the index enumerates the time discretization points. Gradient dimensions and element order are the same as the input waveform dimensions and element order.
  
−
=Outputs=
+
==See also==
−
{| class="wikitable"
+
[[amp_root.m]], [[amp_tanh.m]], [[firf.m]], [[kernelest.m]], [[no_dist.m]], [[restrans.m]], [[spf.m]], [[szf.m]], [[transfermat.m]], [[Optimal control module]]
−
|<tt>'penalty_term'</tt>
+
 
−
|value of the penalty term.
+
''Version 2.11, authors: [[Ilya Kuprov]], [[David Goodwin]]''
−
|-
 
−
|<tt>'penalty_grad'</tt>
 
−
|gradient of the penalty term with respect to the waveform vector.
 
−
|-
 
−
|<tt>'penalty_hess'</tt>
 
−
|Hessian of the penalty term with respect to the waveform vector.
 
−
|}
 

Latest revision as of 06:04, 30 August 2026

Penalty terms for the Optimal Control module. Returns the penalty function and its gradient for the waveform, which should be supplied as row vector or a horizontal stack thereof.

Syntax

    [pen_term,pen_grad,pen_hess]=penalty(wf,type,fb,cb)

Parameters

   wf                          -  control sequence waveform

   type='none'                 -  no waveform penalty.

   type='NS'                   -  norm square, designed to favour
                                  low-power waveforms over high-
                                  power ones.

   type='DNS'                  -  derivative norm square, desig-
                                  ned to favour smooth waveforms
                                  over jagged ones.

   type='SNS'                  -  spillout norm square, NS appli-
                                  ed to the part of the waveform
                                  with values outside the floor
                                  and ceiling bounds.

   type='SNSA'                 -  SNS applied after a transform to
                                  amplitude-phase representation
                                  Penalises amplitude values outs-
                                  ide the ceiling bound. Requires
                                  even number of control channels
                                  with waveform rows ordered as:
                                  [Xa Ya Xb Yb ... Xn Yn]

   fb                          -  floor bound, a scalar or an array
                                  with the same dimensions as the
                                  waveform used in the SNS penalty
                                  function.

   cb                          -  ceiling bound, a scalar or an ar-
                                  ray with the same dimensions as
                                  the waveform used in the SNS pen-
                                  alty function, scalar only for
                                  the SNSA penalty function.

Outputs

   pen_term                    -  value of the penalty term

   pen_grad                    -  gradient of the penalty term with
                                  respect to the waveform vector

   pen_hess                    -  Hessian of the penalty term with
                                  respect to the waveform vector 

Notes

The waveforms on different channels are assumed to be stored in the rows of the input array. The Hessian elements correspond to the elements of the waveform array ordered as:

   [X1 Y1 Z1 X2 Y2 Z2 ... Xn Yn Zn]

where X,Y,Z are different control channels and the index enumerates the time discretization points. Gradient dimensions and element order are the same as the input waveform dimensions and element order.

See also

amp_root.m, amp_tanh.m, firf.m, kernelest.m, no_dist.m, restrans.m, spf.m, szf.m, transfermat.m, Optimal control module

Version 2.11, authors: Ilya Kuprov, David Goodwin