Stabilization of Dynamical Systems with the Help of Optimization Methods