MinimumTimeProblem
MinimumTimeProblem converts an existing optimization problem into a time-optimal control problem. It minimizes the total gate duration while maintaining a minimum fidelity constraint.
When to Use
Use MinimumTimeProblem when:
- You have a working solution and want to minimize its duration
- You need the fastest possible gate that achieves a target fidelity
- You're exploring the fidelity-time trade-off
Key Design: Composition Pattern
MinimumTimeProblemwraps an existing QuantumControlProblem. It does not create a problem directly from a trajectory:
# This does NOT work
qcp_mintime = MinimumTimeProblem(qtraj) # Error!
# This works
qcp_base = SmoothPulseProblem(qtraj; Δt_bounds=(0.01, 0.5))
solve!(qcp_base)
qcp_mintime = MinimumTimeProblem(qcp_base; final_fidelity=0.99)Prerequisites
The base problem must have Δt_bounds set to enable variable timesteps:
# Enable free-time optimization in the base problem
qcp_base = SmoothPulseProblem(qtraj; Δt_bounds=(0.01, 0.5))Constructor
MinimumTimeProblem(
qcp::QuantumControlProblem;
goal = nothing,
final_fidelity = 0.99,
D = 100.0,
piccolo_options = PiccoloOptions()
)Parameter Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
qcp | QuantumControlProblem | required | Base problem to convert (must have Δt_bounds) |
goal | AbstractPiccoloOperator or AbstractVector | nothing | Optional new goal (uses base problem's goal if nothing) |
final_fidelity | Float64 | 0.99 | Minimum fidelity constraint |
D | Float64 | 100.0 | Weight on total time objective |
piccolo_options | PiccoloOptions | PiccoloOptions() | Solver options |
Optimization Problem
MinimumTimeProblem sets up:
minimize: J_original + D × Σ Δtₖ
subject to: Original dynamics and constraints
F_final ≥ final_fidelity
Δt_min ≤ Δtₖ ≤ Δt_maxThe parameter D controls the trade-off between the original objective and time minimization. Higher D values prioritize shorter duration.
Examples
Basic Time-Optimal Gate
using Piccolo
# Setup
H_drift = PAULIS[:Z]
H_drives = [PAULIS[:X], PAULIS[:Y]]
sys = QuantumSystem(H_drift, H_drives, [1.0, 1.0])
T, N = 20.0, 100
times = collect(range(0, T, length = N))
pulse = ZeroOrderPulse(0.1 * randn(2, N), times)
qtraj = UnitaryTrajectory(sys, pulse, GATES[:X])
# Step 1: Solve base problem with free time enabled
qcp_base = SmoothPulseProblem(qtraj, N; Q = 100.0, Δt_bounds = (0.05, 0.5))
solve!(qcp_base; max_iter = 100)
sum(get_timesteps(get_trajectory(qcp_base)))23.643816303044666fidelity(qcp_base)0.9999403535049575Step 2: Minimize Time
qcp_mintime = MinimumTimeProblem(qcp_base; final_fidelity = 0.99, D = 100.0)
solve!(qcp_mintime; max_iter = 100)
sum(get_timesteps(get_trajectory(qcp_mintime)))13.643538876567835fidelity(qcp_mintime)0.9900010557899727Exploring Fidelity-Time Trade-off
results = []
for target_fidelity in [0.999, 0.99, 0.95, 0.90]
qcp_mt = MinimumTimeProblem(qcp_base; final_fidelity = target_fidelity)
solve!(
qcp_mt;
max_iter = 100,
verbose = false,
print_level = 1,
)
dur = sum(get_timesteps(get_trajectory(qcp_mt)))
push!(results, (target = target_fidelity, duration = dur, achieved = fidelity(qcp_mt)))
end
println("Fidelity-Time Trade-off")
println("─"^50)
for r in results
@printf(
" Target: %.3f │ Duration: %.3f │ Achieved: %.4f\n",
r.target,
r.duration,
r.achieved
)
endconstructing MinimumTimeProblem [from UnitaryTrajectory]
final fidelity ≥ 0.999
min-time weight D = 100.0
QuantumControlProblem
├─ UnitaryTrajectory · ZeroOrderPulse · BilinearIntegrator, DerivativeIntegrator, DerivativeIntegrator
│
├─ System
│ dim=2 drives=2
│
├─ Trajectory
│ N=100 T=23.407 Δt∈[0.05, 0.5]
│ Ũ⃗ (8) ±[1.0, 1.0, 1.0, … (8 total)] ✓ state
│ Δt (1) [0.05, 0.5] ✓ timestep
│ t (1) · state
│ u (2) ±[1.0, 1.0] ✓ control
│ du (2) · control
│ ddu (2) ±[1.0, 1.0] ✓ control
│
├─ Goal
│ U_goal (2×2)
│
├─ Objective total = 2341 @ current x
│ KnotPointObjective w=1 1.649e-07
│ QuadraticRegularizer(:u) w=1 2.968e-04
│ QuadraticRegularizer(:du) w=1 7.039e-04
│ QuadraticRegularizer(:ddu) w=1 2.250e-03
│ NullObjective w=1 0
│ MinimumTimeObjective w=1 2341
│
├─ Constraints 4/14 violated at x₀
│ [dyn] BilinearIntegrator ✗ (‖c‖∞ = 8.071e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 1.174e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 2.019e-05)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [eq] TimeConsistencyConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [ineq] Terminal fidelity bound on :Ũ⃗ ✗ (viol = 1.000e-03)
│
└─ Status
variables: 1600 (1300 bounded)
equality: 117617
inequality: 1
F (raw) = 0.990001
Hint: show_problem(qcp; detail=:full) for pulse plot + sparsity
constructing MinimumTimeProblem [from UnitaryTrajectory]
final fidelity ≥ 0.99
min-time weight D = 100.0
QuantumControlProblem
├─ UnitaryTrajectory · ZeroOrderPulse · BilinearIntegrator, DerivativeIntegrator, DerivativeIntegrator
│
├─ System
│ dim=2 drives=2
│
├─ Trajectory
│ N=100 T=23.407 Δt∈[0.05, 0.5]
│ Ũ⃗ (8) ±[1.0, 1.0, 1.0, … (8 total)] ✓ state
│ Δt (1) [0.05, 0.5] ✓ timestep
│ t (1) · state
│ u (2) ±[1.0, 1.0] ✓ control
│ du (2) · control
│ ddu (2) ±[1.0, 1.0] ✓ control
│
├─ Goal
│ U_goal (2×2)
│
├─ Objective total = 2341 @ current x
│ KnotPointObjective w=1 1.649e-07
│ QuadraticRegularizer(:u) w=1 2.968e-04
│ QuadraticRegularizer(:du) w=1 7.039e-04
│ QuadraticRegularizer(:ddu) w=1 2.250e-03
│ NullObjective w=1 0
│ MinimumTimeObjective w=1 2341
│
├─ Constraints 4/14 violated at x₀
│ [dyn] BilinearIntegrator ✗ (‖c‖∞ = 8.071e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 1.174e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 2.019e-05)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [eq] TimeConsistencyConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [ineq] Terminal fidelity bound on :Ũ⃗ ✗ (viol = 1.000e-02)
│
└─ Status
variables: 1600 (1300 bounded)
equality: 117617
inequality: 1
F (raw) = 0.999003
Hint: show_problem(qcp; detail=:full) for pulse plot + sparsity
constructing MinimumTimeProblem [from UnitaryTrajectory]
final fidelity ≥ 0.95
min-time weight D = 100.0
QuantumControlProblem
├─ UnitaryTrajectory · ZeroOrderPulse · BilinearIntegrator, DerivativeIntegrator, DerivativeIntegrator
│
├─ System
│ dim=2 drives=2
│
├─ Trajectory
│ N=100 T=23.407 Δt∈[0.05, 0.5]
│ Ũ⃗ (8) ±[1.0, 1.0, 1.0, … (8 total)] ✓ state
│ Δt (1) [0.05, 0.5] ✓ timestep
│ t (1) · state
│ u (2) ±[1.0, 1.0] ✓ control
│ du (2) · control
│ ddu (2) ±[1.0, 1.0] ✓ control
│
├─ Goal
│ U_goal (2×2)
│
├─ Objective total = 2341 @ current x
│ KnotPointObjective w=1 1.649e-07
│ QuadraticRegularizer(:u) w=1 2.968e-04
│ QuadraticRegularizer(:du) w=1 7.039e-04
│ QuadraticRegularizer(:ddu) w=1 2.250e-03
│ NullObjective w=1 0
│ MinimumTimeObjective w=1 2341
│
├─ Constraints 4/14 violated at x₀
│ [dyn] BilinearIntegrator ✗ (‖c‖∞ = 8.071e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 1.174e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 2.019e-05)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [eq] TimeConsistencyConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [ineq] Terminal fidelity bound on :Ũ⃗ ✗ (viol = 0.05)
│
└─ Status
variables: 1600 (1300 bounded)
equality: 117617
inequality: 1
F (raw) = 0.990001
Hint: show_problem(qcp; detail=:full) for pulse plot + sparsity
constructing MinimumTimeProblem [from UnitaryTrajectory]
final fidelity ≥ 0.9
min-time weight D = 100.0
QuantumControlProblem
├─ UnitaryTrajectory · ZeroOrderPulse · BilinearIntegrator, DerivativeIntegrator, DerivativeIntegrator
│
├─ System
│ dim=2 drives=2
│
├─ Trajectory
│ N=100 T=23.407 Δt∈[0.05, 0.5]
│ Ũ⃗ (8) ±[1.0, 1.0, 1.0, … (8 total)] ✓ state
│ Δt (1) [0.05, 0.5] ✓ timestep
│ t (1) · state
│ u (2) ±[1.0, 1.0] ✓ control
│ du (2) · control
│ ddu (2) ±[1.0, 1.0] ✓ control
│
├─ Goal
│ U_goal (2×2)
│
├─ Objective total = 2341 @ current x
│ KnotPointObjective w=1 1.649e-07
│ QuadraticRegularizer(:u) w=1 2.968e-04
│ QuadraticRegularizer(:du) w=1 7.039e-04
│ QuadraticRegularizer(:ddu) w=1 2.250e-03
│ NullObjective w=1 0
│ MinimumTimeObjective w=1 2341
│
├─ Constraints 4/14 violated at x₀
│ [dyn] BilinearIntegrator ✗ (‖c‖∞ = 8.071e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 1.174e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 2.019e-05)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [eq] TimeConsistencyConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [ineq] Terminal fidelity bound on :Ũ⃗ ✗ (viol = 0.1)
│
└─ Status
variables: 1600 (1300 bounded)
equality: 117617
inequality: 1
F (raw) = 0.950005
Hint: show_problem(qcp; detail=:full) for pulse plot + sparsity
Fidelity-Time Trade-off
──────────────────────────────────────────────────
Target: 0.999 │ Duration: 13.719 │ Achieved: 0.9990
Target: 0.990 │ Duration: 13.644 │ Achieved: 0.9900
Target: 0.950 │ Duration: 13.510 │ Achieved: 0.9500
Target: 0.900 │ Duration: 13.414 │ Achieved: 0.9000With Robust Optimization
Chain with SamplingProblem for robust time-optimal control:
# Base problem
qcp_base = SmoothPulseProblem(qtraj, N; Q=100.0, Δt_bounds=(0.05, 0.5))
solve!(qcp_base; max_iter=100)
# Add robustness
sys_perturbed = QuantumSystem(1.1 * H_drift, H_drives, [1.0, 1.0])
qcp_robust = SamplingProblem(qcp_base, [sys, sys_perturbed])
solve!(qcp_robust; max_iter=100)
# Minimize time while maintaining robustness
qcp_mintime = MinimumTimeProblem(qcp_robust; final_fidelity=0.95)
solve!(qcp_mintime; max_iter=100)Fidelity Constraints by Trajectory Type
MinimumTimeProblem automatically adds the appropriate fidelity constraint based on the trajectory type:
| Trajectory Type | Constraint Type |
|---|---|
UnitaryTrajectory | FinalUnitaryFidelityConstraint |
KetTrajectory | FinalKetFidelityConstraint |
MultiKetTrajectory | FinalCoherentKetFidelityConstraint |
DensityTrajectory | Not yet implemented |
Tips
Setting D
The D parameter controls the weight on total time:
- Higher D (e.g., 1000): Aggressively minimize time, may sacrifice fidelity margin
- Lower D (e.g., 10): More conservative, maintains fidelity buffer
Initial Solution Quality
MinimumTimeProblem works best when starting from a good solution. If your base problem has low fidelity, solve it first:
# Ensure good initial solution
qcp_base = SmoothPulseProblem(qtraj, N; Q=1000.0, Δt_bounds=(0.05, 0.5))
solve!(qcp_base; max_iter=200)
# Only then minimize time
if fidelity(qcp_base) > 0.99
qcp_mintime = MinimumTimeProblem(qcp_base; final_fidelity=0.99)
solve!(qcp_mintime; max_iter=100)
endChanging the Goal
You can optimize for a different goal without recreating the base problem:
qcp_y = MinimumTimeProblem(qcp_base; goal = GATES[:Y], final_fidelity = 0.99)
solve!(qcp_y; max_iter = 100)constructing MinimumTimeProblem [from UnitaryTrajectory]
final fidelity ≥ 0.99
min-time weight D = 100.0
QuantumControlProblem
├─ UnitaryTrajectory · ZeroOrderPulse · BilinearIntegrator, DerivativeIntegrator, DerivativeIntegrator
│
├─ System
│ dim=2 drives=2
│
├─ Trajectory
│ N=100 T=23.407 Δt∈[0.05, 0.5]
│ Ũ⃗ (8) ±[1.0, 1.0, 1.0, … (8 total)] ✓ state
│ Δt (1) [0.05, 0.5] ✓ timestep
│ t (1) · state
│ u (2) ±[1.0, 1.0] ✓ control
│ du (2) · control
│ ddu (2) ±[1.0, 1.0] ✓ control
│
├─ Goal
│ U_goal (2×2)
│
├─ Objective total = 2341 @ current x
│ KnotPointObjective w=1 1.649e-07
│ QuadraticRegularizer(:u) w=1 2.968e-04
│ QuadraticRegularizer(:du) w=1 7.039e-04
│ QuadraticRegularizer(:ddu) w=1 2.250e-03
│ NullObjective w=1 0
│ MinimumTimeObjective w=1 2341
│
├─ Constraints 4/14 violated at x₀
│ [dyn] BilinearIntegrator ✗ (‖c‖∞ = 8.071e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 1.174e-05)
│ [dyn] DerivativeIntegrator ✗ (‖c‖∞ = 2.019e-05)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [bnd] BoundsConstraint ✓
│ [eq] TimeConsistencyConstraint ✓ (no eval)
│ [eq] EqualityConstraint ✓ (no eval)
│ [ineq] Terminal fidelity bound on :Ũ⃗ ✗ (viol = 0.99)
│
└─ Status
variables: 1600 (1300 bounded)
equality: 117617
inequality: 1
F (raw) = 0.001946
Hint: show_problem(qcp; detail=:full) for pulse plot + sparsity
This is Ipopt version 3.14.19, running with linear solver MUMPS 5.8.2.
Number of nonzeros in equality constraint Jacobian...: 38354
Number of nonzeros in inequality constraint Jacobian.: 8
Number of nonzeros in Lagrangian Hessian.............: 38584
Total number of variables............................: 1587
variables with only lower bounds: 0
variables with lower and upper bounds: 1288
variables with only upper bounds: 0
Total number of equality constraints.................: 1386
Total number of inequality constraints...............: 1
inequality constraints with only lower bounds: 0
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 2.3427311e+03 9.90e-01 2.06e+00 0.0 0.00e+00 - 0.00e+00 0.00e+00 0
1 2.3426916e+03 9.90e-01 9.67e+01 -2.1 1.00e+00 2.0 9.89e-01 9.90e-03h 1
2 2.3426899e+03 9.90e-01 9.87e+05 -1.5 9.90e-01 1.5 1.00e+00 1.00e-04h 1
3 2.3424570e+03 9.90e-01 1.06e+06 0.5 1.25e+03 1.0 9.90e-05 7.97e-06f 5
4 2.3415879e+03 9.87e-01 2.66e+04 0.3 4.78e+01 1.5 3.77e-02 8.38e-04f 3
⋮
96 1.3148900e+03 2.52e-04 1.91e+01 -1.2 6.77e+00 -0.5 9.12e-02 6.15e-02f 1
97 1.3139283e+03 1.77e-04 1.28e+01 -2.1 5.15e-01 -0.1 3.87e-01 3.27e-01f 1
98 1.3130489e+03 1.94e-04 1.50e+01 -3.2 2.43e+00 -0.6 2.16e-01 1.47e-01f 1
99 1.3125146e+03 1.44e-04 1.82e+01 -2.1 5.80e-01 -0.1 7.26e-01 3.17e-01f 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
100 1.3122809e+03 1.88e-04 1.40e+01 -1.8 3.24e+00 -0.6 4.13e-02 1.07e-01f 1
Number of Iterations....: 100
(scaled) (unscaled)
Objective...............: 1.3122729258977306e+03 1.3122808704679110e+03
Dual infeasibility......: 1.3950796387793389e+01 1.3950880846657691e+01
Constraint violation....: 1.8762592720325544e-04 1.8762592720325544e-04
Variable bound violation: 0.0000000000000000e+00 0.0000000000000000e+00
Complementarity.........: 1.1712033424529774e-02 1.1712104329803867e-02
Overall NLP error.......: 1.3950796387793389e+01 1.3950880846657691e+01
Number of objective function evaluations = 117
Number of objective gradient evaluations = 101
Number of equality constraint evaluations = 117
Number of inequality constraint evaluations = 117
Number of equality constraint Jacobian evaluations = 101
Number of inequality constraint Jacobian evaluations = 101
Number of Lagrangian Hessian evaluations = 100
Total seconds in IPOPT = 20.777
EXIT: Maximum Number of Iterations Exceeded.
initializing optimizer...
applying constraint: timesteps all equal constraint
applying constraint: initial value of Ũ⃗
applying constraint: initial value of u
applying constraint: final value of u
applying constraint: bounds on Ũ⃗
applying constraint: bounds on u
applying constraint: bounds on Δt
applying constraint: bounds on du
applying constraint: bounds on ddu
applying constraint: time consistency constraint (t_{k+1} = t_k + Δt_k)
applying constraint: initial time t₁ = 0
[ Info: Loaded cached trajectory from mintime_y_gate_573ffb2.jld2See Also
- SmoothPulseProblem - Base problem for piecewise constant controls
- BangBangPulseProblem - Base problem for bang-bang controls
- SplinePulseProblem - Base problem for spline controls
- SamplingProblem - Add robustness before minimizing time
- Composing Templates - Advanced composition patterns
This page was generated using Literate.jl.