Studies on nonlinear optimal control for power systems: a constructive method for choosing weighting matrices