Brute force search is the simplest method for solving unconstrained optimization problems. Brute force search is a very general problem solving technique that consists of systematically enumerating all possible candidates for the solution and checking whether each candidate satisfies the problem. Mathematically, we go through all possible values of in the domain of the function to enumerate all the possible values of . Then we pick the that corresponds to the smallest . In this method there can be more than one solution. One requirement of this method is that the domain should be enumerable. Hence this method is rarely used because it is not practical as we cannot enumerate infinitely infinite numbers. One way to simplify and solve this problem is through discretization. We can choose finitely many points from the given infinite domain. The drawback of discretization is that we likely get suboptimal solution when the points chosen do not contain the optimal answer. If the domain is unbounded , it is not clear how to choose the points for solving the problem. And the performance is very slow for small sized problems. Like for a problem with 8 variables to solve, the dimension of the problem is , where is the number of discrete points chosen for each dimension. Hence the problems become more and more complex exponentially. Apart from all this, brute force search is easy to understand.

` ````
```// An example univariate function.
val f: UnivariateRealFunction = object : AbstractUnivariateRealFunction() {
override fun evaluate(x: Double): Double {
return (x - 1) * (x - 1)
}
}
// Optimizes a univariate function using Brute Force Search method.
val solver = BruteForceMinimizer(
1e-15, // epsilon
20) // max number of iterations
val soln = solver.solve(f)
val xmin: Double = soln.minimizer()
val fmin: Double = f.evaluate(xmin)
println(String.format("f(%f) = %f", xmin, fmin))