Grid Search in Matlab
Grid Search in Matlab
Andrii Parkhomenko
Spring 2017
Problem:
max f (x)
x∈Rn
Example 1
Problem:
max f (x) = x1 − 0.2x12 + x2 − 0.3x22
x∈R2
Construct an equally-spaced grid:
G = {(x1 , x2 )|x1 ∈ {0, 1, ..., 5}, x2 ∈ {0, 1, ..., 5}}
In MATLAB:
Solutions:
Finer grid
Non-equally spaced grid
In MATLAB:
Non-equally spaced grids are also useful when you don’t know the
neighborhood in which to look for maximizer x
“Curse of Dimensionality”
Typically we search on x ∈ Rn
When n is even moderately large, grid search requires too many
iterations:
I if n = 5, mi = 100 for i = 1, ..., 5, then we have to perform
1005 = 10, 000, 000, 000 iterations!
Solutions
Idea:
Start with a coarse grid
Refine as you approach to the solution
Example 2
Problem:
max f (x) = x1 − 0.2x12 + x2 − 0.3x22
x∈R2+
1 Start with:
G 0 = {(x1 , x2 )|x1 ∈ {0, 1, ..., 5}, x2 ∈ {0, 1, ..., 5}}
2 Obtain interim solution: x = (3, 2)
3 Refine the grid around the interim solution by halving the length of
the search interval:
In MATLAB:
After 4 refinements:
Solution algorithm finds x = (2.531, 1.656)
True maximum: x = (2.5, 1.667)
This level of precision requires about 37,000 iterations with simple grid
search, but only 144 with adaptive grid search!
Adaptive grid search faces the same problems as most other numerical
optimization methods when
objective function is not concave, discontinuous or non-differentiable
local optima exist
(see notes from previous class)
Further reading