diff --git a/Volume_1/Book_about_Quadratization.tex b/Volume_1/Book_about_Quadratization.tex index 691d37d..0373860 100644 --- a/Volume_1/Book_about_Quadratization.tex +++ b/Volume_1/Book_about_Quadratization.tex @@ -1593,7 +1593,7 @@ \subsection{PTR-BCR-4 (Boros, Crama, and Rodr\'{i}guez-Heck, 2018)} %Suppose we have a monomial $b_1b_2b_3 \ldots b_k$. This is a more general form of the previous reduction, PTR-BCR-4, in which $k=2^{m+1}$: \begin{align} -b_1 \ldots b_k &\rightarrow \sum_{ij}b_ib_j + \sum_{ij}^m 2^{i+j}b_{a_i}b_{a_j} - \sum_i \sum_j^m 2^{j+1}b_ib_{a_i}. +b_1 \ldots b_k &\rightarrow \sum_{ij}b_ib_j + \sum_{ij}^m 2^{i+j}b_{a_i}b_{a_j} - \sum_i \sum_j^m 2^{j+1}b_ib_{a_j}. \end{align} \costsec @@ -1619,7 +1619,12 @@ \subsection{PTR-BCR-4 (Boros, Crama, and Rodr\'{i}guez-Heck, 2018)} \begin{eqnarray} %b_1 b_2 b_3 b_4 = \min_{b_{a_1}, b_{a_2}} \frac{1}{2} b_1 b_2 b_3 b_4 \rightarrow -\left( b_1 + b_2 + b_3 + b_4 - 2b_a \right)^2 +\left( b_1 + b_2 + b_3 + b_4 - b_{a_1} - 2b_{a_2} \right)^2 +\end{eqnarray} + +\begin{eqnarray} +b_1 b_2 b_3 b_4 \rightarrow +\sum_{i=1}^{4}\sum_{j=1}^{4}b_ib_j + \sum_{i=0}^{1}\sum_{j=0}^{1} 2^{i+j}b_{a_i}b_{a_j} - \sum_{i=1}^{4}\sum_{j=0}^{1} 2^{j+1}b_ib_{a_j} \end{eqnarray} \altformsec diff --git a/everything_else/reproducing.m b/everything_else/reproducing.m index 8b03efc..ea0997b 100644 --- a/everything_else/reproducing.m +++ b/everything_else/reproducing.m @@ -157,6 +157,86 @@ %% Pg. 21, PTR-BCR-2 %% Pg. 22, PTR-BCR-3 (example appears to be the same as PTR-BCR-1, and may have to be redone) %% Pg. 23, PTR-BCR-4 + +% Equation 1 in Example section of PTR-BCR-4 +b = dec2bin(2^6-1:-1:0)-'0'; +b1=b(:,1);b2=b(:,2);b3=b(:,3);b4=b(:,4);ba1=b(:,5);ba2=b(:,6); +LHS = min(reshape(b1.*b2.*b3.*b4, 4, [])); +RHS = min(reshape((b1 + b2 + b3 + b4 - ba1 - 2*ba2).^2, 4, [])); +isequal(LHS,RHS); % Gives 1, confirmed by Nike on 6 April. + +% Equation 2 in Example section of PTR-BCR-4 +b = dec2bin(2^6-1:-1:0)-'0'; +b1=b(:,1);b2=b(:,2);b3=b(:,3);b4=b(:,4);ba1=b(:,5);ba2=b(:,6); +LHS = min(reshape(b1.*b2.*b3.*b4, 4, [])); +RHS = min(reshape(b1.*b1 + b1.*b2 + b1.*b3 + b1.*b4 + b2.*b1 + b2.*b2 + b2.*b3 + b2.*b4 + b3.*b1 + b3.*b2 + b3.*b3 + b3.*b4 + b4.*b1 + b4.*b2 + b4.*b3 + b4.*b4 + ba1.*ba1 + 2*ba1.*ba2 + 2*ba2.*ba1 + 4*ba2.*ba2 - 2*b1.*ba1 - 2*b2.*ba1 - 2*b3.*ba1 - 2*b4.*ba1 - 4*b1.*ba2 - 4*b2.*ba2 - 4*b3.*ba2 - 4*b4.*ba2, 4, [])); +isequal(LHS, RHS); +% b = dec2bin(2^6-1:-1:0)-'0'; +% LHS = ones(2^6,1); +% for i = 1:4 +% LHS = LHS.*b(:,i); +% end +% LHS = min(reshape(LHS, 4, [])); +% RHS = zeros(2^6,1); +% for i = 1:4 +% for j = 1:4 +% RHS = RHS + b(:,i).*b(:,j); +% end +% end +% for i = 5:6 +% for j = 5:6 +% RHS = RHS + 2^(i+j-10)*b(:,i).*b(:,j); +% end +% end +% for i = 1:4 +% for j = 5:6 +% RHS = RHS - 2^(j-4)*b(:,i).*b(:,j); +% end +% end +% RHS = min(reshape(RHS, 4, [])); +% isequal(LHS, RHS); + +% k = 8, Equation in Alternative forms section of PTR-BCR-4 +b = dec2bin(2^11-1:-1:0)-'0'; +LHS = ones(2^11,1); +for i = 1:8 + LHS = LHS.*b(:,i); +end +LHS = min(reshape(LHS, 8, [])); +RHS = zeros(2^11,1); +for i=1:8 + RHS = RHS + b(:,i); +end +RHS = RHS - b(:,9) - 2*b(:,10) - 4*b(:,11); +RHS = min(reshape(RHS.^2, 8, [])); +isequal(LHS, RHS); + +% k = 8, Eq. 71 +b = dec2bin(2^11-1:-1:0)-'0'; +LHS = ones(2^11,1); +for i = 1:8 + LHS = LHS.*b(:,i); +end +LHS = min(reshape(LHS, 8, [])); +RHS = zeros(2^11,1); +for i = 1:8 + for j = 1:8 + RHS = RHS + b(:,i).*b(:,j); + end +end +for i = 9:11 + for j = 9:11 + RHS = RHS + 2^(i+j-18)*b(:,i).*b(:,j); + end +end +for i = 1:8 + for j = 9:11 + RHS = RHS - 2^(j-8)*b(:,i).*b(:,j); + end +end +RHS = min(reshape(RHS, 8, [])); +isequal(LHS, RHS); + %% Pg. 24, PTR-KZ (needs an example!) %% PTR-KZ: b1b2b3 = min_ba(1 − (ba + b1 + b2 + b3) + ba (b1 + b2 + b3) + b1b2 + b1b3 + b2b3)