next up previous
Next: Useful Tip 3 Up: Efficiency Considerations Previous: Useful Tip 1

Useful Tip 2

Be careful how you call your predicates. In the colour_countries/1 example in Section 13.4 the order in which countries are coloured makes a big difference to the speed of solution. You can test this by changing the order of clauses for ngb/2, which gives the neighbouring countries. The general principle is to select the (potentially) most difficult countries and colour them first. The ones likely to be most difficult are the ones with most neighbours. (See Bratko, ``Prolog Programming for AI'' for a detailed discussion of efficiency for the map colouring problem).



Dave Stuart Robertson
Tue Jul 7 10:44:26 BST 1998