clear all; close all; clc;
 
global alpha beta gamma omega deltak deltag sigma psi r_e d_b rho sigmaeA rho_j sigma_j psi2
 
alpha = 0.2856878;  %0.42 check; 
gamma = 0.0564; %0.05 check; %
r_e=0.0182;
beta = 0.9747; %
deltak = 0.01089;
deltag = 0.01089;  % 
psi=0.27;
omega=1.45;
sigma=2;
d_b=2.16;
rho = 0.82;
sigmaeA = 0.012;
rho_j=0.7514;
sigma_j=0.01;
psi2=0.00072; 

x0 =[0.5, 0.5, 0.5, 0.6,0.5 , 0.5, 0.5, 0.5,0.5,0.5,0.5];
%opts = optimoptions(@fsolve,'Algorithm', 'levenberg-marquardt','MaxFunEval',10000,'Maxiter',10000,'TolFun',.0001);
%opts=optimset('Algorithm','levenberg-marquardt','LargeScale','off','TolFun',.00001,'MaxIter',100000,'MaxFunEvals',100000);
[x, fval, flag]= fsolve('foc_abierta',x0);

c_ss= x(1)
n_ss = x(2)
lambda_ss= x(3)
k_ss = x(4)
g_ss = x(5)
i_ss=x(6)
ig_ss=x(7)
y_ss=x(8)
q_ss=x(9)
miu_ss=x(10)


save parame alpha beta gamma omega deltak deltag sigma psi c_ss n_ss lambda_ss...
k_ss g_ss i_ss ig_ss y_ss q_ss miu_ss rho sigmaeA rho_j sigma_j r_e psi2; 
    
igy = ig_ss/y_ss;
iy = i_ss/y_ss;
ky= k_ss/y_ss;
gy=g_ss/y_ss;
cy=c_ss/y_ss;
gk=g_ss/k_ss;
ik=i_ss/k_ss;
ratios=table(igy, iy, ky,gy,cy,gk, n_ss,ik,q_ss,y_ss);
ss=table(y_ss,k_ss,i_ss,g_ss,ig_ss, n_ss,c_ss,lambda_ss);

dynare economia_abierta.mod noclearall
