Warm Start Best Practices
Use Warm Start in MATLAB
The lsqlin
and 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 x0
and
options created with optimoptions
, including setting the
Algorithm
option to 'active-set'
. For
basic examples, see the quadprog
Return Warm Start Object and the
lsqlin
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
Aeq
orbeq
, the solver cannot use a warm start.Modify a few rows of the
A
matrix. A warm start works most efficiently when the problem modifies only a few rows of theA
matrix and correspondingb
vector, representing the constraintA*x <= b
. This modification includes adding or removing one or more constraints.Modify a few elements of the
b
vector. A warm start works most efficiently when the problem modifies only a few elements of theb
vector.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
Inf
or –Inf
.Change the objective function. A warm start can be efficient when you change a matrix or vector representing the objective function—the
H
andf
arrays forquadprog
, or theC
andd
arrays 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
.Use
coder.varsize
(MATLAB Coder) macros on all solver inputs that are matrices (lb
,Aeq
, and so on).
See Also
lsqlin
| quadprog
| optimwarmstart
| coder.varsize
(MATLAB Coder)