Variational Inference and Learning of Piecewise-linear Dynamical Systems