kestrelquantum / QuantumCollocation.jl

Quantum Optimal Control with Direct Collocation
MIT License
29 stars 7 forks source link

[Feature]: unsymmetric constraints on the pulses and first order derivative constraints of the pulses #90

Closed hongyehu closed 4 months ago

hongyehu commented 4 months ago

Feature Description

In quantum control using the ansatz Hamiltonian: $H(t) = H{drift} + \sum{i} a{i}(t)H{i}$. Sometimes the machine requires:

  1. unsymmetric constraints, $ai(t)\in [a{min},a{max}]$, where $a{min}\neq - a{max}$. For example, $a{i}(t)\in [0,2.5]$.
  2. slope constraints: sometimes, machine requires $$|(a{i}(t{l+1})-a{i}(t{l}))/(t{l+1}-t{l})| \leq C$$ for piecewise linear function or $| da_{i}(t) / dt | \leq C$ for true continuous pulse. (But the machine uses piecewise linear even if one provides continuous function mostly) It would be great to add a new feature to set those two constraints in the solver!

Importance

5 (highest)

What does this feature affect?

Other information

related to a deadline for experiments.

andgoldschmidt commented 4 months ago

Both of these are hidden by the problem template structure, but you can get more fine-grained control over the problem data if we look one layer deeper. Check out this fragment from the UnitarySmoothPulseProblem (line ~206)

components = (
    Ũ⃗ = Ũ⃗,
    a = a,
    da = da,
    dda = dda,
)

bounds = (
    a = a_bounds,
    dda = dda_bounds,
)

traj = NamedTrajectory(
    components;
    controls=(:dda,),
    timestep=Δt,
    bounds=bounds,
    initial=initial,
    final=final,
    goal=goal
)
  1. You can directly specify the bounds you'd like. In a UnitarySmoothPulseProblem, we use symmetric bounds. However, bounds is just a tuple with the form: ([lower, vector, entries], [upper, vector, entries]). The number of vector entries should correspond to the number of controls in the control matrix.

  2. The slope constraint can be set using a da_bound. In a UnitarySmoothPulseProblem, we use $\ddot{a}$ as the control variable---it is Euler integrated twice to get back to $a$. Hence, you have direct access to $\dot{a}$ and can append your constraint, mimicking the style of the others.

andgoldschmidt commented 4 months ago

Our recommended workflow is to write a new problem template that is adapted to your desired problem. You can start from an existing template and make piecemeal changes to adapt it to your needs.

One current goal is to document this workflow and make our problem templates into much cleaner minimal working examples to better enable this workflow.

andgoldschmidt commented 4 months ago

Closing with a note to improve docs and template flexibility.