simulate and optimize