From Checking to Inference: Actual Causality Computations as Optimization Problems