Computational method for optimal control of switched systems with input and state constraints. (November 2017)