function Four_Round_Zoning_In_Protocol_1(input1, input2)

%% Zones in on the protocol below  
%% alpha0 = [0, 0, 0, 1/2, 1/2]'
%% alpha1 = [0, 0, 1/2, 0, 1/2]'
%% beta0 = [0, 0, 0, 0, 1]'
%% beta1 = [0, 0, 0, 1, 0]'
%%
%% The mesh precision is 1/10^i for i = input1 to input2
%%
%% Each column of Output is the result of a search 
%% (The first entry is i, and then the rest are how
%% many protocols made it past each strategy in the filter.)
%% 
%% Note: the program also outputs values of beta0 to see if progress is being made.
%%
%% Questions? Contact Jamie at jamiesikora@gmail.com

Best_Bias = 3/4;

format('long')
%pars.eps = 0;

protocol_vector = [0;0;0;0;0; 0;0;0;0;0; 0;0;0;0;0; 0;0;0;0;0; 0]';

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SDP Stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

pars.fid = 0;
K.l = 5; K.s = [5 5 5 5 5 5 5 5 5 5]; 

A1 = sparse(5,5); A1(1,1) = 1; A1 = vec(A1)';
A2 = sparse(5,5); A2(2,2) = 1; A2 = vec(A2)';
A3 = sparse(5,5); A3(3,3) = 1; A3 = vec(A3)';
A4 = sparse(5,5); A4(4,4) = 1; A4 = vec(A4)';
A5 = sparse(5,5); A5(5,5) = 1; A5 = vec(A5)';
A = [A1; A2; A3; A4; A5];

O = sparse(5,25);
OO = sparse(1,25);
I = eye(5);
e = [1 1 1 1 1];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Alice SDP Stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

AA = [ ...
 e         OO OO  OO OO  OO OO  OO OO  OO OO; ...
-I         A A  O O  O O  O O  O O; ...
-I         O O  A A  O O  O O  O O; ...
-I         O O  O O  A A  O O  O O; ...
-I         O O  O O  O O  A A  O O; ...
-I         O O  O O  O O  O O  A A ...
];

AA2 = [ ...
I          O O  O O  O O  O O  O O; ...
-I         A A  O O  O O  O O  O O; ...
-I         O O  A A  O O  O O  O O; ...
-I         O O  O O  A A  O O  O O; ...
-I         O O  O O  O O  A A  O O; ...
-I         O O  O O  O O  O O  A A ...
];

bbbbb1 = [1; zeros(25,1)];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Bob Stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

G.l = 25; G.s = [5 5]; 
b_Bob = [1;1;1;1;1; 0;0;0;0;0;0;0;0;0;0];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for prec_counter = input1:input2
prec = 1/(10^prec_counter);

Best_Bias = 3/4;

iter_protocol_count = 0; 					% ^4 to get protocol count
iter_beta0beta1_count = 0;			% ^2 to get protocol count after symmetry
iter_after_F1 = 0;
iter_after_F2 = 0;
iter_after_F3 = 0;
iter_after_F4 = 0;
iter_after_F5 = 0;
iter_after_F6 = 0;
iter_after_F7 = 0;
iter_after_F8 = 0;
iter_after_F9 = 0;
iter_after_F10 = 0;
iter_after_F11 = 0;
iter_after_F12 = 0;
iter_after_F13 = 0;
iter_after_SDPA0 = 0;
iter_after_SDPA1 = 0;
iter_after_SDPB0 = 0;
iter_after_SDPB1 = 0;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Protocol Data Generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for bb1 = 0:prec:min(2*prec,1)
for bb2 = 0:prec:min(2*prec,1-bb1);
for bb3 = 0:prec:min(2*prec,1-bb1-bb2);
for bb4 = 0:prec:min(2*prec,1-bb1-bb2-bb3);
bb5 = 1-bb1-bb2-bb3-bb4;
beta0 = [bb1; bb2; bb3; bb4; bb5]; 

beta0

