optimise_weights.jl
Public functions
QuantumACES.gls_optimise_weights
— Methodgls_optimise_weights(d::Design, covariance_log::SparseMatrixCSC{Float64, Int}; options::OptimOptions = OptimOptions())
Returns versions of the design d
and circuit log-eigenvalue estimator covariance matrix covariance_log
after optimising the shot weights with respect to the generalised least squares (GLS) figure of merit, alongside the figure of merit values at each step. The optimisation is parameterised by the OptimOptions
object options
.
QuantumACES.ols_optimise_weights
— Methodols_optimise_weights(d::Design, covariance_log::SparseMatrixCSC{Float64, Int}; options::OptimOptions = OptimOptions())
Returns versions of the design d
and circuit log-eigenvalue estimator covariance matrix covariance_log
after optimising the shot weights with respect to the ordinary least squares (OLS) figure of merit, alongside the figure of merit values at each step. The optimisation is parameterised by the OptimOptions
object options
.
QuantumACES.optimise_weights
— Methodoptimise_weights(d::Design, covariance_log::SparseMatrixCSC{Float64, Int}; options::OptimOptions = OptimOptions())
Returns versions of the design d
and circuit log-eigenvalue estimator covariance matrix covariance_log
after optimising the shot weights with respect to the figure of merit, alongside the figure of merit values at each step. The optimisation is parameterised by the OptimOptions
object options
, which in particular specifies the least squares estimator type for which the figure of merit is calculated.
QuantumACES.wls_optimise_weights
— Methodwls_optimise_weights(d::Design, covariance_log::SparseMatrixCSC{Float64, Int}; options::OptimOptions = OptimOptions())
Returns versions of the design d
and circuit log-eigenvalue estimator covariance matrix covariance_log
after optimising the shot weights with respect to the weighted least squares (WLS) figure of merit, alongside the figure of merit values at each step. The optimisation is parameterised by the OptimOptions
object options
.
Private functions
QuantumACES.calc_gls_merit_grad_log
— Methodcalc_gls_merit_grad_log(d::Design, shot_weights::Vector{Float64}, covariance_log_unweighted_inv::SparseMatrixCSC{Float64, Int}, gate_transform_matrix::SparseMatrixCSC{Float64, Int})
Returns the gradient of the generalised least squares (GLS) figure of merit for the design d
with respect to the logarithms of the shot weights shot_weights
, using the inverse of the unweighted (by the shot weights factor) covariance matrix of the circuit log-eigenvalue estimator covariance_log_unweighted_inv
, with the estimator type implicitly specified by the gate eigenvalue transform matrix gate_transform_matrix
.
QuantumACES.calc_ols_merit_grad_log
— Methodcalc_ols_merit_grad_log(d::Design, shot_weights::Vector{Float64}, ols_estimator::Matrix{Float64}, ols_estimator_covariance::Matrix{Float64}, ols_gram_covariance::Matrix{Float64})
Returns the gradient of the ordinary least squares (OLS) figure of merit for the design d
with respect to the logarithms of the shot weights shot_weights
, using the OLS estimator matrix ols_estimator
, scaled by the unweighted covariance matrix in ols_estimator_covariance
, and the OLS Gram matrix also scaled by the unweighted covariance matrix in ols_gram_covariance
.
QuantumACES.calc_wls_merit_grad_log
— Methodcalc_wls_merit_grad_log(d::Design, shot_weights::Vector{Float64}, covariance_log_unweighted::SparseMatrixCSC{Float64, Int}, gate_transform_matrix::SparseMatrixCSC{Float64, Int})
Returns the gradient of the weighted least squares (WLS) figure of merit for the design d
with respect to the logarithms of the shot weights shot_weights
, using the unweighted (by the shot weights factor) covariance matrix of the circuit log-eigenvalue estimator covariance_log_unweighted
, with the estimator type implicitly specified by the gate eigenvalue transform matrix gate_transform_matrix
.
QuantumACES.get_merit_grad
— Methodget_merit_grad(sigma_tr::Float64, sigma_tr_grad::Vector{Float64}, sigma_sq_tr::Float64, sigma_sq_tr_grad::Vector{Float64}, N::Integer)
Returns the gradient of the figure of merit with respect to the shot weights given the trace of the gate eigenvalue estimator covariance matrix sigma_tr
and its square sigma_sq_tr
, the gradient with respect to the shot weights sigma_tr_grad
and the gradient of the square sigma_sq_tr_grad
, and the number of gate eigenvalues N
.
QuantumACES.get_shot_weights_factor
— Methodget_shot_weights_factor(shot_weights::Vector{Float64}, tuple_times::Vector{Float64}, mapping_lengths::Vector{Int})
Returns the shot weights factor for the sparse block diagonal circuit (log-)eigenvalue estimator covariance matrix for the shot weights shot_weights
and tuple times tuple_times
, where the block sizes are specified by mapping_lengths
.
QuantumACES.get_shot_weights_factor_inv
— Methodget_shot_weights_factor_inv(shot_weights::Vector{Float64}, tuple_times::Vector{Float64}, mapping_lengths::Vector{Int})
Returns the shot weights inverse factor for the sparse block diagonal circuit (log-)eigenvalue estimator covariance matrix for the shot weights shot_weights
and tuple times tuple_times
, where the block sizes are specified by mapping_lengths
.
QuantumACES.get_shot_weights_local_grad
— Methodget_shot_weights_local_grad(shot_weights::Vector{Float64}, tuple_times::Vector{Float64})
Returns the local gradient factor corresponding to each tuple's block in the covariance matrix, at shot weights shot_weights
and tuple times tuple_times
.
QuantumACES.get_shot_weights_log_matrix
— Methodget_shot_weights_log_matrix(shot_weights::Vector{Float64})
Returns the matrix that transforms the gradient of the figure of merit with respect to the shot weights shot_weights
into the gradient of the figure of merit with respect to the logarithms of the shot weights.