Calculus of Variation with inequality constraints - Lagrange multiplier approach does not work This is related to a question I asked several years ago, see here.
I want to find the functon $y$ which maximizes the functional
$$J[y]= \int_{a}^{a+1} (2x- 1-a)y(x) \left(1+B\left[y(x)-1\right]\right)-(2y(x)+a)(1-x+a) \left(1+ S(x-a)\right)y'(x) \;dx$$
subject to $0 \leq y(x) \leq 1$ and $y'(x)\geq0$ for all $x\in [a,a+1]$. Moreover, $B, S\in [0,1]$ and $a\geq0$.
I include the constraints $0 \leq y(x) \leq 1$ using Lagrange multipliers so that I obtain the problem
$$J[y]= \int_{a}^{a+1} (2x- 1-a)y(x) \left(1+B\left[y(x)-1\right]\right)-(2y(x)+a)(1-x+a) \left(1+ S(x-a)\right)y'(x) + h(x)(1-y(x)) + g(x)y(x)\;dx$$
where $g(x), h(x) \geq0$ and I have the complementary slackness conditions $h(x)(1-y(x))=0$ and $g(x) y(x)=0$.
The problem is simpler for $a=0$ and let's ignore the constraint $y'(x) \geq0$ for now. One can solve for the Euler-Lagrange equation and, using the complementary slackness conditions, obtain
$$y(x) = -\frac{-2Bx+B+2x-1}{2(2Bx-B-2Sx+S-1)}$$
for $x\geq 1/2$ and $y(x) = 0$ otherwise. It is easily verified that the $y'(x)\geq0$ is indeed satisfied. So far so good.
Now consider $a>0$. Proceeding as above yields (1)
$$y(x)= -\frac{-2a^2S-aB+2aSx-aS+2a+2Bx-B-2x+1}{2(aB-2aS-2Bx+B+2Sx-S+1)}, g(x) = h(x) =0$$
and (2)
$$g(x)=-2a^2S-aB+2aSx-aS+2a+2Bx-B-2x+1, y(x) = h(x)=0$$
and (3)
$$h(x)=2a^2S-aB-2aSx+5aS-2a+2Bx-B-4Sx+2S+2x-3, y(x) = 1, g(x) = 0$$
Im contrast to the case $a=0$, the monotonicity constraint is no longer trivially satisfied. We obtain
$$y'(x) = \frac{(aB+B-1)(aS-1)}{(B(a-2x+1)+S(-2a+2x-1)+1)^2}$$
so that $y'(x)\geq0$ whenever either i) $B\leq 1/(1+a)$ and $S \leq 1/a$ or ii) $B\geq 1/(1+a)$ and $S \geq 1/a$. In case i) everything looks fine. In case ii), however, for instance for the parameters a = 5, B= 0.8, S = 0.3 I obtain that both $g$ and $h$ are strictly positive, which should not happen given the way I've set up the problem. Can anyone tell me what is going awry here?
Also, according to here, I should be able to include the monotonicty constraint using a Lagrange multiplier and the complementary slackness condition as I do above. However, including this constraint always yields that it is non-binding, which is obviously not true as we see in the above expression for $y'(x)$. Any guesses as why this does not work?
 A: I have been able to solve this by reverting to Optimal Control instead of Calculus of Variations.
Let (I've changed notation to move it towards the convention in optimal control theory)
$$F(x, u, t) = (2t- 1-a)x(t) \left(1+B\left[x(t)-1\right]\right)-(2x(t)+a)(1-t+a) \left(1+ S(t-a)\right)u(t) \;dt$$
so that $x(t)$ is the state and $u(t)$ the control where $u(t) = x'(t)$. Initial condition is $x(a)=0$ and free endpoint. Further, guess that the only constraint on the state which is binding is $x(t) \geq0$. The Lagrangian reads
$$L(x, u, t, \lambda, \eta) = F(x, u, t) + \lambda u + \eta x.$$
Now, assume that $B\leq 1/(1+a)$ and $S \leq \min\{1, (1-B(1+a))/a\}$. Standard sufficiency conditions (e.g. Seierstad+Sydsaeter1977, https://www.jstor.org/stable/2525753) are not applicable, as the Hamiltonian is not concave in the state. However, conditions as in Sorger (1989, https://www.sciencedirect.com/science/article/pii/0022053189900410) can be applied so that one can verify that the proposed solution in the question (with appropriate costate etc) solves the problem.
