Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
89841c1
interface changes
aarontrowbridge Mar 10, 2025
879c9de
refactor: update density operator problem and coherent ket function f…
aarontrowbridge Mar 10, 2025
c0e35d5
refactor: replace hardcoded integrator with parameterized ket_integra…
aarontrowbridge Mar 12, 2025
b1a0831
refactor: simplify unitary smooth pulse problem tests and normalize i…
aarontrowbridge Mar 12, 2025
8fac1f5
refactor: improve logging options and enhance infidelity loss calcula…
aarontrowbridge Mar 12, 2025
89cb570
prune piccolo options
andgoldschmidt Mar 12, 2025
e551bb7
refactor: rename and simplify infidelity loss functions for improved …
aarontrowbridge Mar 12, 2025
3920ad9
refactor: add quantum constraints module and update problem templates…
andgoldschmidt Mar 13, 2025
cac7c64
Merge branch 'refactor/direct-collocation-backend' of github.com:harm…
andgoldschmidt Mar 13, 2025
e756e92
patch: drop density include
andgoldschmidt Mar 13, 2025
4f8730d
update min time for flipped inequality constraint
andgoldschmidt Mar 13, 2025
06d2c09
stop reexporting PQO
andgoldschmidt Mar 13, 2025
ec4d294
remove stale usings
andgoldschmidt Mar 13, 2025
6ed7d7e
add unitary problem templates to docs
andgoldschmidt Mar 14, 2025
7daf7eb
state templates in docs
andgoldschmidt Mar 14, 2025
e855307
add using PQO because of removal of reexport
jack-champagne Mar 14, 2025
e1374ee
patch: missing single state min time method
andgoldschmidt Mar 14, 2025
8ef5fbd
Added Adjoint Integrator
BBhattacharyya1729 Mar 21, 2025
2b09f27
Fixed Adjoint
BBhattacharyya1729 Mar 22, 2025
a53ed73
Fixed Adjoint
BBhattacharyya1729 Mar 26, 2025
a722833
Final Adjoint
BBhattacharyya1729 Mar 27, 2025
dbc8777
in progress variational problem template
andgoldschmidt Apr 1, 2025
3be4102
variational PT, replace terminal loss -> terminal obj (bump DTO 0.2)
andgoldschmidt Apr 1, 2025
f77e763
document PT
andgoldschmidt Apr 1, 2025
4f31751
enhance sensitivity handling with scaling
andgoldschmidt Apr 3, 2025
0d07f47
var symb name
andgoldschmidt Apr 3, 2025
c637f7b
add variational PT test
andgoldschmidt Apr 3, 2025
3a580a0
fix: G_vars integration typing
andgoldschmidt Apr 7, 2025
e4516c8
scale -> scales for each variational state
andgoldschmidt Apr 9, 2025
10f2189
fix tests
andgoldschmidt Apr 9, 2025
d286130
Merge commit 'e1374ee98539373120cddb6a7e6f293ea539a298' into feature/…
andgoldschmidt Apr 15, 2025
4c79e88
docs for var prob
andgoldschmidt Apr 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
state templates in docs
  • Loading branch information
andgoldschmidt committed Mar 14, 2025
commit 7daf7eb07288e59f0f0cbd5fb3afde806920687c
132 changes: 92 additions & 40 deletions docs/literate/man/problem_templates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,100 @@ certain types of quantum optimal control problems. These templates all construct
This page provides a brief overview of each problem template, broken down by the state of
the problem being solved.

