From 8f6e0423ab937bcfd57608f61b5fd52c8d036490 Mon Sep 17 00:00:00 2001 From: youainti Date: Tue, 22 Jun 2021 16:11:21 -0700 Subject: [PATCH] finished generalized solution explanation. added pseudo_code section --- CurrentWriting/Main.tex | 36 +++++--- .../sections/apx_02_GeneralizedEuEqSteps.tex | 89 ++++++++++++++++++- psuedo_code.txt | 53 +++++++++++ 3 files changed, 163 insertions(+), 15 deletions(-) create mode 100644 psuedo_code.txt diff --git a/CurrentWriting/Main.tex b/CurrentWriting/Main.tex index 65ac925..7bca9c8 100644 --- a/CurrentWriting/Main.tex +++ b/CurrentWriting/Main.tex @@ -20,20 +20,32 @@ \section{Introduction} \subfile{sections/00_Introduction} %TODO -\section{Laws of Motion} +\section{Current Literature} % Lit Review + +\section{Modeling the Environment} +\subsection{Laws of Motion} \subfile{sections/01_LawsOfMotion} %DONE -\section{Kessler Syndrome}\label{SEC:Kessler} +\subsubsection{Survival Analysis}\label{SEC:Survival} +\subfile{sections/03_SurvivalAnalysis} %TODO + +\subsection{Kessler Syndrome}\label{SEC:Kessler} \subfile{sections/02_KesslerSyndrome} +\subfile{sections/06_KesslerRegion} +%TODO: +% So these sections need combined and rewritten +% In particular, I want to describe the differences present in +% the proto-kessler region. +% +% +% +% +% +% +% -\section{Motion Results}\label{SEC:MotionResults} -The following are two results due to the laws of motion presented. -\subsection{Kessler Regions} -\subfile{sections/06_KesslerRegion} %TODO -\subsection{Survival Analysis}\label{SEC:Survival} -\subfile{sections/03_SurvivalAnalysis} %TODO \section{Model} \subsection{Constellation Operator's Program}\label{SEC:Operator} @@ -55,9 +67,11 @@ I hope to write a section clearly explaining assumptions, caveats, and shortcomi \section{Appedicies} \subsection{Mathematical Notation} Needs completed. -\subsection{Derivations} -\subsubsection{Marginal Survival Rates}\label{APX:Derivations:SurvivalRates} -%\subfile{sections/appedicies/apx_01_MarginalSurvivalRates} +\subsection{Deriving Marginal Survival Rates}\label{APX:Derivations:SurvivalRates} +%\subfile{sections/apx_01_MarginalSurvivalRates} + +\subsection{Deriving Euler Equations}\label{APX:Derivations:EulerEquations} +\subfile{sections/apx_02_GeneralizedEuEqSteps} \end{document} diff --git a/CurrentWriting/sections/apx_02_GeneralizedEuEqSteps.tex b/CurrentWriting/sections/apx_02_GeneralizedEuEqSteps.tex index f62c4be..6060972 100644 --- a/CurrentWriting/sections/apx_02_GeneralizedEuEqSteps.tex +++ b/CurrentWriting/sections/apx_02_GeneralizedEuEqSteps.tex @@ -2,8 +2,10 @@ \graphicspath{{\subfix{Assets/img/}}} \begin{document} -General Description of Defining Euler Equations with many choice -and state variables. +The following is a general description of how to solve highly dimensional +bellman equations. +I currently only have it describing deterministic systems, but I will be +adding stochastic versions soon. Consider the following constrained Bellman Equation: @@ -44,9 +46,88 @@ If $A_t$ is invertible, it gives the iteration condition If $A_t$ is not invertible, you don't have a solution leading to the standard euler equation. But, assuming it is, we can now begin solving for the Euler Equation. -The basic approach is to choose enough extra +\subsubsection{Solving for Euler Equations} +The basic approach is to increment your optimality conditions +forward a given number of periods, +and then recurively apply the envelope conditions and laws of motion +to define it in terms of the current period $t$ variables $\theta_t$. +With the correct increments, you will get enough conditions to specify both +$\parder{W}{\theta_t}{}$ and $x(\theta_t)$. + +This leaves two important questions: +\begin{itemize} + \item How do you choose the number of periods to increment the optimality conditions? + \item How do we use these to specify $x(\theta_t)$? +\end{itemize} + +In response to the first question, there are $k+m$ unknown variables, +the $k$ $x(\theta_t)$ policy functions and the $m$ $\parder{w}{\theta_t}{}$ value +function derivatives. +%Thus we need $m+k$ conditions to solve the system. +By incrementing the optimality condition $j$ times such that $j\cdot m > m+k$, +and substituting the appropriate time-transition from the recursive envelope condition, +we can implicity define the $k+m$ unknowns through $k+m$ equations. + +This provides the answer two the second question. +With the system of euler equations in hand\footnote{ + And appropriate existence results depending on the exact specification +} +we can choose any functional approximation approach that we care to use. +Options include euler equation iteration on a grid, +neural networks, generalized least squares, etc. +but we must solve for both the policy function and the partial +derivatives together. + +If we don't care about the $m$ partial derivatives, we can simplify +this by recognizing that the $m$ terms that determine them can be used +to solve for $\parder{w}{\theta_t}{}$ in terms of $x()$, and then substituted into +the $k$ conditions that determine $x()$ in terms of $\parder{w}{\theta_t}{}$. +This gives us the standard euler equations. + +\subsubsection{Inequality Constraints} +The discussion above holds for equality constraints. +How do we include inequality constraints, such as a lower bound on consumption +or an upper bound on launch rates? + +This can be addressed by using the KKT maximization technuite to create the optimality conditions. +and including the complementary slackness conditions in the system of equations +used to determine the euler equations. + +A basic example is: +\begin{align} + W(\theta_t) =& \max_{x_t} F(\theta_t,x_t) + \beta W(\theta_{t+1}) \\ + \text{Subjet To:}\\ + &\theta_{t+1} = G(\theta_t, x_t) \\ + &a_i \leq (x_t)_i \leq b_i ~\forall~ i \in \{1\dots k\} +\end{align} + + +The resulting stationarity conditions in matrix form are +\begin{align} + [0] =& \underset{k\times 1}{\parder{F(\theta_t,x_t)}{x_t}{} } + + \beta + \underset{k \times m}{\parder{G(\theta_t,x_t)}{x_t}{} } + \cdot + \underset{m\times 1}{\parder{W(\theta_{t+1})}{\theta_{t+1}}{}} + + \underset{k \times 1}{\left[-\lambda_a + \lambda_b\right]} \\ + 0 =& \lambda_a [(x_t)_i - a_i] ~\forall~ i \in \{1\dots k\} \\ + 0 =& \lambda_b [(x_t)_i - b_i] ~\forall~ i \in \{1\dots k\} +\end{align} + +In some situations (such as when using neural networks to approximate the policy function), +this organization of the complementary slackness conditions is difficult to use. +A useful equivalent condition is setting the equivalent Fisher-Burmeister function +equalt to zero. +\begin{align} + 0 = \Phi(a,b) = a + b - \sqrt{a^2 + b^2} +\end{align} +A quick proof by contradiction shows that $\Phi(a,b)=0$ exists only when +$a\geq0, b\geq 0, ab=0$. +As it is differentiable, this works well for gradient descent.\footnote{ + https://notes.quantecon.org/submission/5ddb3c926bad3800109084bf +} + -The first problem we need to address is dimensionality conserns \end{document} diff --git a/psuedo_code.txt b/psuedo_code.txt new file mode 100644 index 0000000..3decda1 --- /dev/null +++ b/psuedo_code.txt @@ -0,0 +1,53 @@ +# psuedo code to solve for euler equations with neural networks + +/* +# bellman with policy function + +Vt(Θ) = F(Θ,x(Θ)) + β Vtt(G(Θ,x(Θ))) + where x() maximizes the standard bellman + a-g(Θ,x) < 0 + +## Setting up the euler equation + +### Stationarity (optimality) Conditions +0 =set= ∇Vt wrt x() - λ + - Implies definition of ∇Vtt wrt G() in terms of x(), λ, and Θ +#### Complementary Slackness Conditions +λ * (a-g()) = 0 and one of the terms is greater than zero. + - There is a continuous, roughly parabolic alternative + to this condition called the Fisher-Burmeister function. + +### Envelope Conditions +∇Vt wrt Θ = ∇F wrt Θ + β ∇Vtt wrt G X ∇G wrt Θ + - This defines ∇Vtt wrt G in terms of Θ,x,∇F, and ∇Vt wrt Θ + which we call the time-transition function. + - It turns out to be an affine problem + - There are invertibility conditions that are important to be aware of. +*/ + + +// Setup envelope conditions +// Set up laws of motion +// Recursive definition of time-transition function. + +// Increment optimality/stationarity conditions +// Substitute time-transition function as needed into stationarity conditions + +// Choose the set of transitioned, stationarity conditions you will be using +// Set them into a vector of conditions. +// Now you should have a vector function in terms of Θ, x(), and maybe ∇Vtt. +// Make sure to add the complementary slackness conditions + +// Set up loss functions +// The most basic is the l_2 metric on the vector. +// It may be worth making a penalized loss function, but you do you. + +// Generate your initial neural network +// If you didn't solve out ∇Vtt, generate that as a neural network. +// Honestly though, you should probably just solve it out. + +// Substitute the neural network into the loss function +// Generate a variety of states. +// Start using some gradient descent to train the model + +// Notice some error you made, and start over again (do you want to account for asymmetry in the utility functions?)