Optimal Planning as Constraint Optimization