Main Content

Optimization Convergence

What to do if the optimization does not get close to an acceptable solution?

  • If you are using pattern search, check that you have specified appropriate maximum and minimum values for all your tuned parameters or compensator elements. The pattern search method looks inside these bounds for a solution. When they are set to their default values of Inf and -Inf, the method searches within ±100% of the initial values of the parameters. In some cases this region is not large enough and changing the maximum and minimum values can expand the search region.

  • Your optimization problem might have local minima. Consider running one of the search-based methods first to get closer to an acceptable solution.

  • Reduce the number of tuned parameters and compensator elements by removing from the design variables or from the Compensators pane those parameters that you know only mildly influence the optimized responses. After you identify reasonable values for the key parameters, add the fixed parameters back to the tunable list and restart the optimization using these reasonable values as initial guesses.

  • The software may have encountered errors during the optimization. Review the errors to determine if you can make changes to improve the optimization results. Changes may require modifications to the model, requirements, or optimization settings.

    • In the Response Optimizer, the software creates a structure named EvalErrors in the Data area when the optimization completes with errors. Export this structure to the MATLAB® workspace and examine its contents at the command line. EvalErrors has two fields, Errors and DesignVars, containing the errors encountered during optimization and the corresponding design variable values. To reproduce a specific error, use sdo.setValueInModel to run the model using the design variables that correspond to the error.

    • At the command line, the second output of sdo.optimize, opt_info, is a structure that provides information regarding the optimization. opt_info.exitflag identifies the reason the optimization terminated. For more information regarding exit flags, see Exit Flags and Exit Messages.

Why does the optimization terminate before exceeding the maximum number of iterations, with a solution that does not satisfy all the constraints or design requirements?

  • It might not be possible to achieve your specifications. Try relaxing the constraints or design requirements that the response signals violate the most. After you find an acceptable solution to the relaxed problem, tighten some constraints again and restart the optimization.

  • The optimization might have converged to a local minimum that is not a feasible solution. Restart the optimization from a different initial guess and/or use one of the search-based methods to identify another local minimum that satisfies the constraints.

What to do if the optimization takes a long time to converge even though it is close to a solution?

  • In the Response Optimizer, click Stop to interrupt the optimization when you think the current optimized response signals are acceptable.

    When you use Optimization Based Tuning, click Stop Optimization in the Optimization tab of the Response Optimization dialog in the Control System Designer, when you think the current optimized response signals are acceptable.

  • If you use the gradient descent method, try restarting the optimization. Restarting resets the Hessian estimate and might speed up convergence.

  • Increase the convergence tolerances in the Optimization Options dialog to force earlier termination.

  • Relax some of the constraints or design requirements to increase the size of the feasibility region.

What to do if the response becomes unstable and does not recover?

While the optimization formulation has explicit safeguards against unstable or divergent response signals, the optimization can sometimes venture into an unstable region where simulation results become erratic and gradient methods fail to find a way back to the stable region. In these cases, you can try one of the following solutions:

  • Add or tighten the lower and upper bounds on compensator element and parameter values. Instability often occurs when you allow some parameter values to become too large.

  • Use a search-based method to find parameter values that stabilize the response signals and then start the gradient-based method using these initial values.

  • When optimizing responses in Control System Designer, you can try adding additional design requirements that achieve the same or similar goal. For example, in addition to a settling time design requirement on a step response plot, you could add a settling time design requirement on a root-locus plot that restricts the location of the real parts of the poles. By adding overlapping design requirements in this way, you can force the optimization to meet the requirements.