(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



(* This cell contains uninteresting generic setup stuff to prepare for execution of the programs *)

ClearAll["Global`*"];

(* If running from Notebook front end, set directory to Notebook's directory *)
If[Length[$FrontEnd] > 0, NBDir = SetDirectory[NotebookDirectory[]]];(* If running from the Notebook interface *)
If[Length[$FrontEnd] == 0,SetDirectory["/Volumes/Data/Work/BufferStock/BufferStockTheory/Latest/Code/Mathematica/Results/BufferStockTheory"]];

HomeDir = Directory[];
CodeDir = HomeDir<>"/../../CoreCode";
CDToHomeDir := SetDirectory[HomeDir];
CDToCodeDir := SetDirectory[HomeDir<>"/../../CoreCode"];
CDToCodeDir;

<<SetupModelSolutionRoutines.m;
<<SetParamsToBaselineVals.m;
SaveFigs=True;


(* Example of parameters where FVAC holds but GIC fails *)
CDToHomeDir;
<<SetParamsFVACnotGIC.m; 
SetupGrids;
SetupShocks;
Print["GIC fails (1 < \[CapitalThorn]\[CapitalGamma]):" , 1 < GICValue];
Print["FVAC holds FVA < 1:",FVA < 1];
ConstructLastPeriodToConsumeEverything;
<<FVACnotGICPlot.m;


(* Show convergence of consumption rules iterating back from terminal period T *)
SetParamsBaseline;
SetupGrids;
SetupShocks;
ConstructLastPeriodToConsumeEverything; (* Define terminal consumption rule as the one for the finite horizon *)
CDToHomeDir;
<<cFuncsConvergeSolve.m;
<<cFuncsConvergePlot.m;


(* Show characteristics of the converged consumption rule *)
SetParamsBaseline;
ConstructLastPeriod;
aGridVecExcBotSmallLength = 10;
aGridVecExcBotLargeLength = 30;
SetupGrids;
Off[InterpolatingFunction::dmval];
SolveInfHorizToToleranceAtTarget[mTargetDiffAtSuccessiveIterations=0.001];


CDToHomeDir;<<cFuncBoundsPlot.m;


<<cGroTargetFigPlot.m;


<<MPCLimitsPlot.m;


<<cRatTargetFigPlot.m;


<<SimCDFsConverge.m;


<<SimCDFsConvergePlot.m;


<<SimRevolution.m;


<<SimRevolutionPlot.m;


<<doApndxLiqConstr.m;


<<doApndxcLim.m;



