Skip to content

Commit

Permalink
conjugate cons cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsha Nagarajan committed Dec 3, 2024
1 parent 17f9d79 commit 9e24ca2
Show file tree
Hide file tree
Showing 73 changed files with 45 additions and 23 deletions.
Empty file modified .codecov.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/CompatHelper.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/TagBot.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/ci.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/documentation.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified CHANGELOG.md
100644 → 100755
Empty file.
Empty file modified CITATION.bib
100644 → 100755
Empty file.
Empty file modified LICENSE.md
100644 → 100755
Empty file.
Empty file modified Project.toml
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified docs/.gitignore
100644 → 100755
Empty file.
Empty file modified docs/Project.toml
100644 → 100755
Empty file.
Empty file modified docs/README.md
100644 → 100755
Empty file.
Empty file modified docs/make.jl
100644 → 100755
Empty file.
Empty file modified docs/src/1_qubit_gates.md
100644 → 100755
Empty file.
Empty file modified docs/src/2_qubit_gates.md
100644 → 100755
Empty file.
Empty file modified docs/src/3_qubit_gates.md
100644 → 100755
Empty file.
Empty file modified docs/src/assets/QCOpt_framework.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/assets/QCOpt_framework_dark.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/assets/docs_header.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/assets/docs_header_dark.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/assets/extra_styles.css
100644 → 100755
Empty file.
Empty file modified docs/src/assets/logo-dark.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/assets/logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/assets/logo_header_dark.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/assets/logo_header_light.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/assets/themes/dark.scss
100644 → 100755
Empty file.
Empty file modified docs/src/assets/themes/darkdefs.scss
100644 → 100755
Empty file.
Empty file modified docs/src/assets/themes/documenter-dark.css
100644 → 100755
Empty file.
Empty file modified docs/src/assets/themes/documenter-light.css
100644 → 100755
Empty file.
Empty file modified docs/src/assets/themes/light.scss
100644 → 100755
Empty file.
Empty file modified docs/src/assets/themes/lightdefs.scss
100644 → 100755
Empty file.
Empty file modified docs/src/assets/themes/style.scss
100644 → 100755
Empty file.
Empty file modified docs/src/assets/video_img_1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/assets/video_img_2.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/src/function_references.md
100644 → 100755
Empty file.
Empty file modified docs/src/index.md
100644 → 100755
Empty file.
Empty file modified docs/src/multi_qubit_gates.md
100644 → 100755
Empty file.
Empty file modified docs/src/quickguide.md
100644 → 100755
Empty file.
Empty file modified examples/2qubit_gates.jl
100644 → 100755
Empty file.
Empty file modified examples/3qubit_gates.jl
100644 → 100755
Empty file.
Empty file modified examples/4qubit_gates.jl
100644 → 100755
Empty file.
Empty file modified examples/5qubit_gates.jl
100644 → 100755
Empty file.
Empty file modified examples/Project.toml
100644 → 100755
Empty file.
Empty file modified examples/README.md
100644 → 100755
Empty file.
Empty file modified examples/decompose_all_gates.jl
100644 → 100755
Empty file.
Empty file modified examples/gates_sc21.jl
100644 → 100755
Empty file.
Empty file modified examples/optimizers.jl
100644 → 100755
Empty file.
Empty file modified examples/parametrized_gates.jl
100644 → 100755
Empty file.
Empty file modified examples/results_sc21.jl
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions examples/run_examples.jl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ using LinearAlgebra

using JuMP
using Gurobi
# using CPLEX
using CPLEX
# using HiGHS

include("optimizers.jl")
[include("$(i)qubit_gates.jl") for i in 2:5]
include("parametrized_gates.jl")
include("decompose_all_gates.jl")

# decompose_gates = ["iSwap"]
decompose_gates = ["magic"]

#----------------------------------------------#
# Quantum Circuit Optimization model #
#----------------------------------------------#
qcopt_optimizer = get_gurobi(solver_log = true)
qcopt_optimizer = get_cplex(solver_log = true)

result = Dict{String,Any}()
times = zeros(length(decompose_gates), 1)
Expand Down
Empty file modified src/QuantumCircuitOpt.jl
100644 → 100755
Empty file.
Empty file modified src/chull.jl
100644 → 100755
Empty file.
15 changes: 10 additions & 5 deletions src/constraints.jl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -560,31 +560,36 @@ function constraint_unitary_property(qcm::QuantumCircuitModel)
return
end

function constraint_unitary_complex_conjugate(qcm::QuantumCircuitModel)
function constraint_unitary_complex_conjugate(qcm::QuantumCircuitModel;
quadratic_constraint = true,
num_gates_bnd = 50)

max_depth = qcm.data["maximum_depth"]
z_bin_var = qcm.variables[:z_bin_var]
U_var = qcm.variables[:U_var]
gates_real = qcm.data["gates_real"]

num_gates = size(gates_real)[3]

