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?