Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
*.jl.*.cov
*.jl.cov
*.jl.mem
/Manifest.toml
/**/Manifest.*
/deps/build.log
/docs/build/
.vscode/


*.log
*.log
.vscode/
48 changes: 4 additions & 44 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,54 +1,14 @@
name = "QuanEstimation"
uuid = "088c8dff-a786-4a66-974c-03d3f6773f87"
authors = ["Jing Liu <liujingphys@hust.edu.cn>", "Huaiming Yu <Huaimingyuuu@gmail.com>", "Mao Zhang <zhangmao2018@hust.edu.cn>"]
version = "0.1.6"
version = "0.2.0"

[deps]
BoundaryValueDiffEq = "764a87c0-6b3e-53db-9096-fe964310641d"
Convex = "f65535da-76fb-5f13-bab9-19810c17039a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Trapz = "592b5752-818d-11e9-1e9a-2b8ca4a44cd1"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[weakdeps]
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
NVMagnetometer = "28fc4bcf-da03-4841-bbdb-88baaf311b30"
QuanEstimationBase = "9769ca81-ed10-4016-bab9-e66dc61d4d60"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"

[extensions]
QuanEstimationPyExt = "PythonCall"

[compat]
BoundaryValueDiffEq = "2,5"
Convex = "0.15"
DelimitedFiles = "1"
Distributions = "0.25"
Flux = "0.12, 0.13, 0.14"
Interpolations = "0.13, 0.14, 0.15"
IntervalSets = "0.5, 0.7"
JLD2 = "0.4"
OrdinaryDiffEq = "6"
QuadGK = "2"
Revise = "3"
SCS = "1, 2"
StableRNGs = "1"
StatsBase = "0.33, 0.34"
Trapz = "2"
Zygote = "0.6"
julia = "1.10"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
97 changes: 0 additions & 97 deletions docs/Manifest.toml

This file was deleted.

2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
DocumenterMarkdown = "997ab1e6-3595-5248-9280-8efb232c3433"
QuanEstimation = "088c8dff-a786-4a66-974c-03d3f6773f87"
50 changes: 13 additions & 37 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,51 +1,27 @@
using QuanEstimation
using Documenter
using DocumenterMarkdown
import Documenter.Writers.MarkdownWriter: render, renderdoc
using DocumenterCitations

DocMeta.setdocmeta!(
QuanEstimation,
:DocTestSetup,
:(using QuanEstimation);
recursive = true,
)

# function render(io::IO, mime::MIME"text/plain", anchor::Documenter.Anchors.Anchor, page, doc)
# println(io, "\n", lstrip(Documenter.Anchors.fragment(anchor), '#', " "))
# if anchor.nth == 1 # add legacy id
# legacy = lstrip(Documenter.Anchors.fragment(anchor), '#', " ") * "-1"
# println(io, "\n", legacy)
# end
# render(io, mime, anchor.object, page, doc)
# end
bib = CitationBibliography("src/refs.bib")

function render(io::IO, mime::MIME"text/plain", node::Documenter.Documents.DocsNode, page, doc)
# Docstring header based on the name of the binding and it's category.
anchor = "## "
header = "**`$(node.object.binding)`** &mdash; *$(Documenter.Utilities.doccat(node.object))*."
println(io, anchor, " ", header, "\n\n")
# Body. May contain several concatenated docstrings.
renderdoc(io, mime, node.docstr, page, doc)
end

