Application of optimal control to semiconductor bandgap engineering