%%% Test for White-Snow algorithm
%%% White's example


%%% Calculation of bounds for conditional:
%	max/min y_i
%	subject to
%             c1 y <= c2
% Called as lp([1,0,0,0], c1, c2, zeros(4,1), ones(4,1)) 
% for the variable y_1

c1 = [ -1 0 0 0 
       1 0 0 0
       0 0 -1 0
       1 -8 0 0 
       -1 7 0 0 
       0 1 -2 0
       0 -1 1 0
       0 1 0 -1
       0 -1 0 1 ];

c2 = [ -0.9; 0.95; -0.01; 0; 0; 0; 0; 0; 0];

%%% Calculation of prior bounds
%	max/min x_i
%	subject to
%             a1 x <= a2
% Called as lp([1,0,0,0],a1,a2,zeros(4,1),ones(4,1),[],1)
% for the variable x_1

a1 = [1 1 1 1
      -2.5 0 0 1
      2    0 0 -1
      0 -1 0 5 
      0 1 0 -5
      0 -1 9 0 
      0 1 -10 0];

a2 = [1; 0; 0; 0; 0; 0; 0];

%%% White-Snow algorithm with interval-conditionals

%%% Repeating the constraints for the priors
a = [-2.5 0 0   1  -2.5 0 0   1
       2  0 0  -1    2  0 0  -1
       0 -1 0   5    0 -1 0   5 
       0  1 0  -5    0  1 0  -5
       0 -1 9   0    0 -1 9   0 
       0  1 -10 0    0  1 -10 0];

% These are the lower and upper likelihoods
lik = [ 0.9 0.1125 0.0562 0.1125 0.95 0.1357 0.1357 0.1357 ]; 

% These are the basic matrices used by the White-Snow algorithm;
% algorithm is called by lp([1,0,0,0,1,0,0,0],wsa,wsb,zeros(8,1),ones(8,1),[],1)

wsa = [    1 1 1 1 1 1 1 1
       -2.7778         0         0    8.8889   -2.6316         0         0    7.3692
        2.2222         0         0   -8.8889    2.1053         0         0   -7.3692
         0   -8.8889         0   44.4444         0   -7.3692         0   36.8460
         0    8.8889         0  -44.4444         0    7.3692         0  -36.8460
         0   -8.8889  160.1423         0         0   -7.3692   66.3228   0
         0    8.8889 -177.9359         0         0    7.3692  -73.6920   0];

wsb = [1; 0; 0; 0; 0; 0; 0];


% These are the basic matrices used by the linear fractional algorithm;
% algorithm is called by lp([0.9,0,0,0,0.95,0,0,0],lf,lfb,zeros(8,1),[],[],1)
% Notice that vector of upper bounds is empty!!!

lf = [ 0.9 0.1125 0.0562 0.1125 0.95 0.1357 0.1357 0.1357 
      -2.5 0 0 1 -2.5 0 0   1
      2 0 0 -1     2  0 0  -1
      0 -1 0 5     0 -1 0   5 
      0 1 0 -5     0  1 0  -5
      0 -1 9 0     0 -1 9   0 
      0 1 -10 0    0  1 -10 0];

lfb = [1; 0; 0; 0; 0; 0; 0];



