Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7f9c195
feat: add boilerplate and inner function call
jack-champagne Sep 25, 2024
7f35b40
add callbacks tests
jack-champagne Sep 25, 2024
f25a057
add tmp callback changes
jack-champagne Nov 11, 2024
1a0e8fb
Merge branch 'main' into feature/ipopt-callbacks
jack-champagne Nov 11, 2024
f88cde8
add docstrings
jack-champagne Nov 11, 2024
81cbad7
add generic callback factory
jack-champagne Nov 11, 2024
6b4a6cc
Merge commit '18d52526351f71093d7bca9b111779ac00e77bb4' into feature/…
andgoldschmidt Nov 11, 2024
6428fa6
add get best iterate to callbacks lib
jack-champagne Nov 12, 2024
70d5fa1
fix renamed callback
jack-champagne Nov 12, 2024
972aea9
move callback tests, rename callbacks
andgoldschmidt Nov 12, 2024
587c051
Merge branch 'feature/ipopt-callbacks' of github.com:kestrelquantum/Q…
andgoldschmidt Nov 12, 2024
bc406f3
local project toml changes
jack-champagne Nov 12, 2024
d267338
remove pulse animation pngs
jack-champagne Nov 12, 2024
ddb9f0e
add NamedTrajectories to docs compat
jack-champagne Nov 12, 2024
e5e64c6
fix typo NM version
jack-champagne Nov 12, 2024
1701f19
roll back callback fidelity
andgoldschmidt Nov 12, 2024
e8dabda
Merge branch 'feature/ipopt-callbacks' of github.com:kestrelquantum/Q…
andgoldschmidt Nov 12, 2024
0ecef44
rm manifest
jack-champagne Nov 12, 2024
1c4d641
test unitary fid callback
andgoldschmidt Nov 12, 2024
f712b40
fix doctests
jack-champagne Nov 12, 2024
e4f7cbc
fixup docs
jack-champagne Nov 12, 2024
a1586aa
callbacks version bump
jack-champagne Nov 12, 2024
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
test unitary fid callback
  • Loading branch information
andgoldschmidt committed Nov 12, 2024
commit 1c4d641f7734d7b34162d2a143b2297b45db2ae4
32 changes: 30 additions & 2 deletions src/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function best_rollout_fidelity_callback(prob::QuantumControlProblem)
end

function best_unitary_rollout_fidelity_callback(prob::QuantumControlProblem)
return best_rollout_callback(prob, fidelity_unitary)
return best_rollout_callback(prob, unitary_fidelity)
end

function trajectory_history_callback(prob::QuantumControlProblem)
Expand Down Expand Up @@ -82,7 +82,7 @@ end
@test length(trajectory_history) == 21
end

@testitem "Callback can get best trajectory" begin
@testitem "Callback can get best state trajectory" begin
using MathOptInterface
using NamedTrajectories
const MOI = MathOptInterface
Expand Down Expand Up @@ -110,6 +110,34 @@ end
@test after ≤ best
end

@testitem "Callback can get best unitary trajectory" begin
using MathOptInterface
using NamedTrajectories
const MOI = MathOptInterface
include("../test/test_utils.jl")

prob, system = smooth_unitary_problem(return_system=true)

callback, best_trajs = best_unitary_rollout_fidelity_callback(prob)
@test length(best_trajs) == 0

# measure fidelity
before = unitary_fidelity(prob)
solve!(prob, max_iter=20, callback=callback)

# length must increase if iterations are made
@test length(best_trajs) > 0
@test best_trajs[end] isa NamedTrajectory

# fidelity ranking
after = unitary_fidelity(prob)
best = unitary_fidelity(best_trajs[end], system)

@test before < after
@test before < best
@test after ≤ best
end

@testitem "Callback with full parameter test" begin
using MathOptInterface
using NamedTrajectories
Expand Down
17 changes: 17 additions & 0 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,20 @@ function smooth_quantum_state_problem(; return_system::Bool=false)
return prob
end
end

function smooth_unitary_problem(; return_system::Bool=false)
T = 50
Δt = 0.2
sys = QuantumSystem(0.1 * PAULIS[:Z], [PAULIS[:X], PAULIS[:Y]])
U_goal = GATES[:H]
prob = UnitarySmoothPulseProblem(
sys, U_goal, T, Δt;
ipopt_options=IpoptOptions(print_level=1),
piccolo_options=PiccoloOptions(verbose=false)
)
if return_system
return prob, sys
else
return prob
end
end
Loading