Main Content

Warm Start Best Practices

Use Warm Start inMATLAB

Thelsqlinandquadprogsolvers support the use of a warm start object as an enhanced initial point. Warm start objects store algorithm-specific data from a previous solution to help avoid costly initialization between solves. Using a warm start can significantly increase performance between multiple solver calls. To use a warm start with a solver, you first create a warm start object usingoptimwarmstart. Specify an initial pointx0and options created withoptimoptions, including setting theAlgorithmoption to'active-set'. For basic examples, see thequadprogReturn Warm Start Objectand thelsqlinReturn Warm Start Object. For a more extensive example, seeWarm Start quadprog.

Use a warm start object when you solve a sequence of similar problems. For best performance, follow these guidelines.

  • Keep the same number of variables.You must have the same number of variables from one problem to the next. If the number of variables changes, solvers issue an error.

  • Do not change the equality constraints.If you change the equality constraint matricesAeqorbeq, the solver cannot use a warm start.

  • Modify a few rows of theAmatrix.A warm start works most efficiently when the problem modifies only a few rows of theAmatrix and correspondingbvector, representing the constraintA*x <= b. This modification includes adding or removing one or more constraints.

  • Modify a few elements of thebvector.A warm start works most efficiently when the problem modifies only a few elements of thebvector.

  • Change a few bound constraint.A warm start works most efficiently when the problem modifies only a few bounds by adding, removing, or changing entries in the upper bounds or lower bounds. This modification includes setting bounds toInfor –Inf.

  • Change the objective function.A warm start can be efficient when you change a matrix or vector representing the objective function—theHandfarrays forquadprog,或者是Canddarrays forlsqlin. However, large modifications to these arrays can result in a loss of efficiency, because the previous solution can be far away from the new solution.

The performance improvement of a warm start ultimately depends on problem geometry. For many problems, performance benefits improve as fewer changes are made between problems.

Use Warm Start in Code Generation with Static Memory Management

In addition to the guidelines for a MATLAB®warm start, follow these guidelines for code generation with static memory management:

  • Set the'MaxLinearEqualities'and'MaxLinearInequalities'name-value arguments inoptimwarmstart.

  • Usecoder.varsize(MATLAB Coder)macros on all solver inputs that are matrices (lb,Aeq, and so on).

See Also

|||(MATLAB Coder)

Related Topics