Control Of Piecewise Affine Systems Through Inverse Optimization