Skip to content

Commit cfaccfe

Browse files
committed
Make dummy_control_problem reproducible
1 parent b2fed48 commit cfaccfe

4 files changed

Lines changed: 40 additions & 16 deletions

File tree

docs/make.jl

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,26 @@ DocMeta.setdocmeta!(
88
recursive=true
99
)
1010

11+
PROJECT_TOML = Pkg.TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))
12+
VERSION = PROJECT_TOML["version"]
13+
NAME = PROJECT_TOML["name"]
14+
AUTHORS = join(PROJECT_TOML["authors"], ", ") * " and contributors"
15+
GITHUB = "https://github.com/JuliaQuantumControl/QuantumControlTestUtils.jl"
16+
17+
println("Starting makedocs")
18+
1119
makedocs(;
12-
modules=[QuantumControlTestUtils],
13-
authors="Michael Goerz <mail@michaelgoerz.net",
14-
repo="https://github.com/JuliaQuantumControl/QuantumControlTestUtils.jl/blob/{commit}{path}#{line}",
20+
authors=AUTHORS,
1521
sitename="QuantumControlTestUtils.jl",
1622
format=Documenter.HTML(;
17-
prettyurls=get(ENV, "CI", "false") == "true",
23+
prettyurls=true,
1824
canonical="https://JuliaQuantumControl.github.io/QuantumControlTestUtils.jl",
19-
edit_link="master",
20-
assets=String[]
25+
assets=String[],
26+
footer="[$NAME.jl]($GITHUB) v$VERSION docs powered by [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl)."
2127
),
2228
pages=["Home" => "index.md",]
2329
)
2430

25-
deploydocs(;
26-
repo="github.com/JuliaQuantumControl/QuantumControlTestUtils.jl",
27-
devbranch="master"
28-
)
31+
println("Finished makedocs")
32+
33+
deploydocs(; repo="github.com/JuliaQuantumControl/QuantumControlTestUtils.jl")

docs/src/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ CurrentModule = QuantumControlTestUtils
44

55
# QuantumControlTestUtils
66

7+
```@eval
8+
using Markdown
9+
using Pkg
10+
11+
VERSION = Pkg.dependencies()[Base.UUID("d3fd27c9-1dfb-4e67-b0c0-90d0d87a1e48")].version
12+
13+
github_badge = "[![Github](https://img.shields.io/badge/JuliaQuantumControl-QuantumControlTestUtils.jl-blue.svg?logo=github)](https://github.com/JuliaQuantumControl/QuantumControlTestUtils.jl)"
14+
15+
version_badge = "![v$VERSION](https://img.shields.io/badge/version-v$VERSION-green.svg)"
16+
17+
Markdown.parse("$github_badge $version_badge")
18+
```
19+
720
The [QuantumControlTestUtils](https://github.com/JuliaQuantumControl/QuantumControlTestUtils.jl) package collects methods that are used for testing and benchmarking within the [JuliaQuantumControl](https://github.com/JuliaQuantumControl) organization
821

922
## Exported Functions

src/dummy_problem.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module DummyOptimization
22

33
export dummy_control_problem, optimize_with_dummy_method
44

5+
using Random
56
using Printf
67
using LinearAlgebra
78

@@ -17,7 +18,7 @@ using ..RandomObjects: random_matrix, random_state_vector
1718
```julia
1819
problem = 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
2324
Sets 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

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
99
Krotov = "b05dcdc7-62f6-4360-bf2c-0898bba419de"
1010
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
1111
LocalCoverage = "5f6e1e16-694c-5876-87ef-16b5274f298e"
12+
QuantumCitations = "259add83-af3e-4603-9706-50e341d5574e"
1213
QuantumControl = "8a270532-f23f-47a8-83a9-b33d10cad486"
1314
QuantumControlBase = "f10a33bc-5a64-497c-be7b-6f86b4f0c2aa"
1415
QuantumControlTestUtils = "d3fd27c9-1dfb-4e67-b0c0-90d0d87a1e48"

0 commit comments

Comments
 (0)