Before soving industy equilibrium, you must solve the optimal policy for individual firm. The codes for doing that are in the folder 'Basic'. THe programs will save the optimal policy in some folder.

Note: when solving the optimal policy, you must set lamda>alpha (i.e. lamda=0 won't do here)

To solve the industry equilibrium, define on lines 19-23 of "equilibriumruns.m" the directory and file name extensions to read the optimal policy of the individual firm.

To solve for a single case with given s0 and phi (e.g. s0=0, phi=0.5), define in the command window phi=0.5; sinit=0;  flag_switch=1; 

Then run "equilibriumruns.m";

A figure of the density and a figure of the contour plot of average age will be built. To continue with another set of s0 and phi (e.g. s0=0.1, phi=0.6), set phi=0.6; sinit=0.5; flag_switch=2; (flag_switch=2 means that transition matrix will not be computed again, the program will use the transition matrix biult in the previous run). Then run again "equilibriumruns.m".


2.To make the figure as in 'output_makeIEgraph3.fig', simply call makeIEgraph;To change the optimal policy for individuals which is used to compute the industry equilibrium, see Line 6-10 in 'makeIEgraph.m'. 'equilibriumruns_2.m' is a modified version of 'equilibriumruns.m' only used in 'makeIEgraph.m'. Optimal policy of individuals used to find equilibrium distribution should be loaded before calling 'equilibriumrums_2.m'.

3.Other supplement programs:unconstrained.m: called in makeIEgraph.m. This function computes the equilibium distribution of firms of the unconstrained case for all possible values phi corresponding to xgrid. To use it, run [phi0_un,array_price_un,array_output_un,array_age_un]=unconstrained(params,xgrid);with params and xgrid from the results of NewProgram.plot_one_s.m: called in makeIEgraph.m. This function finds all possible values of phi with a given s0 so that the birth points are in the continuation region, computes and plots figures of price, mean output and mean age for each phi and percentage change compared to the unconstrained case. To plot the curves colored red with one fixed s0 (e.g. s0=0.1), run s0=0.1; [phi0,array_price,array_output,array_age]=plot_one_s(V,pol,xgrid,sgrid,s0,'r',phi0_un,array_price_un,array_output_un,array_Age_un);makephigrid.m: called in plot_one_s.m. This function finds the index xind so that all the birth points in the continuationregion with the given s0 have x=xgrid(xind) and it also computes the values of phi corresponding to xgrid(xind). It also print [s x phi] in the command window, where phi is the minimum value with which part of s0 will be paid immediately after birth, and (x,s) is the corresponding birth point, which should be on the dividend line. For example, with s0=0.1, run s0=0.1; [xind,phi]=makephigrid(V,pol,xgrid,sgrid,s0);