makedocs(;
format = Markdown(),
makedocs(bib;
root = ".",
source = "docs/src",
build = "docs/build",
source = "src",
build = "build",
clean = true,
doctest = true,
modules = [QuanEstimation],
authors = "Hauiming Yu <Huaimingyuuu@gmail.com> and contributors",
repo = "https://github.com/QuanEstimation/QuanEstimation.jl/blob/{commit}{path}#{line}",
sitename = "QuanEstimation.jl",
# format = Documenter.HTML(;
# prettyurls = get(ENV, "CI", "false") == "true",
# canonical = "https://HuaimingYuuu.github.io/QuanEstimation.jl",
# assets = String[],
# ),
# pages = [api.md"],

pages = [
"API" => [
"api/GeneralAPI.md",
"api/BaseAPI.md",
"api/NVMagnetometerAPI.md"
]
]
)

deploydocs(; repo = "github.com/QuanEstimation/QuanEstimation.jl")
#deploydocs(; repo = "github.com/QuanEstimation/QuanEstimation.jl")
9 changes: 9 additions & 0 deletions docs/src/api/BaseAPI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Base

```@meta
CurrentModule = QuanEstimationBase
```

```@autodocs
Modules = [QuanEstimationBase]
```
2 changes: 2 additions & 0 deletions docs/src/api.md → docs/src/api/GeneralAPI.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# General

```@meta
CurrentModule = QuanEstimation
```
Expand Down
9 changes: 9 additions & 0 deletions docs/src/api/NVMagnetometerAPI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# NVMagnetometer

```@meta
CurrentModule = NVMagnetometer
```

```@autodocs
Modules = [NVMagnetometer]
```
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# QuanEstimation.jl
File renamed without changes.
6 changes: 3 additions & 3 deletions examples/Bayesian_CramerRao_bounds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ rho0 = 0.5*ones(2, 2)
# prior distribution
x = range(-0.5*pi, stop=0.5*pi, length=100) |>Vector
mu, eta = 0.0, 0.2
p_tp = [p_func(x[i], mu, eta) for i in 1:length(x)]
dp_tp = [dp_func(x[i], mu, eta) for i in 1:length(x)]
p_tp = [p_func(x[i], mu, eta) for i in eachindex(x)]
dp_tp = [dp_func(x[i], mu, eta) for i in eachindex(x)]
# normalization of the distribution
c = trapz(x, p_tp)
p = p_tp/c
Expand All @@ -37,7 +37,7 @@ tspan = range(0., stop=1., length=1000)
# dynamics
rho = Vector{Matrix{ComplexF64}}(undef, length(x))
drho = Vector{Vector{Matrix{ComplexF64}}}(undef, length(x))
for i = 1:length(x)
for i in eachindex(x)
H0_tp = H0_func(x[i])
dH_tp = dH_func(x[i])
rho_tp, drho_tp = QuanEstimation.expm(tspan, rho0, H0_tp, dH_tp)
Expand Down
4 changes: 2 additions & 2 deletions examples/Bayesian_estimation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ p = (1.0/(x[end]-x[1]))*ones(length(x))
tspan = range(0., stop=1., length=1000)
# dynamics
rho = Vector{Matrix{ComplexF64}}(undef, length(x))
for i = 1:length(x)
for i in eachindex(x)
H0_tp = H0_func(x[i])
dH_tp = dH_func(x[i])
rho_tp, drho_tp = QuanEstimation.expm(tspan, rho0, H0_tp, dH_tp)
Expand All @@ -39,7 +39,7 @@ end
Random.seed!(1234)
y = [0 for i in 1:500]
res_rand = sample(1:length(y), 125, replace=false)
for i in 1:length(res_rand)
for i in eachindex(res_rand)
y[res_rand[i]] = 1
end

Expand Down
50 changes: 0 additions & 50 deletions examples/adaptive_estimation.jl

This file was deleted.

21 changes: 11 additions & 10 deletions examples/adaptive_estimation_MZI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@ using SparseArrays
# the number of photons
N = 8
# probe state
psi = sum([sin(k*pi/(N+2))*kron(QuanEstimation.basis(N+1,k),
QuanEstimation.basis(N+1, N-k+2)) for k in 1:(N+1)]) |> sparse
psi = sum([sin(k*pi/(N+2))*kron(basis(N+1,k),
basis(N+1, N-k+2)) for k in 1:(N+1)]) |> sparse
psi = psi*sqrt(2/(2+N))
rho0 = psi*psi'
# prior distribution
x = range(-pi, pi, length=100)
p = (1.0/(x[end]-x[1]))*ones(length(x))
apt = QuanEstimation.Adapt_MZI(x, p, rho0)
apt =Adapt_MZI(x, p, rho0)

#================online strategy=========================#
QuanEstimation.online(apt, target=:sharpness, output="phi")
# online(apt; target=:sharpness, output="phi")
adapt!(apt; target=:sharpness, output="phi")

#================offline strategy=========================#
# # algorithm: DE
# alg = QuanEstimation.DE(p_num=10, ini_population=missing,
# max_episode=1000, c=1.0, cr=0.5)
# QuanEstimation.offline(apt, alg, target=:sharpness, seed=1234)
# algorithm: DE
alg = DE(p_num=10, ini_population=missing,
max_episode=1000, c=1.0, cr=0.5)
offline(apt, alg, target=:sharpness, seed=1234)

# # algorithm: PSO
# alg = QuanEstimation.PSO(p_num=10, ini_particle=missing,
# PSO(p_num=10, ini_particle=missing,
# max_episode=[1000,100], c0=1.0,
# c1=2.0, c2=2.0)
# QuanEstimation.offline(apt, alg, target=:sharpness, seed=1234)
# offline(apt, alg, target=:sharpness, seed=1234)
Loading