Documentation Center |
Typically, at any given iteration of a pattern search, some of the mesh points might coincide with mesh points at previous iterations. By default, the pattern search recomputes the objective function at these mesh points even though it has already computed their values and found that they are not optimal. If computing the objective function takes a long time—say, several minutes—this can make the pattern search run significantly longer.
You can eliminate these redundant computations by using a cache, that is, by storing a history of the points that the pattern search has already visited. To do so, set Cache to On in Cache options. At each poll, the pattern search checks to see whether the current mesh point is within a specified tolerance, Tolerance, of a point in the cache. If so, the search does not compute the objective function for that point, but uses the cached function value and moves on to the next point.
Note When Cache is set to On, the pattern search might fail to identify a point in the current mesh that improves the objective function because it is within the specified tolerance of a point in the cache. As a result, the pattern search might run for more iterations with Cache set to On than with Cache set to Off. It is generally a good idea to keep the value of Tolerance very small, especially for highly nonlinear objective functions. |
For example, set up the problem described in Linearly Constrained Problem as follows:
Enter the following at the command line:
x0 = [2 1 0 9 1 0]; Aineq = [-8 7 3 -4 9 0]; bineq = 7; Aeq = [7 1 8 3 3 3; 5 0 -5 1 -5 8; -2 -6 7 1 1 9; 1 -1 2 -2 3 -3]; beq = [84 62 65 1];
Set up your problem in the Optimization app to match the following figures.
Run the optimization.
After the pattern search finishes, the plots appear as shown in the following figure.
Note that the total function count is 758.
Now, set Cache to On and run the example again. This time, the plots appear as shown in the following figure.
This time, the total function count is reduced to 734.