@@ -2,6 +2,7 @@ module DummyOptimization
22
33export dummy_control_problem, optimize_with_dummy_method
44
5+ using Random
56using Printf
67using LinearAlgebra
78
@@ -17,7 +18,7 @@ using ..RandomObjects: random_matrix, random_state_vector
1718```julia
1819problem = dummy_control_problem(;
1920 N=10, n_objectives=1, n_controls=1, n_steps=50, dt=1.0, density=0.5,
20- complex_operators=true, hermitian=true, kwargs...)
21+ complex_operators=true, hermitian=true, rng, kwargs...)
2122```
2223
2324Sets up a control problem with random (sparse) Hermitian matrices.
@@ -36,7 +37,10 @@ Sets up a control problem with random (sparse) Hermitian matrices.
3637 1.0. For `density=1.0`, the Hamiltonians will be dense matrices.
3738* `complex_operators`: Whether or not the drift/control operators will be
3839 complex-valued or real-valued.
39- * `hermitian`: Whether or not all drift/control operators will be Hermitian matrices.
40+ * `hermitian`: Whether or not all drift/control operators will be Hermitian
41+ matrices.
42+ * `rng=Random.GLOBAL_RNG`: The random number generator to use. See
43+ [`random_matrix`](@ref) and [`random_state_vector`](@ref).
4044* `kwargs`: All other keyword arguments are passed on to
4145 [`ControlProblem`](@ref)
4246"""
@@ -49,6 +53,7 @@ function dummy_control_problem(;
4953 density= 0.5 ,
5054 complex_operators= true ,
5155 hermitian= true ,
56+ rng= Random. GLOBAL_RNG,
5257 kwargs...
5358)
5459
@@ -61,18 +66,18 @@ function dummy_control_problem(;
6166 controls = [discretize (pulse, tlist) for pulse in pulses]
6267
6368 hamiltonian = []
64- H_0 = random_matrix (N; density, hermitian, complex= complex_operators)
69+ H_0 = random_matrix (N; rng, density, hermitian, complex= complex_operators)
6570 push! (hamiltonian, H_0)
6671 for control ∈ controls
67- H_c = random_matrix (N; density, hermitian, complex= complex_operators)
72+ H_c = random_matrix (N; rng, density, hermitian, complex= complex_operators)
6873 push! (hamiltonian, (H_c, control))
6974 end
7075
7176 objectives = [
7277 Objective (;
73- initial_state= random_state_vector (N),
78+ initial_state= random_state_vector (N; rng ),
7479 generator= tuple (hamiltonian... ),
75- target_state= random_state_vector (N)
80+ target_state= random_state_vector (N; rng )
7681 ) for k = 1 : n_objectives
7782 ]
7883
0 commit comments