Skip to content

Commit

Permalink
Adapt to renaing of "ojective" to "trajectory"
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Jan 22, 2024
1 parent 202da02 commit 1556c14
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
43 changes: 22 additions & 21 deletions src/dummy_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Printf
using LinearAlgebra

using QuantumControl.Controls: get_controls, discretize, discretize_on_midpoints
using QuantumControl: Objective, ControlProblem
using QuantumControl: Trajectory, ControlProblem
import QuantumControl

using ..RandomObjects: random_matrix, random_state_vector
Expand All @@ -17,7 +17,7 @@ using ..RandomObjects: random_matrix, random_state_vector
```julia
problem = dummy_control_problem(;
N=10, n_objectives=1, n_controls=1, n_steps=50, dt=1.0, density=0.5,
N=10, n_trajectories=1, n_controls=1, n_steps=50, dt=1.0, density=0.5,
complex_operators=true, hermitian=true, pulses_as_controls=false, rng,
kwargs...)
```
Expand All @@ -27,8 +27,9 @@ Sets up a control problem with random (sparse) Hermitian matrices.
# Arguments
* `N`: The dimension of the Hilbert space
* `n_objectives`: The number of objectives in the optimization. All objectives
will have the same Hamiltonian, but random initial and target states.
* `n_trajectories`: The number of trajectories in the optimization. All
trajectories will have the same Hamiltonian, but random initial and target
states.
* `n_controls`: The number of controls, that is, the number of control terms in
the control Hamiltonian. Each control is an array of random values,
normalized on the intervals of the time grid.
Expand All @@ -50,7 +51,7 @@ Sets up a control problem with random (sparse) Hermitian matrices.
"""
function dummy_control_problem(;
N=10,
n_objectives=1,
n_trajectories=1,
n_controls=1,
n_steps=50,
dt=1.0,
Expand Down Expand Up @@ -83,22 +84,22 @@ function dummy_control_problem(;
push!(hamiltonian, (H_c, control))
end

objectives = [
Objective(;
initial_state=random_state_vector(N; rng),
generator=tuple(hamiltonian...),
trajectories = [
Trajectory(
random_state_vector(N; rng),
tuple(hamiltonian...);
target_state=random_state_vector(N; rng)
) for k = 1:n_objectives
) for k = 1:n_trajectories
]

return ControlProblem(;
objectives=objectives,
return ControlProblem(
trajectories,
tlist;
pulse_options=Dict(
control => Dict(:lambda_a => 1.0, :update_shape => t -> 1.0) for
control in controls
),
prop_method,
tlist,
kwargs...
)
end
Expand All @@ -119,7 +120,7 @@ mutable struct DummyOptimizationResult

function DummyOptimizationResult(problem)
tlist = problem.tlist
controls = get_controls(problem.objectives)
controls = get_controls(problem.trajectories)
iter_start = get(problem.kwargs, :iter_start, 0)
iter = iter_start
iter_stop = get(problem.kwargs, :iter_stop, 20)
Expand All @@ -146,8 +147,8 @@ mutable struct DummyOptimizationResult
end

struct DummyOptimizationWrk
objectives
adjoint_objectives
trajectories
adjoint_trajectories
kwargs
controls
pulses0::Vector{Vector{Float64}}
Expand All @@ -157,9 +158,9 @@ end


function DummyOptimizationWrk(problem)
objectives = [obj for obj in problem.objectives]
adjoint_objectives = [adjoint(obj) for obj in problem.objectives]
controls = get_controls(objectives)
trajectories = [traj for traj in problem.trajectories]
adjoint_trajectories = [adjoint(traj) for traj in problem.trajectories]
controls = get_controls(trajectories)
kwargs = Dict(problem.kwargs)
tlist = problem.tlist
if haskey(kwargs, :continue_from)
Expand All @@ -180,8 +181,8 @@ function DummyOptimizationWrk(problem)
end
pulses1 = [copy(pulse) for pulse in pulses0]
return DummyOptimizationWrk(
objectives,
adjoint_objectives,
trajectories,
adjoint_trajectories,
kwargs,
controls,
pulses0,
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
LocalCoverage = "5f6e1e16-694c-5876-87ef-16b5274f298e"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
QuantumControl = "8a270532-f23f-47a8-83a9-b33d10cad486"
QuantumControlBase = "f10a33bc-5a64-497c-be7b-6f86b4f0c2aa"
QuantumControlTestUtils = "d3fd27c9-1dfb-4e67-b0c0-90d0d87a1e48"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Expand Down

0 comments on commit 1556c14

Please sign in to comment.