function [fval] = BBCDLmodelcomp_ramsey_c1pid_c2pid_endoss_reduced(variablesguess,instr1,instr2,c1z,c2z,c1taupvar,c2taupvar,c1shockgy,c2shockgy)

global M_ 

%% assign variables and parameter values 

num_variablesguess=size(variablesguess,1);
for idxxx=1:1:num_variablesguess
    define_string=[M_.endo_names_reduced(idxxx,:),'=',sprintf('%20.20g',variablesguess(idxxx))];
    evalc(define_string);
end

if isnan(M_.params(:,:))==0
    %read parameter values from M_.params and assign to parameters names.
    %this overwrites parameters coming from params.m if estimation is done.
    num_para=size(M_.params,1);
    for idxxx=1:1:num_para
        define_string=[M_.param_names(idxxx,:),'=',sprintf('%20.20g',M_.params(idxxx))];
        evalc(define_string);
    end
end

 
fval(1) = instr1 - ( c1pid); 
 
fval(2) = instr2 - ( c2pid); 
 
% fval(7) =  c1deltadlag - (c1deltad);  
% 
% fval(8) = c1rnlag - (c1rn);  
% 
% fval(9) = c1rpcpdlag - (c1rpcpd);  
% 
% fval(10) = c2deltadlag - (c2deltad);  
% 
% fval(11) = c2rnlag - (c2rn);  
% 
% fval(12) = c2rpcpdlag - (c2rpcpd);    
%  
% fval(13) = Util1 - ( (exp(c1c))^(1-c1sigma)/(1-c1sigma)-c1chi0*(exp(c1z))^(-c1chi)*(exp(c1y))^(1+c1chi)/(1+c1chi)*exp(c1deltad)); 
%  
% fval(14) = Util2 - ( (exp(c2c))^(1-c2sigma)/(1-c2sigma)-c2chi0*(exp(c2z))^(-c2chi)*(exp(c2y))^(1+c2chi)/(1+c2chi)*exp(c2deltad)); 
%  
% fval(15) = Welfcon1 - ( (exp(c1c))^(1-c1sigma)/(1-c1sigma) + c1beta*Welfcon1); 
%  
% fval(16) = 1/(1+(c1rn)) - ( c1beta*(((exp(c1c))^(-c1sigma)/exp(c1rpcpd)))/(((exp(c1c))^(-c1sigma)/exp(c1rpcpd)))/c1pid); 
 
fval(3) = exp(c1rpcpd)*(c1omegac*exp(c1c)/exp(c1cd))^(c1rhoc/(1+c1rhoc)) - ( 1); 
 
fval(4) = (exp(c1rer))/(exp(c2rpcpd))- ( (c1omegamc*exp(c1c)/exp(c1mc))^(c1rhoc/(1+c1rhoc))); 
 
fval(5) = exp(c1c) - ( ((c1omegac)^(c1rhoc/(1+c1rhoc))*exp(c1cd)^(1/(1+c1rhoc))+(c1omegamc)^(c1rhoc/(1+c1rhoc))*(exp(c1mc))^(1/(1+c1rhoc)))^(1+c1rhoc)); 
 
fval(6) = (exp(c1pstar))^(1+(1+c1nup)/(c1nup)*c1chi) - ( (exp(c1hp))/(exp(c1gp))); 
 
fval(7) = (exp(c1hp)) - ( (1+(c1nup))/(c1nup) ... 
*c1chi0*(exp(c1y)/exp(c1z))^(c1chi)/((exp(c1c))^(-c1sigma)/exp(c1rpcpd))*exp(c1y) ... 
+ c1xip*c1beta*(((exp(c1c))^(-c1sigma)/exp(c1rpcpd)))/(((exp(c1c))^(-c1sigma)/exp(c1rpcpd)))*((c1pistar)/(c1pid))^(-(1 ... 
+(c1nup))/(c1nup)*(1+c1chi))*(exp(c1hp))); 
 
fval(8) = (exp(c1gp)) - ( (1+c1taup*exp(c1taupvar))/(c1nup)*(exp(c1y))+c1xip*c1beta*(((exp(c1c))^(-c1sigma)/exp(c1rpcpd)))/(((exp(c1c))^(-c1sigma)/exp(c1rpcpd)))*((c1pistar)/(c1pid))^(1 ... 
-(1+(c1nup))/(c1nup))*(exp(c1gp))); 
 
fval(9) = (1-c1xip)*((exp(c1pstar)))^(-1/(c1nup))+c1xip*((c1pistar)/(c1pid))^(-1/(c1nup)) - ( 1); 
 
