The Design of Optimal Pay-as-Bid Procurement Mechanisms