Skip to content

Commit 1556c14

Browse files
committed
Adapt to renaing of "ojective" to "trajectory"
1 parent 202da02 commit 1556c14

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

src/dummy_problem.jl

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using Printf
77
using LinearAlgebra
88

99
using QuantumControl.Controls: get_controls, discretize, discretize_on_midpoints
10-
using QuantumControl: Objective, ControlProblem
10+
using QuantumControl: Trajectory, ControlProblem
1111
import QuantumControl
1212

1313
using ..RandomObjects: random_matrix, random_state_vector
@@ -17,7 +17,7 @@ using ..RandomObjects: random_matrix, random_state_vector
1717
1818
```julia
1919
problem = dummy_control_problem(;
20-
N=10, n_objectives=1, n_controls=1, n_steps=50, dt=1.0, density=0.5,
20+
N=10, n_trajectories=1, n_controls=1, n_steps=50, dt=1.0, density=0.5,
2121
complex_operators=true, hermitian=true, pulses_as_controls=false, rng,
2222
kwargs...)
2323
```
@@ -27,8 +27,9 @@ Sets up a control problem with random (sparse) Hermitian matrices.
2727
# Arguments
2828
2929
* `N`: The dimension of the Hilbert space
30-
* `n_objectives`: The number of objectives in the optimization. All objectives
31-
will have the same Hamiltonian, but random initial and target states.
30+
* `n_trajectories`: The number of trajectories in the optimization. All
31+
trajectories will have the same Hamiltonian, but random initial and target
32+
states.
3233
* `n_controls`: The number of controls, that is, the number of control terms in
3334
the control Hamiltonian. Each control is an array of random values,
3435
normalized on the intervals of the time grid.
@@ -50,7 +51,7 @@ Sets up a control problem with random (sparse) Hermitian matrices.
5051
"""
5152
function dummy_control_problem(;
5253
N=10,
53-
n_objectives=1,
54+
n_trajectories=1,
5455
n_controls=1,
5556
n_steps=50,
5657
dt=1.0,
@@ -83,22 +84,22 @@ function dummy_control_problem(;
8384
push!(hamiltonian, (H_c, control))
8485
end
8586

86-
objectives = [
87-
Objective(;
88-
initial_state=random_state_vector(N; rng),
89-
generator=tuple(hamiltonian...),
87+
trajectories = [
88+
Trajectory(
89+
random_state_vector(N; rng),
90+
tuple(hamiltonian...);
9091
target_state=random_state_vector(N; rng)
91-
) for k = 1:n_objectives
92+
) for k = 1:n_trajectories
9293
]
9394

94-
return ControlProblem(;
95-
objectives=objectives,
95+
return ControlProblem(
96+
trajectories,
97+
tlist;
9698
pulse_options=Dict(
9799
control => Dict(:lambda_a => 1.0, :update_shape => t -> 1.0) for
98100
control in controls
99101
),
100102
prop_method,
101-
tlist,
102103
kwargs...
103104
)
104105
end
@@ -119,7 +120,7 @@ mutable struct DummyOptimizationResult
119120

120121
function DummyOptimizationResult(problem)
121122
tlist = problem.tlist
122-
controls = get_controls(problem.objectives)
123+
controls = get_controls(problem.trajectories)
123124
iter_start = get(problem.kwargs, :iter_start, 0)
124125
iter = iter_start
125126
iter_stop = get(problem.kwargs, :iter_stop, 20)
@@ -146,8 +147,8 @@ mutable struct DummyOptimizationResult
146147
end
147148

148149
struct DummyOptimizationWrk
149-
objectives
150-
adjoint_objectives
150+
trajectories
151+
adjoint_trajectories
151152
kwargs
152153
controls
153154
pulses0::Vector{Vector{Float64}}
@@ -157,9 +158,9 @@ end
157158

158159

159160
function DummyOptimizationWrk(problem)
160-
objectives = [obj for obj in problem.objectives]
161-
adjoint_objectives = [adjoint(obj) for obj in problem.objectives]
162-
controls = get_controls(objectives)
161+
trajectories = [traj for traj in problem.trajectories]
162+
adjoint_trajectories = [adjoint(traj) for traj in problem.trajectories]
163+
controls = get_controls(trajectories)
163164
kwargs = Dict(problem.kwargs)
164165
tlist = problem.tlist
165166
if haskey(kwargs, :continue_from)
@@ -180,8 +181,8 @@ function DummyOptimizationWrk(problem)
180181
end
181182
pulses1 = [copy(pulse) for pulse in pulses0]
182183
return DummyOptimizationWrk(
183-
objectives,
184-
adjoint_objectives,
184+
trajectories,
185+
adjoint_trajectories,
185186
kwargs,
186187
controls,
187188
pulses0,

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
77
LocalCoverage = "5f6e1e16-694c-5876-87ef-16b5274f298e"
88
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
99
QuantumControl = "8a270532-f23f-47a8-83a9-b33d10cad486"
10+
QuantumControlBase = "f10a33bc-5a64-497c-be7b-6f86b4f0c2aa"
1011
QuantumControlTestUtils = "d3fd27c9-1dfb-4e67-b0c0-90d0d87a1e48"
1112
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
1213
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"

0 commit comments

Comments
 (0)