%PLANT    is a script file used to compute the optimal lotteries for
%         the planner in ``The firm and the plant in general equilibrium'' 
%         by Hornstein and Prescott (Section 3).

%         Ellen McGrattan, 04-06-93



% Inputs
% ------
%
%   grid on consumption, hours, capital/worker:

C   = [.2:.03:.5]';
H   = [0:.05:.4]';
K   = [0:.1:.3,2:.1:3]';
C   = [.3:.02:.38]';
H   = [0:.1:.7]';
K   = [0:1:6]';

%   parameters:

alpha = .3;
gamma = .3;
sigma = .8;
kbar  = 2;



%----------------------------------------------------------------------------

nc  = length(C);
nh  = length(H);
nk  = length(K);
nhk = nh*nk;
nch = nc*nh;
n   = nc*nhk;
C   = kron(ones(nhk,1),C);
H   = kron(H,ones(nc,1))*ones(1,nk);
H   = H(:); 
K   = kron(K,ones(nch,1));
U   = ((C.^gamma.*(1-H).^(1-gamma)).^(1-sigma)-1)/(1-sigma);
F   = K.^alpha;
lbx = zeros(n,1);
ubx = ones(n,1);
A   = [ones(1,n);
      (C-F.*H)';
       K'];
b   = [1;0;kbar];
x   = lp(-U,A,b,lbx,ubx,ones(n,1)/n,1);

[x,C,H,K,-U]
-U'*x
b-A*x


%save plant
