Hybrid Systems for Control and Optimisation