close all; clear all; diary([mfilename '.out']); 
disp('optimal sales scheme model. F: truncated exponential distribution');

%Solve the sequential pricing problems with J=I and alpha_0=0.

denom = 7;
%permutations of four buyers
B1=[1/denom 2/denom 3/denom 4/denom];
B2=[2/denom 1/denom 3/denom 4/denom];
B3=[3/denom 1/denom 2/denom 4/denom];
B4=[4/denom 1/denom 2/denom 3/denom];


% parameters
M = 2; %least upper bound of the distribution
delta = 0.5;
edm = exp(-delta*M);
mu = (delta^(-1) - (M+delta^(-1))*edm) / (1-edm);

% define grid for alpha
maxa = 3*(M-mu);					% maximum value of alpha grid
mina = 3*(-mu);					% minimum value of alpha grid
ia = 0.005; 					% size of alpha grid
na = round((maxa - mina)/ia+1);	% number of alpha grid points

% determine grid point for alpha=0
for i=1:na
	if i*ia + mina <= 0 & (i+1)*ia + mina >= 0;
		a0=i+1;
	end
end


% define vec_a as a column vector
for i=1:na
	vec_a(i,1) = (i-1)*ia + mina;
end

%%%
B=B1;
A = aoyagi11func(B, maxa, mina, ia, na, M, delta, edm, mu);
A1=A;
disp(A1(1,a0));

%B=B2
B=B2;
A = aoyagi11func(B, maxa, mina, ia, na, M, delta, edm, mu);
A2=A;
disp(A2(1,a0));

%B=B3
B=B3;
A = aoyagi11func(B, maxa, mina, ia, na, M, delta, edm, mu);
A3=A;
disp(A3(1,a0));

%B=B4
B=B4;
A = aoyagi11func(B, maxa, mina, ia, na, M, delta, edm, mu);
A4=A;
disp(A4(1,a0));


%evaluate at the initial state a=0

disp('A1-A2');
disp(A1(1,a0)-A2(1,a0));

disp('A1-A3');
disp(A1(1,a0)-A3(1,a0));

disp('A1-A4');
disp(A1(1,a0)-A4(1,a0));

diary off;


