- Cost Function: We used custom cost function to show effectiveness of the model, but you can apply it to any cost function as you wish:
- Optimization Method: We used Gradient Descent for optimizing the cost function
- Of course there is better approaches exist, but our purpose is show the effectiveness of multi-start optimization
- If we take the gradient of the cost function w.r.t x and y
- Files: There are 6 files:
- parameters.py: Contains the parameters of the cost function. You can adjust it as you wish
- main.py: Contains the cost function, optimization method and gradient of the cost function. You can adjust it as you wish
- single.py: This is traditional single-start optimization. You can observe that it will probably stuck on local minima
- sequential.py: This uses multi-start technique implemented sequentially
- parallel-mpi.py: This uses parallel multi-start technique implemented with MPI library
- parallel-numba.py: This uses thread parallelization with Numba's OMP for multi-start implementation
- Make sure you have Python installed (preferably version 3.7 or later).
- Install the required dependencies using
pip3:pip3 install -r requirements.txt
You can execute these files using below commands:
python3 main.pypython3 single.pypython3 sequential.py <num of starting points>mpiexec -n <num of processes> python3 parallel_mpi.py <num of starting points>python3 parallel_numba.py <num of starting points> <num of threads>According to your file system, you may need to change the last line of the code.
- For Windows/Mac file systems, use
pio.write_html(fig, file='data/cost_function.html', auto_open=False)
- For Linux-based file systems, use
pio.write_html(fig, file='../data/cost_function.html', auto_open=False)