The two well problem for piecewise affine maps