Relatively optimal control: a static piecewise-affine solution