Optimal control of rapid thermal annealing in a semiconductor process