A first-order numerical approach to switched-mode systems optimization. (August 2017)