Text this: Optimal control in environmental systems and stability analysis