Below is the dummy example, for which I expect the answer 0.8, but it outputs something close to 0:
from scipy.optimize import minimize, Bounds minimize(lambda ch