# Solve ODE with non-negative and maximization constraints

My task is to solve $$\eta_k\frac{d^2C_k}{dz}(z)=-e_k, k = 1,2,3$$

$$C_k\ge0$$

$$C_1(0)=0, C_2(0)=A, C_3(0)=0$$ $$C_1(L)=B, \frac{dC_2}{dz}(L)=0, \frac{dC_3}{dz}(L)=0$$ with $$e_1 = -\beta_1-\beta_3$$ $$e_2=-\beta_1-\beta_2$$ $$e_3=\beta_2-\beta_3$$

satisfying the constraints $$-e_k\le \frac{\eta_kC_k}{K_k+C_k}$$ where $$\eta_k, K_k$$ are some constants, where $$\beta_1,\beta_2,\beta_3$$ are such that $$\max 19\beta_1+0.5\beta_2+16\beta_3$$ is obtained.

I try to solve it by iterations, treating the ODE and the optimization as two separated steps. For every iteration,

1. First solve the ode to get some $$C_k$$;
2. then I fix $$C_k$$ and solve the linear programming to get $$e_k$$.

I repeat the above two steps to iteratively get next $$C_k$$, "$$e_k$$", and so on. My main problem is I do not know how to properly guarantee $$C_k\ge0$$ when solving the ODE. Any reference to papers or software packages that enforce such constraint is very much appreciated!

Without being able to guarantee that constraint, the above iterative process does not seem to converge and give weird oscillations.

• What is a "maximisation constraint"? – Rodrigo de Azevedo Apr 20 '19 at 23:49
• Try flipping it around and solve it as an ODE-coinstrained maximization problem which includes $C_k \ge 0$ among the constraints. – Mark L. Stone Apr 21 '19 at 21:23