Probabilistic inference by linear optimization