for b1 = 0:prec:min(2*prec,1)
for b2 = 0:prec:min(2*prec,1-b1)
for b3 = 0:prec:min(2*prec,1-b1-b2)
for b4 = 0:prec:min(2*prec,1-b1-b2-b3)
b5 = 1-b1-b2-b3-b4;
beta1 = [b1; b2; b3; b5; b4]; % Note this is permuted (want fourth entry to be large)

iter_beta0beta1_count = iter_beta0beta1_count + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

F1 = 0.5 + 0.5 * sqrt(beta0)'*sqrt(beta1);
if F1 < Best_Bias 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for aa1 = 0:prec:min(2*prec,1)
for aa2 = 0:prec:min(2*prec,1-aa1)
for aa3 = 0:prec:min(2*prec,1-aa1-aa2)
for aa4 = 0.5-2*prec:prec:min(0.5+2*prec,1-aa1-aa2-aa3)
aa5 = 1-aa1-aa2-aa3-aa4;
alpha0 = [aa1; aa2; aa3; aa4; aa5]; 

for a1 = 0:prec:min(2*prec,1)
for a2 = 0:prec:min(2*prec,1-a1)
for a3 = 0:prec:min(2*prec,1-a1-a2)
for a4 = 0.5-2*prec:prec:min(0.5+2*prec,1-a1-a2-a3)
a5 = 1-a1-a2-a3-a4;
alpha1 = [a1; a2; a4; a3; a5]; % Note this is permuted. Want third and fifth entry large (does not affect symmetry arguments)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% 	Filter (Known cheating strategies)  %%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Apply the Filter to weed out bad protocols

iter_after_F1 = iter_after_F1 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

F2 = 0.5 + 0.25 * norm(alpha0 - alpha1,1);
if F2 < Best_Bias
iter_after_F2 = iter_after_F2 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

