# Solving ODE boundary problem with additional conditions

I need to solve two point bondary problem for ODE. The solution of the problem itself is very easy. The real issue is that when solving arising non linear system of equations it always converges to one solution. However there exist two (physically justified) solutions. To illustrate this problem in detail consider the following case:

The discrete form of ODE is: $$y_{i+1}=y_i+\frac{\Delta x}{2} (a\cdot y_i^2+a\cdot y_{i+1}^2)$$ I want to find $a$ and $y_i$ values. As one can see in each node $x_i$ there are two possible solutions of this equation. Sometimes I want to pick the ones that are placed on the left of the minimum of the parabol, sometimes those on the right. It depends on the value of some additional function:

$$f(x_{i+1},y_{i+1})$$

that is computed in every step.

How do I formulate a problem? Should I look into optimization techniques?