Implementing some blackbox optimization methods
- TestFunctions.py: Define test functions
- BOmethods.py: Define optimization method
- black_box_optimize.ipynb: notebook for visualization
- Random search
- Gaussian search
- Whale Optimization Algorithm (WOA)
- Particle Swam Optimization (PSO)
In each test function, needs definition of dimensions of inputs variables. And in optimization method, you need to set some parameters such as iteration, population, temperature, and so on. Let's consider following case:
Test function: Rastrigin
In this case, you write code such as:
test_obj = Rastrigin(ndim=10)
This means test_obj is a Rastrigin function with a dimension of 10.
Optimization method: particle swam optimization
In this case, you write code such as:
optimizer = PSO(test_obj, ndim=10, ranges = [[-5.12,5.12] for n in range(10)])
val, variable = optimizer.fit(iteration=1000, population=10, c1=0.5, c2=0.7)
Here, PSO's arguments are target test function, a dimension of search variables, and a range of each dimension. These arguments are the same in each optimization method. Once you can create an optimization object, then conduct optimization by .fit() with some arguments. In the above case, PSO is conducted with 1000 iteration and, in each iteration, 10 search agents are evaluated. And the found value and variables are returned as a list format (obtain these values per iteration).
For additional examples, please see the notebook.