functional abstractions for simulated annealing
play

Functional Abstractions for Simulated Annealing Richard Senington - PowerPoint PPT Presentation

Introduction Monolithic State Implementations Functional Reactive Programming Conclusion Functional Abstractions for Simulated Annealing Richard Senington University Of Leeds School Of Computing Faculty of Engineering sc06r2s@leeds.ac.uk


  1. Introduction Monolithic State Implementations Functional Reactive Programming Conclusion Functional Abstractions for Simulated Annealing Richard Senington University Of Leeds School Of Computing Faculty of Engineering sc06r2s@leeds.ac.uk 5th May 2011 For York, May 2011 Richard Senington Functional Abstractions for Simulated Annealing

  2. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Introduction The Wider Project Investigating Local Search Meta-heuristics Finding combinators for describing them and combinators for combining/hybridising them Description, abstraction and implementation in Haskell This Mini-Project Simulated Annealing (SA) is a family of Meta-heuristics The variations on SA, provide illustration of wider issues Description, abstraction and implementation in Haskell Richard Senington Functional Abstractions for Simulated Annealing

  3. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Local Search Sub-Field of Operational Research Optimisation of Combinatorial Problems NP-Hard, cannot solve for large instances (Meta-)heuristics are often used for these large instances Exploring space to find good/better solutions Making decisions based upon limited/local information Heuristic methods to make decisions Richard Senington Functional Abstractions for Simulated Annealing

  4. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Meta-Heuristics Patterns, or Templates for Heuristics Work on most or many problems E.g. hill climbing, restart, genetic algorithms, simulated annealing Each type forms a family of variations on the theme Families can be hybridised Richard Senington Functional Abstractions for Simulated Annealing

  5. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Simulated Annealing 1 Initialise Seed Solution, Temperature & Random Numbers Richard Senington Functional Abstractions for Simulated Annealing

  6. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Simulated Annealing 1 Initialise Seed Solution, Temperature & Random Numbers 3 Permute Current Solution Richard Senington Functional Abstractions for Simulated Annealing

  7. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Simulated Annealing 1 Initialise Seed Solution, Temperature & Random Numbers 3 Permute Current Solution 4 Choose between old and new depends on temperature and random number stream Richard Senington Functional Abstractions for Simulated Annealing

  8. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Simulated Annealing 1 Initialise Seed Solution, Temperature & Random Numbers 3 Permute Current Solution 4 Choose between old and new depends on temperature and random number stream 7 Update Temperature using Strategy Richard Senington Functional Abstractions for Simulated Annealing

  9. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Simulated Annealing 1 Initialise Seed Solution, Temperature & Random Numbers 3 Permute Current Solution 4 Choose between old and new depends on temperature and random number stream 7 Update Temperature using Strategy 8 Choose to End or return to 3 Richard Senington Functional Abstractions for Simulated Annealing

  10. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Simulated Annealing 1 Initialise Seed Solution, Temperature & Random Numbers 2 Initialise Monitoring Data 3 Permute Current Solution 4 Choose between old and new depends on temperature and random number stream 7 Update Temperature using Strategy 8 Choose to End or return to 3 Richard Senington Functional Abstractions for Simulated Annealing

  11. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Simulated Annealing 1 Initialise Seed Solution, Temperature & Random Numbers 2 Initialise Monitoring Data 3 Permute Current Solution 4 Choose between old and new depends on temperature and random number stream 5 Update Monitoring Data 7 Update Temperature using Strategy 8 Choose to End or return to 3 Richard Senington Functional Abstractions for Simulated Annealing

  12. Introduction Local Search Monolithic State Implementations Meta-Heuristics Functional Reactive Programming Simulated Annealing Conclusion Simulated Annealing 1 Initialise Seed Solution, Temperature & Random Numbers 2 Initialise Monitoring Data 3 Permute Current Solution 4 Choose between old and new depends on temperature and random number stream 5 Update Monitoring Data 6 Should Temperature Strategy be Changed if so change it 7 Update Temperature using Strategy 8 Choose to End or return to 3 Richard Senington Functional Abstractions for Simulated Annealing

  13. Introduction Naive Monolithic State Implementations Type Classes & Records Functional Reactive Programming Functions For SA Conclusion Descriptions Of SA Monolithic State Type lots of pattern matching Very bad in terms of flexibility Few ways to generalise f ( a , b , c , d ) = ..... g ( a , b , c , d ) = ..... h ( a , b , c , d ) = ..... Richard Senington Functional Abstractions for Simulated Annealing

  14. Introduction Naive Monolithic State Implementations Type Classes & Records Functional Reactive Programming Functions For SA Conclusion Descriptions Of SA Type Classes & Records Getter and Setter functions in a Type class Functions can operate if data type has right accessor class class Ac a b where get :: a → b set :: a → b → a Richard Senington Functional Abstractions for Simulated Annealing

  15. Introduction Naive Monolithic State Implementations Type Classes & Records Functional Reactive Programming Functions For SA Conclusion Descriptions Of SA Type Classes & Records Can build these quickly using record access. instance Ac D Temp where get = getTemp set x t = x { getTemp = t } Richard Senington Functional Abstractions for Simulated Annealing

  16. Introduction Naive Monolithic State Implementations Type Classes & Records Functional Reactive Programming Functions For SA Conclusion Descriptions Of SA Some Useful Functions tempChange :: Ac a Temp ⇒ ( Temp → Temp ) → a → a varTempChange :: Ac a ( a → a ) ⇒ a → a updateTempStrat :: ( Ac a ( a → a ) , Ac a Monitor ) ⇒ ( Monitor → Bool ) → a → a updateMonitor :: ( Ac a Monitor , Ac a [ Sol ]) ⇒ ( Monitor → Sol → Monitor ) → a → a permute :: Ac a [ Sol ] ⇒ a → a choose :: ( Ac a [ Sol ] , Ac a Temp ) ⇒ a → a Richard Senington Functional Abstractions for Simulated Annealing

  17. Introduction Naive Monolithic State Implementations Type Classes & Records Functional Reactive Programming Functions For SA Conclusion Descriptions Of SA Function Composition sa :: ( Ac a Temp , Ac a [ Sol ]) ⇒ ( Temp → Temp ) → a → a sa f = ( tempChange f ) ◦ choose ◦ permute sa :: ( Ac a ( a → a ) , Ac a Monitor , Ac a Temp , Ac a [ Sol ]) ⇒ ( Monitor → Bool ) → ( Monitor → Sol → Monitor ) → a → a sa f g = varTempChange ◦ ( updateTempStrat f ) ◦ ( updateMonitor g ) ◦ choose ◦ permute Richard Senington Functional Abstractions for Simulated Annealing

  18. Introduction Naive Monolithic State Implementations Type Classes & Records Functional Reactive Programming Functions For SA Conclusion Descriptions Of SA Other Descriptions Arrow sa f = permute > > choose > > ( tempChange f ) Richard Senington Functional Abstractions for Simulated Annealing

  19. Introduction Naive Monolithic State Implementations Type Classes & Records Functional Reactive Programming Functions For SA Conclusion Descriptions Of SA Other Descriptions Arrow sa f = permute > > choose > > ( tempChange f ) No reason a monadic version could not be created Richard Senington Functional Abstractions for Simulated Annealing

  20. Introduction Naive Monolithic State Implementations Type Classes & Records Functional Reactive Programming Functions For SA Conclusion Descriptions Of SA Issues Lots of boiler plate code For each description function you choose, you often must; add data component explicitly to larger data structure implement accessors (the boiler plate) Quite imperative style Explain when and how to do things, not just what or relationships Feels like the data structure should be quite implicit in the code Where is the separation of search logic? Richard Senington Functional Abstractions for Simulated Annealing

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend