Added log file and update spatial allocation algorithm

Added log file and update spatial allocation algorithm