Ket Problem Templates:
- [Quantum State Smooth Pulse Problem](#Quantum-State-Smooth-Pulse-Problem)
- [Quantum State Minimum Time Problem](#Quantum-State-Minimum-Time-Problem)
- [Quantum State Sampling Problem](#Quantum-State-Sampling-Problem)

Unitary Problem Templates:
- [Unitary Smooth Pulse Problem](#Unitary-Smooth-Pulse-Problem)
- [Unitary Minimum Time Problem](#Unitary-Minimum-Time-Problem)
- [Unitary Sampling Problem](#Unitary-Sampling-Problem)
=#

Ket Problem Templates:
- [Quantum State Smooth Pulse Problem](#Quantum-State-Smooth-Pulse-Problem)
- [Quantum State Minimum Time Problem](#Quantum-State-Minimum-Time-Problem)
- [Quantum State Sampling Problem](#Quantum-State-Sampling-Problem)
# -----
# ## Ket Problem Templates

#=
#### Quantum State Smooth Pulse Problem
```@docs; canonical = false
QuantumStateSmoothPulseProblem
```

Each problem starts with a `QuantumSystem` object, which is used to define the system's
Hamiltonian and control operators. The goal is to find a control pulse that drives the
intial state, `ψ_init`, to a target state, `ψ_goal`.
=#

# _define the quantum system_
system = QuantumSystem(0.1 * PAULIS.Z, [PAULIS.X, PAULIS.Y])
ψ_init = Vector{ComplexF64}([1.0, 0.0])
ψ_goal = Vector{ComplexF64}([0.0, 1.0])
T = 51
Δt = 0.2

# _create the smooth pulse problem_
state_prob = QuantumStateSmoothPulseProblem(system, ψ_init, ψ_goal, T, Δt);

# _check the fidelity before solving_
println("Before: ", rollout_fidelity(state_prob.trajectory, system))

# _solve the problem_
solve!(state_prob, max_iter=100, verbose=true, print_level=1);

# _check the fidelity after solving_
println("After: ", rollout_fidelity(state_prob.trajectory, system))

# _extract the control pulses_
state_prob.trajectory.a |> size

#=
#### Quantum State Minimum Time Problem
```@docs; canonical = false
QuantumStateMinimumTimeProblem
```
=#

# _create the minimum time problem_
min_state_prob = QuantumStateMinimumTimeProblem(state_prob, ψ_goal);

# _check the previous duration_
println("Duration before: ", get_duration(state_prob.trajectory))

# _solve the minimum time problem_
solve!(min_state_prob, max_iter=100, verbose=true, print_level=1);

# _check the new duration_
println("Duration after: ", get_duration(min_state_prob.trajectory))

# _the fidelity is preserved by a constraint_
println("Fidelity after: ", rollout_fidelity(min_state_prob.trajectory, system))

#=
#### Quantum State Sampling Problem
```@docs; canonical = false
QuantumStateSamplingProblem
```
=#

# _create a sampling problem_
driftless_system = QuantumSystem([PAULIS.X, PAULIS.Y])
sampling_state_prob = QuantumStateSamplingProblem([system, driftless_system], ψ_init, ψ_goal, T, Δt);

# _new keys are added to the trajectory for the new states_
println(sampling_state_prob.trajectory.state_names)

# _solve the sampling problem for a few iterations_
solve!(sampling_state_prob, max_iter=25, verbose=true, print_level=1);

# _check the fidelity of the sampling problem (use the updated key to get the initial and goal)_
println("After (original system): ", rollout_fidelity(sampling_state_prob.trajectory, system, state_name=:ψ̃1_system_1))
println("After (new system): ", rollout_fidelity(sampling_state_prob.trajectory, driftless_system, state_name=:ψ̃1_system_1))

# _compare this to using the original problem on the new system_
println("After (new system, original `prob`): ", rollout_fidelity(state_prob.trajectory, driftless_system))


# -----
# ## Unitary Problem Templates

Expand All @@ -36,10 +119,10 @@ Ket Problem Templates:
UnitarySmoothPulseProblem
```

Each problem starts with a `QuantumSystem` object, which is used to define the system's
Hamiltonian and control operators. The goal is to find a control pulse that drives the
system to a target unitary operator, `U_goal`. The problem is solved by minimizing the
difference between the target unitary and the unitary generated by the control pulse.
The `UnitarySmoothPulseProblem` is similar to the `QuantumStateSmoothPulseProblem`, but
instead of driving the system to a target state, the goal is to drive the system to a
target unitary operator, `U_goal`.

=#

system = QuantumSystem(0.1 * PAULIS.Z, [PAULIS.X, PAULIS.Y])
Expand Down Expand Up @@ -106,40 +189,9 @@ This can be useful for exploring robustness, for example.
driftless_system = QuantumSystem([PAULIS.X, PAULIS.Y])
sampling_prob = UnitarySamplingProblem([system, driftless_system], U_goal, T, Δt);

# _solve the sampling problem_
solve!(sampling_prob, max_iter=100, verbose=true, print_level=1);

# _new keys are addded to the trajectory for the new states_
println(sampling_prob.trajectory.state_names)

# _check the fidelity of the sampling problem_
println("After on original system: ", unitary_rollout_fidelity(sampling_prob.trajectory, system, unitary_name=:Ũ⃗_system_1))
println("After on new system: ", unitary_rollout_fidelity(sampling_prob.trajectory, driftless_system, unitary_name=:Ũ⃗_system_1))

# _compare this to using the original problem on the new system_
println("After on new system with original problem: ", unitary_rollout_fidelity(prob.trajectory, driftless_system))
# _the `solve!` proceeds as in the [Quantum State Sampling Problem](#Quantum-State-Sampling-Problem)]_


# -----
# ## Ket Problem Templates

#=
#### Quantum State Smooth Pulse Problem
```@docs; canonical = false
QuantumStateSmoothPulseProblem
```
=#

#=
#### Quantum State Minimum Time Problem
```@docs; canonical = false
QuantumStateMinimumTimeProblem
```
=#

#=
#### Quantum State Sampling Problem
```@docs; canonical = false
QuantumStateSamplingProblem
```
=#
Loading