Pricing American options by simulation using a stochastic mesh with optimized weights