Solving dynamic optimization with non-binding inequality constraint I want to solve a problem similar to the following discrete and finite time horizon dynamic optimization problem :
\begin{equation} 
\begin{split}
&\max_{\{d_t\}} \sum_{t=0}^{T} - \left [ f(s_t) + k(d_t)  \right ] + F(s_{T+1})\\
& s.t. \left \{ \begin{array}{ll} 
s_{t+1} = s_t + d_t \\
s_t < A \\
s_0 \in \mathbb{R}_+ \\
s_T = A \\
\end{array}
\right.
\end{split}
\end{equation} 
I am able to solve the problem without the inequality constraint $s_t < A$ using Lagrangian multiplier which leads to a recursive equation on $s_t$ which I am able to solve numerically afterwards. 
I wish to find a similar recursive equation, but this time when considering $s_t < A$. How should I take this inequality constraint into account when computing the Lagrangian first order conditions ?  
 A: I will present a reduced example shoving how to solve this kind of problems using the classical procedure of Lagrange multipliers. To apply this technique, previously we transform the inequalities into equalities with the help of the $\epsilon_k$ slack variables.  
First form the Lagrangian
$$
L(x,u,\lambda,\epsilon) = \phi(x_{n+1})-f(x,u)+\sum_{k=1}^n\lambda_k(x_{k+1}-x_k-u_k) + \sum_{k=1}^n\lambda_{n+k}(x_k-A+\epsilon_k^2)+\lambda_{2n+1}(x_n-A)
$$
where
$$
\phi(x_{n+1}) = x_{n+1}^2\\
f(x,u) = \min(\max)\sum_{k=1}^na x_k^2+b u_k^2
$$
Now considering $n = 5$ the stationary conditions are
$$
\nabla L = \left\{
\begin{array}{rcl}
 2 \epsilon _1 \lambda _6&=&0 \\
 2 \epsilon _2 \lambda _7&=&0 \\
 2 \epsilon _3 \lambda _8&=&0 \\
 2 \epsilon _4 \lambda _9&=&0 \\
 2 \epsilon _5 \lambda _{10}&=&0 \\
 -u_1-x_1+x_2&=&0 \\
 -u_2-x_2+x_3&=&0 \\
 -u_3-x_3+x_4&=&0 \\
 -u_4-x_4+x_5&=&0 \\
 -u_5-x_5+x_6&=&0 \\
 \epsilon _1^2-A+x_1&=&0 \\
 \epsilon _2^2-A+x_2&=&0 \\
 \epsilon _3^2-A+x_3&=&0 \\
 \epsilon _4^2-A+x_4&=&0 \\
 \epsilon _5^2-A+x_5&=&0 \\
 x_5-A&=&0 \\
 2 b u_1+\lambda _1&=&0 \\
 2 b u_2+\lambda _2&=&0 \\
 2 b u_3+\lambda _3&=&0 \\
 2 b u_4+\lambda _4&=&0 \\
 2 b u_5+\lambda _5&=&0 \\
 -\lambda _1+\lambda _6-2 a x_1&=&0 \\
 \lambda _1-\lambda _2+\lambda _7-2 a x_2&=&0 \\
 \lambda _2-\lambda _3+\lambda _8-2 a x_3&=&0 \\
 \lambda _3-\lambda _4+\lambda _9-2 a x_4&=&0 \\
 \lambda _4-\lambda _5+\lambda _{10}+\lambda _{11}-2 a x_5&=&0 \\
 \lambda _5+2 x_6&=&0 \\
\end{array}
\right.
$$
Solving this system of equations we obtain for the parametric values $a = 2, b = 2, A = 1, n = 5$
follows the $\min$ strategy (in red $u$ and in blue $x$)

and the $\max$ strategy

Any way, this kind of problem can be satisfactorily solved with a quadratic programming package, without the need for the slack variables introduction. See https://en.wikipedia.org/wiki/Quadratic_programming
I hope this helps.
