
clc;  clear;  close
load ("data/Parameters.mat",'m');

JJ = 21;
dis = 0.05;
beta_ini = 0; 
%% The equilibrium
% Case 1: competition + prohibit
m.DataPolicy = 'prohibit';  % prohibit free
m.MarketStruct = 'competition';  % competition oligopoly monopoly 
m.Privacy = 'nonePrivacy';  % nonePrivacy privacyExternality

for i = 1:JJ
    m.beta_c = beta_ini + dis*(i-1);
    m.beta_u = m.beta_c; 
    [wel1,Case11] = func_eqm_iter(m);   
    Case1.wel_c(i,1) = Case11.wel_c;
    Case1.wel_u(i,1) = Case11.wel_u;
end

% Case 2: competition + free
m.DataPolicy = 'free';  % prohibit free
m.MarketStruct = 'competition';  % competition oligopoly monopoly 
m.Privacy = 'nonePrivacy';  % nonePrivacy privacyExternality

for i = 1:JJ
    m.beta_c = beta_ini + dis*(i-1);
    m.beta_u = m.beta_c; 
    [wel2,Case22] = func_eqm_iter(m);   
    Case2.wel_c(i,1) = Case22.wel_c;
    Case2.wel_u(i,1) = Case22.wel_u;
end

% Case 3: monopoly + prohibit
m.DataPolicy = 'prohibit';  % prohibit free
m.MarketStruct = 'monopoly';  % competition oligopoly monopoly 
m.Privacy = 'nonePrivacy';  % nonePrivacy privacyExternality

for i = 1:JJ
    m.beta_c = beta_ini + dis*(i-1);
    m.beta_u = m.beta_c; 
    [wel3,Case33] = func_eqm_iter(m);   
    Case3.wel_c(i,1) = Case33.wel_c;
    Case3.wel_u(i,1) = Case33.wel_u;
end

% Case 4: monopoly + free
m.DataPolicy = 'free';  % prohibit free
m.MarketStruct = 'monopoly';  % competition oligopoly monopoly 
m.Privacy = 'nonePrivacy';  % nonePrivacy privacyExternality

for i = 1:JJ
    m.beta_c = beta_ini + dis*(i-1);
    m.beta_u = m.beta_c; 
    [wel4,Case44] = func_eqm_iter(m);   
    Case4.wel_c(i,1) = Case44.wel_c;
    Case4.wel_u(i,1) = Case44.wel_u;
end

beta = beta_ini:dis:beta_ini + dis*(i-1);
beta = beta';
save ("data\Baseline.mat", "Case1", "Case2", "Case3", "Case4","beta","m")

