From 0c83cee10d079f5e1cd926bcf1e89b9afda7d7c3 Mon Sep 17 00:00:00 2001 From: AnhMai-bit <71567193+AnhMai-bit@users.noreply.github.com> Date: Sun, 24 Apr 2022 14:52:36 -0400 Subject: [PATCH 1/7] Decomposition - symmetric and anti-symmetric Decompose a quadratic equation into symmetric, antisymmetric parts using its transpose. --- everything_else/reproducing.m | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/everything_else/reproducing.m b/everything_else/reproducing.m index 8b03efc..7e6b415 100644 --- a/everything_else/reproducing.m +++ b/everything_else/reproducing.m @@ -349,6 +349,34 @@ %% Pg. 55, SCM-BCR %% Pg. 56, Decomposition into symmetric and anti-symmetric parts +% Anh Mai - Attempt for Topic: "Decomposition into symmetric and anti-symmetric parts" + +% Credit: Eric Huang: reproducing.m, +% Dr: Dattani:Book_About_Quadratization, +% Kahl and Strandmark, "Generalized Roof Duality for Pseudo-Boolean Optimization,” International Conference on Computer Vision (2011). + +% Idea: Decompose a quadratic equation into symmetric and skew-symmetric parts. +% For example, A is matrix. +% Symmetric: A = Transpose(A). +% Skew-symmetric: - A = Transpose(A) + +%Setting up the coefficients using Eric Huang's setup +b = dec2bin(2^4-1:-1:0)-'0'; +b1 = b(:,1) +b2 = b(:,2) +b3 = b(:,3) +b4 = b(:,4) + +% Take quadratic function as an example (Eq. 2 from the book) +% f = f_sym + f_anti +f=b1.*b2 + b2.*b3 + b3.*b4 - 4*b1.*b2.*b3; + +% f_sym = (1/2)*(f(b) + transpose f(b)) +f_sym = (1/2)*(f + f.') + +% f_anti = (1/2)*(f(b) - transpose f(b)) +f_anti = (1/2)*(f - f.') + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% QUANTUM GADGETS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From ffe08617aab89af4c54f226fa37d599c11d33ea5 Mon Sep 17 00:00:00 2001 From: AnhMai-bit <71567193+AnhMai-bit@users.noreply.github.com> Date: Sun, 24 Apr 2022 15:27:06 -0400 Subject: [PATCH 2/7] Update - Decomposition Removed comments, all coefficients defined in one line. --- everything_else/reproducing.m | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/everything_else/reproducing.m b/everything_else/reproducing.m index 7e6b415..6208a78 100644 --- a/everything_else/reproducing.m +++ b/everything_else/reproducing.m @@ -349,32 +349,12 @@ %% Pg. 55, SCM-BCR %% Pg. 56, Decomposition into symmetric and anti-symmetric parts -% Anh Mai - Attempt for Topic: "Decomposition into symmetric and anti-symmetric parts" - -% Credit: Eric Huang: reproducing.m, -% Dr: Dattani:Book_About_Quadratization, -% Kahl and Strandmark, "Generalized Roof Duality for Pseudo-Boolean Optimization,” International Conference on Computer Vision (2011). - -% Idea: Decompose a quadratic equation into symmetric and skew-symmetric parts. -% For example, A is matrix. -% Symmetric: A = Transpose(A). -% Skew-symmetric: - A = Transpose(A) - -%Setting up the coefficients using Eric Huang's setup b = dec2bin(2^4-1:-1:0)-'0'; -b1 = b(:,1) -b2 = b(:,2) -b3 = b(:,3) -b4 = b(:,4) +b1 = b(:,1); b2 = b(:,2); b3 = b(:,3); b4 = b(:,4) -% Take quadratic function as an example (Eq. 2 from the book) -% f = f_sym + f_anti f=b1.*b2 + b2.*b3 + b3.*b4 - 4*b1.*b2.*b3; -% f_sym = (1/2)*(f(b) + transpose f(b)) f_sym = (1/2)*(f + f.') - -% f_anti = (1/2)*(f(b) - transpose f(b)) f_anti = (1/2)*(f - f.') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 571cb0faa44d0045d5919e4b98e01c6b3300cbe7 Mon Sep 17 00:00:00 2001 From: AnhMai-bit <71567193+AnhMai-bit@users.noreply.github.com> Date: Sun, 24 Apr 2022 15:29:05 -0400 Subject: [PATCH 3/7] Update reproducing.m --- everything_else/reproducing.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/everything_else/reproducing.m b/everything_else/reproducing.m index 6208a78..df143f6 100644 --- a/everything_else/reproducing.m +++ b/everything_else/reproducing.m @@ -350,12 +350,12 @@ %% Pg. 56, Decomposition into symmetric and anti-symmetric parts b = dec2bin(2^4-1:-1:0)-'0'; -b1 = b(:,1); b2 = b(:,2); b3 = b(:,3); b4 = b(:,4) +b1 = b(:,1); b2 = b(:,2); b3 = b(:,3); b4 = b(:,4); f=b1.*b2 + b2.*b3 + b3.*b4 - 4*b1.*b2.*b3; -f_sym = (1/2)*(f + f.') -f_anti = (1/2)*(f - f.') +f_sym = (1/2)*(f + f.'); +f_anti = (1/2)*(f - f.'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% QUANTUM GADGETS From dd25ba832dc50a6c89eac0043fb24e77cb7f1874 Mon Sep 17 00:00:00 2001 From: AnhMai-bit <71567193+AnhMai-bit@users.noreply.github.com> Date: Wed, 27 Apr 2022 13:43:48 -0400 Subject: [PATCH 4/7] Update - Apr 27 - Symm Decomp Updated new function, coefficients and calculation for symmetry and antisymmetry --- everything_else/reproducing.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/everything_else/reproducing.m b/everything_else/reproducing.m index df143f6..d9cee0b 100644 --- a/everything_else/reproducing.m +++ b/everything_else/reproducing.m @@ -352,10 +352,10 @@ b = dec2bin(2^4-1:-1:0)-'0'; b1 = b(:,1); b2 = b(:,2); b3 = b(:,3); b4 = b(:,4); -f=b1.*b2 + b2.*b3 + b3.*b4 - 4*b1.*b2.*b3; +f = b1 + 2*b1.*b2 - 4*b1.*b2.*b3 + 2*b1.*b2.*b3.*b4; -f_sym = (1/2)*(f + f.'); -f_anti = (1/2)*(f - f.'); +f_sym = (1/2)*(f + (1 - f)); +f_anti = (1/2)*(f - (1 - f)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% QUANTUM GADGETS From 94437b0daa70fde11dfb601be5366e89cacb15df Mon Sep 17 00:00:00 2001 From: AnhMai-bit <71567193+AnhMai-bit@users.noreply.github.com> Date: Fri, 29 Apr 2022 12:01:48 -0400 Subject: [PATCH 5/7] Update - Decomp - Include checks for accuracy --- everything_else/reproducing.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/everything_else/reproducing.m b/everything_else/reproducing.m index d9cee0b..33221f2 100644 --- a/everything_else/reproducing.m +++ b/everything_else/reproducing.m @@ -353,10 +353,15 @@ b1 = b(:,1); b2 = b(:,2); b3 = b(:,3); b4 = b(:,4); f = b1 + 2*b1.*b2 - 4*b1.*b2.*b3 + 2*b1.*b2.*b3.*b4; - f_sym = (1/2)*(f + (1 - f)); f_anti = (1/2)*(f - (1 - f)); +f_new = f_sym + f_anti; + +LHS=min(reshape(f_new,[])); +RHS=min(reshape(f,[])); +isequal(LHS,RHS); + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% QUANTUM GADGETS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 87d93fcecab1b58d2dce052b59104489eace870c Mon Sep 17 00:00:00 2001 From: AnhMai-bit <71567193+AnhMai-bit@users.noreply.github.com> Date: Fri, 29 Apr 2022 17:21:45 -0400 Subject: [PATCH 6/7] Update - Decomp - Reshape Corrected reshape functions. --- everything_else/reproducing.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/everything_else/reproducing.m b/everything_else/reproducing.m index 33221f2..383eef1 100644 --- a/everything_else/reproducing.m +++ b/everything_else/reproducing.m @@ -353,13 +353,14 @@ b1 = b(:,1); b2 = b(:,2); b3 = b(:,3); b4 = b(:,4); f = b1 + 2*b1.*b2 - 4*b1.*b2.*b3 + 2*b1.*b2.*b3.*b4; + f_sym = (1/2)*(f + (1 - f)); f_anti = (1/2)*(f - (1 - f)); f_new = f_sym + f_anti; -LHS=min(reshape(f_new,[])); -RHS=min(reshape(f,[])); +LHS=min(reshape(f_new,[],4)); +RHS=min(reshape(f,[],4)); isequal(LHS,RHS); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From adb37005d5ab3b8a7fcb2eeaaf7b2fcc3efed390 Mon Sep 17 00:00:00 2001 From: AnhMai-bit <71567193+AnhMai-bit@users.noreply.github.com> Date: Wed, 4 May 2022 23:42:12 -0400 Subject: [PATCH 7/7] Decom - Update - May 4 Updated decomposition method, used NTR - KZFD and SFR-BCR-1. --- everything_else/reproducing.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/everything_else/reproducing.m b/everything_else/reproducing.m index 383eef1..8088a99 100644 --- a/everything_else/reproducing.m +++ b/everything_else/reproducing.m @@ -349,19 +349,19 @@ %% Pg. 55, SCM-BCR %% Pg. 56, Decomposition into symmetric and anti-symmetric parts -b = dec2bin(2^4-1:-1:0)-'0'; -b1 = b(:,1); b2 = b(:,2); b3 = b(:,3); b4 = b(:,4); +b = dec2bin(2^8-1:-1:0)-'0'; +b1 = b(:,1); b2 = b(:,2); b3 = b(:,3); b4 = b(:,4); ba = b(:,5); ba1 = b(:,6); ba2 = b(:,7); ba3 = b(:,8); f = b1 + 2*b1.*b2 - 4*b1.*b2.*b3 + 2*b1.*b2.*b3.*b4; -f_sym = (1/2)*(f + (1 - f)); -f_anti = (1/2)*(f - (1 - f)); +f_new_symm = 2*(-5 + b1 + b2 + b3 + b4 - ba1 - 2*ba2 + 5*ba3).^2; +f_new_anti = b1 + 2*b1.*b2 + 4*(2 - b1 - b2 - b3).*ba; -f_new = f_sym + f_anti; +f_new = f_new_anti + f_new_symm; -LHS=min(reshape(f_new,[],4)); -RHS=min(reshape(f,[],4)); -isequal(LHS,RHS); +LHS=min(reshape(f_new,16,[])) +RHS=min(reshape(f,16,[])) +isequal(LHS,RHS) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% QUANTUM GADGETS