Method and system for optimizing process parameters in an additive manufacturing process