Warm Start Best Practices
Use Warm Start in MATLAB
quadprog solvers 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 using
optimwarmstart. Specify an initial point
options created with
optimoptions, including setting the
Algorithm option to
basic examples, see the
Return Warm Start Object and the
Return Warm Start Object. For a more
extensive example, see Warm 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 matrices
beq, the solver cannot use a warm start.
Modify a few rows of the
Amatrix. A warm start works most efficiently when the problem modifies only a few rows of the
Amatrix and corresponding
bvector, representing the constraint
A*x <= b. This modification includes adding or removing one or more constraints.
Modify a few elements of the
bvector. A warm start works most efficiently when the problem modifies only a few elements of the
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 to
Change the objective function. A warm start can be efficient when you change a matrix or vector representing the objective function—the
quadprog, or the
lsqlin. 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:
'MaxLinearInequalities'name-value arguments in
coder.varsize(MATLAB Coder) macros on all solver inputs that are matrices (
Aeq, and so on).
coder.varsize (MATLAB Coder)