F3 = (0.5 + 0.5 * sqrt(alpha0)'*sqrt(alpha1)) * ...
     (0.5 + 0.25 * norm(beta0 - beta1,1));
if F3 < Best_Bias				
iter_after_F3 = iter_after_F3 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

F4 = 0.5*(sqrt(beta0)'*sqrt(alpha0))^2 ...
   + 0.5*(sqrt(beta1)'*sqrt(alpha1))^2;
if F4 < Best_Bias				
iter_after_F4 = iter_after_F4 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

F5 = 0.5*(sqrt(beta0)'*sqrt(alpha1))^2 ...
   + 0.5*(sqrt(beta1)'*sqrt(alpha0))^2;
if F5 < Best_Bias				
iter_after_F5 = iter_after_F5 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

m=0;
n=0;		  
for counter = 1:5		  
if beta1(counter) > beta0(counter)
n = n + beta1(counter); 
else m = m + beta0(counter);
end
end		  
F6 = 0.25*(m+n+sqrt((m-n)^2 +4*m*n*(sqrt(alpha0)'*sqrt(alpha1))^2));
if F6 < Best_Bias
iter_after_F6 = iter_after_F6 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

F7 = ...
0.25*(alpha0(1)+alpha1(1)+sqrt((alpha0(1)-alpha1(1))^2 +4*alpha0(1)*alpha1(1)*(sqrt(beta0)'*sqrt(beta1))^2)) + ...
0.25*(alpha0(2)+alpha1(2)+sqrt((alpha0(2)-alpha1(2))^2 +4*alpha0(2)*alpha1(2)*(sqrt(beta0)'*sqrt(beta1))^2)) + ...
0.25*(alpha0(3)+alpha1(3)+sqrt((alpha0(3)-alpha1(3))^2 +4*alpha0(3)*alpha1(3)*(sqrt(beta0)'*sqrt(beta1))^2)) + ...
0.25*(alpha0(4)+alpha1(4)+sqrt((alpha0(4)-alpha1(4))^2 +4*alpha0(4)*alpha1(4)*(sqrt(beta0)'*sqrt(beta1))^2)) + ...
0.25*(alpha0(5)+alpha1(5)+sqrt((alpha0(5)-alpha1(5))^2 +4*alpha0(5)*alpha1(5)*(sqrt(beta0)'*sqrt(beta1))^2));								
if F7 < Best_Bias
iter_after_F7 = iter_after_F7 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

me1 = 0.5*(alpha0(1)+alpha1(1)+sqrt((alpha0(1)-alpha1(1))^2 +4*alpha0(1)*alpha1(1)*(sqrt(beta0)'*sqrt(beta1))^2));
me2 = 0.5*(alpha0(2)+alpha1(2)+sqrt((alpha0(2)-alpha1(2))^2 +4*alpha0(2)*alpha1(2)*(sqrt(beta0)'*sqrt(beta1))^2));
me3 = 0.5*(alpha0(3)+alpha1(3)+sqrt((alpha0(3)-alpha1(3))^2 +4*alpha0(3)*alpha1(3)*(sqrt(beta0)'*sqrt(beta1))^2));
me4 = 0.5*(alpha0(4)+alpha1(4)+sqrt((alpha0(4)-alpha1(4))^2 +4*alpha0(4)*alpha1(4)*(sqrt(beta0)'*sqrt(beta1))^2));
me5 = 0.5*(alpha0(5)+alpha1(5)+sqrt((alpha0(5)-alpha1(5))^2 +4*alpha0(5)*alpha1(5)*(sqrt(beta0)'*sqrt(beta1))^2));

A1 = alpha0(1)*sqrt(beta0)*sqrt(beta0)' + alpha1(1)*sqrt(beta1)*sqrt(beta1)';
A2 = alpha0(2)*sqrt(beta0)*sqrt(beta0)' + alpha1(2)*sqrt(beta1)*sqrt(beta1)';
A3 = alpha0(3)*sqrt(beta0)*sqrt(beta0)' + alpha1(3)*sqrt(beta1)*sqrt(beta1)';
A4 = alpha0(4)*sqrt(beta0)*sqrt(beta0)' + alpha1(4)*sqrt(beta1)*sqrt(beta1)';
A5 = alpha0(5)*sqrt(beta0)*sqrt(beta0)' + alpha1(5)*sqrt(beta1)*sqrt(beta1)';

n = null(A1 - me1*eye(5));
S = size(n);
if S(2) > 0
  v1 = n(:,1);
  else
  [v1, e1] = eigs(A1,1);
end
v1 = abs(v1); v1 = v1/norm(v1,2); v1 = v1.*v1;

n = null(A2 - me2*eye(5));
S = size(n);
if S(2) > 0
  v2 = n(:,1);
  else
  [v2, e1] = eigs(A2,1);
end
v2 = abs(v2); v2 = v2/norm(v2,2); v2 = v2.*v2;

n = null(A3 - me3*eye(5));
S = size(n);
if S(2) > 0
  v3 = n(:,1);
  else
  [v3, e1] = eigs(A3,1);
end
v3 = abs(v3); v3 = v3/norm(v3,2); v3 = v3.*v3;

n = null(A4 - me4*eye(5));
S = size(n);
if S(2) > 0
  v4 = n(:,1);
  else
  [v4, e1] = eigs(A4,1);
end
v4 = abs(v4); v4 = v4/norm(v4,2); v4 = v4.*v4;

n = null(A5 - me5*eye(5));
S = size(n);
if S(2) > 0
  v5 = n(:,1);
  else
  [v5, e1] = eigs(A5,1);
end
v5 = abs(v5); v5 = v5/norm(v5,2); v5 = v5.*v5;

p0 = alpha0(1)*v1 + alpha0(2)*v2 + alpha0(3)*v3 + alpha0(4)*v4 + alpha0(5)*v5;               
p1 = alpha1(1)*v1 + alpha1(2)*v2 + alpha1(3)*v3 + alpha1(4)*v4 + alpha1(5)*v5;

F8 = 0.5*(sqrt(p0)'*sqrt(beta0))^2 + ...
     0.5*(sqrt(p1)'*sqrt(beta1))^2;
if F8 < Best_Bias
iter_after_F8 = iter_after_F8 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%		
		  																	   
me1 = 0.5*(alpha0(1)+alpha1(1)+sqrt((alpha0(1)-alpha1(1))^2 +4*alpha0(1)*alpha1(1)*(sqrt(beta0)'*sqrt(beta1))^2));
me2 = 0.5*(alpha0(2)+alpha1(2)+sqrt((alpha0(2)-alpha1(2))^2 +4*alpha0(2)*alpha1(2)*(sqrt(beta0)'*sqrt(beta1))^2));
me3 = 0.5*(alpha0(3)+alpha1(3)+sqrt((alpha0(3)-alpha1(3))^2 +4*alpha0(3)*alpha1(3)*(sqrt(beta0)'*sqrt(beta1))^2));
me4 = 0.5*(alpha0(4)+alpha1(4)+sqrt((alpha0(4)-alpha1(4))^2 +4*alpha0(4)*alpha1(4)*(sqrt(beta0)'*sqrt(beta1))^2));
me5 = 0.5*(alpha0(5)+alpha1(5)+sqrt((alpha0(5)-alpha1(5))^2 +4*alpha0(5)*alpha1(5)*(sqrt(beta0)'*sqrt(beta1))^2));
																					 
A1 = alpha0(1)*sqrt(beta1)*sqrt(beta1)' + alpha1(1)*sqrt(beta0)*sqrt(beta0)';
A2 = alpha0(2)*sqrt(beta1)*sqrt(beta1)' + alpha1(2)*sqrt(beta0)*sqrt(beta0)';
A3 = alpha0(3)*sqrt(beta1)*sqrt(beta1)' + alpha1(3)*sqrt(beta0)*sqrt(beta0)';
A4 = alpha0(4)*sqrt(beta1)*sqrt(beta1)' + alpha1(4)*sqrt(beta0)*sqrt(beta0)';
A5 = alpha0(5)*sqrt(beta1)*sqrt(beta1)' + alpha1(5)*sqrt(beta0)*sqrt(beta0)';
		  
		  n = null(A1 - me1*eye(5));
		  S = size(n);
		  if S(2) > 0
		  v1 = n(:,1);
		  else
		  [v1, e1] = eigs(A1,1);
		  end
		  v1 = abs(v1); v1 = v1/norm(v1,2); v1 = v1.*v1;
		  
		  n = null(A2 - me2*eye(5));
		  S = size(n);
		  if S(2) > 0
		  v2 = n(:,1);
		  else
		  [v2, e1] = eigs(A2,1);
		  end
		  v2 = abs(v2); v2 = v2/norm(v2,2); v2 = v2.*v2;
		  
		  n = null(A3 - me3*eye(5));
		  S = size(n);
		  if S(2) > 0
		  v3 = n(:,1);
		  else
		  [v3, e1] = eigs(A3,1);
		  end
		  v3 = abs(v3); v3 = v3/norm(v3,2); v3 = v3.*v3;
		  
		  n = null(A4 - me4*eye(5));
		  S = size(n);
		  if S(2) > 0
		  v4 = n(:,1);
		  else
		  [v4, e1] = eigs(A4,1);
		  end
		  v4 = abs(v4); v4 = v4/norm(v4,2); v4 = v4.*v4;
		  
		  n = null(A5 - me5*eye(5));
		  S = size(n);
		  if S(2) > 0
		  v5 = n(:,1);
		  else
		  [v5, e1] = eigs(A5,1);
		  end
		  v5 = abs(v5); v5 = v5/norm(v5,2); v5 = v5.*v5;
		  
		  p0 = alpha0(1)*v1 + alpha0(2)*v2 + alpha0(3)*v3 + alpha0(4)*v4 + alpha0(5)*v5;
		  p1 = alpha1(1)*v1 + alpha1(2)*v2 + alpha1(3)*v3 + alpha1(4)*v4 + alpha1(5)*v5;
		  
F9 = 0.5*(sqrt(p0)'*sqrt(beta1))^2 + 0.5*(sqrt(p1)'*sqrt(beta0))^2;
if F9 < Best_Bias
iter_after_F9 = iter_after_F9 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

m0 = vec(sqrt(alpha0)*sqrt(alpha0)')';
m1 = vec(sqrt(alpha1)*sqrt(alpha1)')';

c = 0.5*[ 0,0,0,0,0,...
beta0(1)*m0, beta1(1)*m1, ...
beta0(2)*m0, beta1(2)*m1, ...
beta0(3)*m0, beta1(3)*m1, ...
beta0(4)*m0, beta1(4)*m1, ...
beta0(5)*m0, beta1(5)*m1, ...
];

ATemp = sparse(5,5);
for counter = 1:5
if beta1(counter) > beta0(counter)
ATemp = ATemp + 0.5 * beta1(counter) * sqrt(alpha1)*sqrt(alpha1)';
else ATemp = ATemp + 0.5 * beta0(counter) * sqrt(alpha0)*sqrt(alpha0)';
end
end

% F6 = max(eig(ATemp))
n = null(ATemp - F6*eye(5));
S = size(n);
if S(2) > 0
  v1 = n(:,1);
  else
  [v1, e1] = eigs(ATemp,1);
end
v1 = abs(v1); v1 = v1/norm(v1,2); v1 = v1.*v1;

bbbbb2 = [v1; zeros(25,1)];
x = sedumi(AA2,bbbbb2,-c,K,pars);
F10 = x'*c';
if F10 < Best_Bias
iter_after_F10 = iter_after_F10 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

m0 = vec(sqrt(alpha0)*sqrt(alpha0)')';
m1 = vec(sqrt(alpha1)*sqrt(alpha1)')';

c = 0.5*[ 0,0,0,0,0,...
beta1(1)*m0, beta0(1)*m1, ...
beta1(2)*m0, beta0(2)*m1, ...
beta1(3)*m0, beta0(3)*m1, ...
beta1(4)*m0, beta0(4)*m1, ...
beta1(5)*m0, beta0(5)*m1, ...
];

ATemp = sparse(5,5);
for counter = 1:5
if beta1(counter) > beta0(counter)
ATemp = ATemp + 0.5 * beta1(counter) * sqrt(alpha0)*sqrt(alpha0)';
else ATemp = ATemp + 0.5 * beta0(counter) * sqrt(alpha1)*sqrt(alpha1)'; 
end
end

% F6 = max(eig(ATemp))
n = null(ATemp - F6*eye(5));
S = size(n);
if S(2) > 0
v1 = n(:,1);
else
[v1, e1] = eigs(ATemp,1);
end
v1 = abs(v1); v1 = v1/norm(v1,2); v1 = v1.*v1;

bbbbb2 = [v1; zeros(25,1)];

x = sedumi(AA2,bbbbb2,-c,K,pars);
F11 = x'*c';
if F11 < Best_Bias
iter_after_F11 = iter_after_F11 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

m0 = vec(sqrt(alpha0)*sqrt(alpha0)')';
m1 = vec(sqrt(alpha1)*sqrt(alpha1)')';

c = 0.5*[ 0,0,0,0,0,...
beta0(1)*m0, beta1(1)*m1, ...
beta0(2)*m0, beta1(2)*m1, ...
beta0(3)*m0, beta1(3)*m1, ...
beta0(4)*m0, beta1(4)*m1, ...
beta0(5)*m0, beta1(5)*m1, ...
];

[x,y,INFO] = sedumi(AA,bbbbb1,-c,K,pars);
SDPA0p = x'*c';
SDPA0d = abs(y'*bbbbb1);
SDPA0 = max([SDPA0p, SDPA0d]);
if SDPA0 < Best_Bias
iter_after_SDPA0 = iter_after_SDPA0 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

F12 = 1/(2*SDPA0);
if F12 < Best_Bias
iter_after_F12 = iter_after_F12 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

A_Bob = [ ...
kron(eye(5),e), O, O; ...
alpha0(1)*I, alpha0(2)*I, alpha0(3)*I, alpha0(4)*I, alpha0(5)*I, -A, O; ...
alpha1(1)*I, alpha1(2)*I, alpha1(3)*I, alpha1(4)*I, alpha1(5)*I, O, -A ...
];
c_Bob_0 = 0.5*[zeros(25,1); ...
               vec(sqrt(beta0)*sqrt(beta0)'); ...
               vec(sqrt(beta1)*sqrt(beta1)')];

[x,y,INFO] = sedumi(A_Bob, b_Bob, -c_Bob_0, G, pars);
SDPB0p = x'*c_Bob_0';
SDPB0d = abs(y'*b_Bob);
SDPB0 = max([SDPB0p, SDPB0d]);
if SDPB0 < Best_Bias
iter_after_SDPB0 = iter_after_SDPB0 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

m0 = vec(sqrt(alpha0)*sqrt(alpha0)')';
m1 = vec(sqrt(alpha1)*sqrt(alpha1)')';

c = 0.5*[ 0,0,0,0,0,...
beta1(1)*m0, beta0(1)*m1, ...
beta1(2)*m0, beta0(2)*m1, ...
beta1(3)*m0, beta0(3)*m1, ...
beta1(4)*m0, beta0(4)*m1, ...
beta1(5)*m0, beta0(5)*m1, ...
];

[x,y,INFO] = sedumi(AA,bbbbb1,-c,K,pars);
SDPA1p = x'*c';
SDPA1d = abs(y'*bbbbb1);
SDPA1 = max([SDPA1p, SDPA1d]);
if SDPA1 < Best_Bias
iter_after_SDPA1 = iter_after_SDPA1 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

F13 = 1/(2*SDPA1);
if F13 < Best_Bias
iter_after_F13 = iter_after_F13 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

c_Bob_1 = 0.5*[zeros(25,1); ...
               vec(sqrt(beta1)*sqrt(beta1)'); ...
               vec(sqrt(beta0)*sqrt(beta0)')];
[x,y,INFO] = sedumi(A_Bob, b_Bob, -c_Bob_1, G, pars);
SDPB1p = x'*c_Bob_1;
SDPB1d = abs(y'*b_Bob);
SDPB1 = max([SDPB1p,SDPB1d]);
if SDPB1 < Best_Bias
iter_after_SDPB1 = iter_after_SDPB1 + 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Update
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

bias = max([SDPA0, SDPA1, SDPB0, SDPB1]);
Best_Bias = bias;

protocol_vector = [protocol_vector; bias alpha0' alpha1' beta0' beta1'];
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Endifs for Filter (Known Strategies)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

end % SDPB1
end % SDPB0
end % F13
end % F12
end % F11
end % F10
end % SDPA1
end % SDPA0
end % F9
end % F8
end % F7
end % F6
end % F5
end % F4
end % F3
end % F2
end % F1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Endifs for Protocol Generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

end
end
end
end
end
end
end
end % alpha's

end
end
end
end
end
end
end
end % beta's

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Update 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

temp_vector1 = [ ...
prec_counter;
iter_after_F1;
iter_after_F2;
iter_after_F3;
iter_after_F4;
iter_after_F5;
iter_after_F6;
iter_after_F7;
iter_after_F8;
iter_after_F9;
iter_after_F10;
iter_after_F11;
iter_after_SDPA0;
iter_after_F12;
iter_after_SDPB0;
iter_after_SDPA1;
iter_after_F13;
iter_after_SDPB1]; 

temp_vector2 = [Best_Bias];

if prec_counter < input1 + 0.5
 Output_vector = temp_vector1
 Output_vector2 = temp_vector2
else Output_vector = [Output_vector, temp_vector1]
     Output_vector2 = [Output_vector2, temp_vector2]
end

end % endfor prec_counter

Output_vector
Output_vector2

% protocol_vector

return