% fval(24) = (exp(c1deltad)) - ( (1-c1xip)*((exp(c1pstar)))^(-(1+(c1nup))/(c1nup)*(1+c1chi)) ... 
% +c1xip*((c1pistar)/(c1pid))^(-(1+(c1nup))/(c1nup)*(1+c1chi))*(exp(c1deltadlag))); 
 
fval(10) = exp(c1y) - ( exp(c1cd)+exp(c1g)+1/c1relc2*(exp(c2mc))); 
 
fval(11) = exp(c1g) - ( c1sharegy*exp(c1y)*exp(c1shockgy)); 
 
% fval(27) = c1dcore - ( exp(c1rpcpd)/exp(c1rpcpdlag)*c1pid); 
 
%fval(28) = 1/(1+(c2rn)) - ( c2beta*(((exp(c2c))^(-c2sigma)/exp(c2rpcpd)))/(((exp(c2c))^(-c2sigma)/exp(c2rpcpd)))/c2pid); 
 
fval(12) = (exp(c2rpcpd))*(c2omegac*(exp(c2c))/(exp(c2cd)))^(c2rhoc/(1+c2rhoc)) - ( 1); 
 
fval(13) = 1/(exp(c1rer))/(exp(c1rpcpd)) - ( (c2omegamc*(exp(c2c))/(exp(c2mc)))^(c2rhoc/(1+c2rhoc))); 
 
fval(14) = (exp(c2c)) - ( ((c2omegac)^(c2rhoc/(1+c2rhoc))*(exp(c2cd))^(1/(1+c2rhoc))+(c2omegamc)^(c2rhoc/(1+c2rhoc))*((exp(c2mc)))^(1/(1+c2rhoc)))^(1+c2rhoc)); 
 
fval(15) = (exp(c2pstar))^(1+(1+c2nup)/(c2nup)*c2chi) - ( (exp(c2hp))/(exp(c2gp))); 
 
fval(16) = (exp(c2hp)) - ( (1+(c2nup))/(c2nup) ... 
*c2chi0*(exp(c2y)/exp(c2z))^c2chi/((exp(c2c))^(-c2sigma)/exp(c2rpcpd))*exp(c2y) ... 
+ c2xip*c2beta*(((exp(c2c))^(-c2sigma)/exp(c2rpcpd)))/(((exp(c2c))^(-c2sigma)/exp(c2rpcpd)))*((c2pistar)/(c2pid))^(-(1 ... 
+(c2nup))/(c2nup)*(1+c2chi))*(exp(c2hp))); 
 
fval(17) = (exp(c2gp)) - ( (1+c2taup*exp(c2taupvar))/(c2nup)*(exp(c2y))+c2xip*c2beta*(((exp(c2c))^(-c2sigma)/exp(c2rpcpd)))/(((exp(c2c))^(-c2sigma)/exp(c2rpcpd)))*((c2pistar)/(c2pid))^(1 ... 
-(1+(c2nup))/(c2nup))*(exp(c2gp))); 
 
fval(18) = (1-c2xip)*((exp(c2pstar)))^(-1/(c2nup))+c2xip*((c2pistar)/(c2pid))^(-1/(c2nup)) - ( 1); 
 
% fval(36) = (exp(c2deltad)) - ( (1-c2xip)*((exp(c2pstar)))^(-(1+(c2nup))/(c2nup)*(1+c2chi)) ... 
% +c2xip*((c2pistar)/(c2pid))^(-(1+(c2nup))/(c2nup)*(1+c2chi))*(exp(c2deltadlag))); 
 
fval(19) = (exp(c2y)) - ( (exp(c2cd))+(exp(c2g))+(c1relc2*(exp(c1mc)))); 
 
fval(20) = (exp(c2g)) - ( c2sharegy*(exp(c2y))*(exp(c2shockgy))); 
 
%fval(39) = c2dcore - ( exp(c2rpcpd)/exp(c2rpcpdlag)*c2pid); 
 
fval(21) = c2lambdaqss/((exp(c2c))^(-c2sigma))*c2rpcpdss - ( c1rerss/(exp(c1rer))*c1lambdaqss/((exp(c1c))^(-c1sigma))*c1rpcpdss); 
 
%fval(41) = c1shockgy - ( c1rhogy*c1shockgy + c1sigmagy*0); 
 
%fval(42) = c1z - ( c1rhoz*c1z + c1sigmaz*0); 
 
%fval(43) = c1taupvar - ( c1rhotaupvar*c1taupvar+c1sigmataupvarerr*0); 
 
%fval(44) = c2shockgy - ( c2rhogy*c2shockgy + c2sigmagy*0); 
 
%fval(45) = c2z - ( c2rhoz*c2z + c2sigmaz*0); 
 
%fval(46) = c2taupvar - ( c2rhotaupvar*c2taupvar+c2sigmataupvarerr*0); 

end



