Here is my approach to do it.
This is a simplified version of the simulated annealing approach to the pagination problem. At first we place one large advertisement for each page in a section. This is for the regulations we have to follow in our implementation.(Largest advertisement should be in the bottom right corner in odd page ,bottom left corner in the even page).
Based on previous step result initial solution can be generated by placing the remaining ads.
when we placing the ads to the dummy we use three steps.
- width and height fit ad
- width or height fit ad
- random ad which reduces the energy