# Grid Search

The optimisation parameters are linearly varied between their minimum and the maximum values in a predefined number of steps.

This method is strictly speaking not an optimisation method. This can be useful to investigate the parameter space before beginning an optimisation. Due to the required computational time, it is not generally recommended that this method be applied for problems containing more than two parameters.

During application of the grid search method, optimisation goals are evaluated at each of the specified grid points, and a fitness is assigned to each evaluation. Though this fitness has no effect on the selection of the ensuing parameter set, an optimum result on the predefined grid will be identified and the solutions at each of the grid points can be compared to evaluate their performance based on fitness.

## Error treatment and termination

Failure during re-evaluation and meshing (in the CADFEKO batch meshing tool or in PREFEKO) for a specific set of parameters is treated by writing an appropriate error message to the .log file before continuing with the next set of parameters in the grid.

The grid search method terminates naturally only when the maximum number of Feko solver runs has been reached. The number of solver runs can be computed based on the number of parameters and the number of steps per parameter.

Internally, a limit of 10 000 is placed on the maximum number of allowed solver runs. For 4 parameters this would mean a maximum of only 10 points per parameter (this indicates how quickly the algorithm can scale in terms of the number of required solver runs for multi-parameter problems.)

## The text log of the Grid search method

During an optimisation, OPTFEKO maintains a text log of the optimisation process in the project .log file. The structure of this file is primarily determined by the optimisation method.

**Section 1**: General information regarding the optimisation setup.

```
========================= L O G - FILE - OPTFEKO =========================
Version: 13.22 of 2007-05-08
Date: 2007-06-06 16:32:51
File: test
OPTIMISATION WITH Feko
=============== Optimisation variables ===============
No. Name Beg.value Minimum Maximum
1 zf0 2.000000000e+00 1.000000000e+00 1.000000000e+01
=============== Optimisation goals ===============
No. Name Expression
1 search1.goals.farfieldgoal1 farfieldgoal1
```

**Section 2**: Information regarding the grid search parameters.

```
=============== Optimisation method: GRID SEARCH ===============
No. Name Quantity Minimum Maximum Step
0 zf0 3 1.000000000e+00 1.000000000e+01 4.500000000e+00
```

**Section 3**: Information regarding the parameter values and goal values at each step.

```
=============== GRID SEARCH: Intermediate results ===============
No. zf0 search1.goals.f global goal
1 1.000000000e+00 2.267123373e-01 7.732876627e-01
2 5.500000000e+00 2.267123373e-01 7.732876627e-01
3 1.000000000e+01 2.267123373e-01 7.732876627e-01
```

**Section 4**: Information regarding the termination reason and best results found on the search grid.

```
=============== GRID SEARCH: Finished ===============
Optimisation finished (Maximum number of analyses reached: 3)
Optimum found for these parameters:
zf0 = 1.000000000e+01
Optimum aim function value (at no. 3): 7.732876627e-01
No. of the last analysis: 3
```