if max_depth >= 3
if max_depth >= 2
JuMP.@constraint(qcm.model, U_var[:, :, (max_depth-1)] .==
qcm.data["target_gate"] *
sum(z_bin_var[i, (max_depth)] *
(gates_real[:,:,i]') for i=1:num_gates)
)
end

if max_depth >= 4
# Quadratic constraint
# Quadratic constraint
if (max_depth >= 3) && (num_gates <= num_gates_bnd) && (quadratic_constraint)
Memento.info(_LOGGER, "Applying quadratic unitary complex-congugate constraints")

JuMP.@constraint(qcm.model, U_var[:, :, (max_depth-2)] .==
qcm.data["target_gate"] *
sum(z_bin_var[i, (max_depth)] *
(gates_real[:,:,i]') for i=1:num_gates) *
sum(z_bin_var[i, (max_depth-1)] *
(gates_real[:,:,i]') for i=1:num_gates)
)
)

end

Expand Down
Empty file modified src/data.jl
100644 → 100755
Empty file.
Empty file modified src/gates.jl
100644 → 100755
Empty file.
Empty file modified src/log.jl
100644 → 100755
Empty file.
Empty file modified src/objective.jl
100644 → 100755
Empty file.
Empty file modified src/qc_model.jl
100644 → 100755
Empty file.
Empty file modified src/relaxations.jl
100644 → 100755
Empty file.
Empty file modified src/solution.jl
100644 → 100755
Empty file.
Empty file modified src/types.jl
100644 → 100755
Empty file.
Empty file modified src/utility.jl
100644 → 100755
Empty file.
47 changes: 32 additions & 15 deletions src/variables.jl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,45 @@ function variable_gate_products_linearization(qcm::QuantumCircuitModel)
return
end

# function variable_slack_for_feasibility(qcm::QuantumCircuitModel)
# n_r = size(qcm.data["gates_real"])[1]
# n_c = size(qcm.data["gates_real"])[2]
# max_depth = qcm.data["maximum_depth"]
# U_var = qcm.variables[:U_var]

# qcm.variables[:slack_var] = JuMP.@variable(qcm.model, slack_var[1:n_r, 1:n_c])

# for i=1:n_r, j=1:n_c
# lb = JuMP.lower_bound(U_var[i,j,max_depth-1])
# ub = JuMP.upper_bound(U_var[i,j,max_depth-1])
# if QCO.is_zero(lb) && QCO.is_zero(ub)
# JuMP.set_lower_bound(slack_var[i,j], 0)
# JuMP.set_upper_bound(slack_var[i,j], 0)
# else
# JuMP.set_lower_bound(slack_var[i,j], -1)
# JuMP.set_upper_bound(slack_var[i,j], 1)
# end
# end
# return
# end

function variable_slack_for_feasibility(qcm::QuantumCircuitModel)
n_r = size(qcm.data["gates_real"])[1]
n_c = size(qcm.data["gates_real"])[2]
max_depth = qcm.data["maximum_depth"]
n_r, n_c = size(qcm.data["gates_real"])[1:2]
max_depth = qcm.data["maximum_depth"]
U_var = qcm.variables[:U_var]

qcm.variables[:slack_var] = JuMP.@variable(qcm.model, slack_var[1:n_r, 1:n_c])

for i=1:n_r, j=1:n_c
lb = JuMP.lower_bound(U_var[i,j,max_depth-1])
ub = JuMP.upper_bound(U_var[i,j,max_depth-1])
if QCO.is_zero(lb) && QCO.is_zero(ub)
JuMP.set_lower_bound(slack_var[i,j], 0)
JuMP.set_upper_bound(slack_var[i,j], 0)
else
JuMP.set_lower_bound(slack_var[i,j], -1)
JuMP.set_upper_bound(slack_var[i,j], 1)
end
# Set bounds for slack variables
for i in 1:n_r, j in 1:n_c
lb, ub = JuMP.lower_bound(U_var[i, j, max_depth - 1]), JuMP.upper_bound(U_var[i, j, max_depth - 1])
bounds = (QCO.is_zero(lb) && QCO.is_zero(ub)) ? (0, 0) : (-1, 1)
JuMP.set_lower_bound(slack_var[i, j], bounds[1])
JuMP.set_upper_bound(slack_var[i, j], bounds[2])
end
return
end


function variable_slack_var_outer_approximation(qcm::QuantumCircuitModel)
n_r = size(qcm.data["gates_real"])[1]
n_c = size(qcm.data["gates_real"])[2]
Expand Down
Empty file modified test/chull_tests.jl
100644 → 100755
Empty file.
Empty file modified test/data_tests.jl
100644 → 100755
Empty file.
Empty file modified test/gates_tests.jl
100644 → 100755
Empty file.
Empty file modified test/qc_model_tests.jl
100644 → 100755
Empty file.
Empty file modified test/relaxations_tests.jl
100644 → 100755
Empty file.
Empty file modified test/runtests.jl
100644 → 100755
Empty file.
Empty file modified test/types_tests.jl
100644 → 100755
Empty file.
Empty file modified test/utility_tests.jl
100644 → 100755
Empty file.

0 comments on commit 9e24ca2

Please sign in to comment.