# GRAPE optimization

## Description

The GRAPE Optimization node refers to a gradient-based optimization algorithm known as Gradient Ascent Pulse Engineering (GRAPE), and relevant for quantum optimal control problems. It is an optimization loop which optimizes the control path based on the inputs provided.

## Inputs

The node has the following inputs:

• Problem: A control problem defined by an analytical expression
• Initial control ($u^{(0)}$): An initial control path defined in the Control Node
• Number of Iterations (N): The number of iterations to be run by the optimization algorithm
• Target Fidelity: The optimization algorithm will run until the target fidelity is achieved (unless some other stopping criteria has been met)
• Regularization parameter ($\gamma$):  A real scalar value that penalizes rapid temporal fluctuations in the control field
• Weight factor ($\sigma$): A real scalar value that penalizes controls outside the bounds

## Content

The node has two checkboxes: H1 and BFGS, which enable the choice of search direction. The search direction is based on the gradient information, which are the gradients calulated in iterations 1,2....N. It also has the content fields to specify the bounds of the intial control $u_{0 min}$ and $u_{0 max}$.

## Output

• Updated control ($u^{(i)}$): The updated control at the $i^{th}$ iteration
• Iteration number (i): A real scalar value corresponding to the iteration number
• Fidelity: The fidelity achieved at the $i^{th}$ iteration
• Time-evolving state ({$\psi(t)$}): The aggregate of states over time $t$

## Example

In the example below, a harmonic oscillator potential is controlled which is defined in the Control Problem node. The control path is defined in the Control node which is optimized based on the optimization paremeters provided as inputs to the GRAPE optimization node. The initial path (red) and the optimized path (blue) are plotted together in the Control Comparison Plot. The iteration number (i) and the final fidelity is displyed in the scalar outputs (a).