1 / 24

Mental Health and Wellness Resources

Access various resources for mental health and wellness, including helplines and counseling services. Take care of your mental well-being.

jkarsten
Download Presentation

Mental Health and Wellness Resources

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mental Health and Wellness Resources • Health and Wellness(416-978-8030) orKoffler Student Services. • Good 2 Talk(1-866-925-5454): 24 hour helpline • Other 24/7:Gerstein Centre and Toronto Distress Centre at 416-408-HELP (4357). CAMH’s Center for Addiction and Mental Health at 250 College Street. 

  2. M4 Iterative Algorithms, Continued

  3. What About Depots? Solution Representation Given N pick up / drop offs 2 Don’t have to store depots Could fill in closest depot to start/end later deliveryOrder = {0, 0, 0, 1, 3, 3, 1, 2, 2, 2} 1 3 2 0 3 2 0 1 1 0 Given Mcourier truck depots (intersections)

  4. Local Permutations • Representation deliveryOrder= {1, 3, 2, 1, 3, 0, 0, 2} 2 1 8 15 5 2 18 3 5 0 4 20 3 0 4 1 2 Total travel time = 81

  5. Local Permutations • Swap order of two deliveries? deliveryOrder= {1, 3, 2, 1, 3, 0, 0, 2} deliveryOrder= {1, 3, 2, 1, 3, 0, 2, 0} 2 1 8 15 14 5 2 18 23 3 5 0 4 20 7 3 0 4 1 2 Total travel time = 72

  6. 2-opt deliveryOrder= {1, 3, 2, 1, 3, 0, 0, 2} Delete two connections in path 2 1 2 3 0 3 0 1

  7. 2-opt • Reconnect connections differentlydeliveryOrder = {1, 3, 2, 1, 3, 0, 0, 2} • deliveryOrder = {1, 1 2,3,3, 0, 0, 2} • General: • Pick order for 3 sub-paths • Reverse any or allsub-paths • Check if legal 2 1 2 3 0 3 0 1

  8. 2-opt: Complexity • 2N-1 edges/connections between delivery locations • How many different 2-opts? • (2N-1) choose 2 edges we could cut • N = 100 199 * 198 / 2 = ~20,000 options • 3 sub-paths • Can order in 6 ways • 23 options to reverse or not 3 sub-paths • Can reverse or recombine in 48 ways • Total: ~1,000,000 2-opts • Fast code can try them all • If you find an improvement, can try all 2-opts again • Path has changed  a 2-opt that didn’t work before now might • Could make your own perturbation algorithm • Maybe 2-opts not best for traveling courier  many illegal • 3-opts?

  9. Heuristics Overview

  10. Exploring the Space Worse Travel Time Local Minima Global Minimum Better Solution Really a 200-dimensional space for N = 100. Huge!

  11. Pick a Random Order? Random Solution Worse Travel Time Better Solution Solution very poor  many more bad solutions than good in this space

  12. Multi-Start? Best of 4 random orders Worse Travel Time Better Solution A bit better, but still not very good Space very big, with mostly bad solution points

  13. Greedy Algorithm? Greedy Worse Travel Time Better Solution Much better! Still not locally optimal

  14. Local Permutation (Iterative Improvement)? Worse Travel Time Better Solution Search Local Space Finds Local Minimum!

  15. Combine with Multi-Start? Worse Travel Time Better Solution Yes – Find Many Local Minima Take Best One

  16. Local Permutations: Can Get Stuck Worse Travel Time Better Solution Can’t Get Out of Local Minimum

  17. More Powerful Local Permutations Worse Travel Time Better Solution Explore Larger Part of Space  Less Prone to Getting Stuck But More Exploration Means More CPU Time  Need Balance

  18. Hill Climbing? Worse Travel Time Better Solution Can Get You Unstuck from Local Minima But Watch CPU Time  Need Time to Improve Solution After It Gets Worse

  19. Heuristic 4: Hill Climbing • One way to get out of a rut • Change something! • Even if it looks like a bad idea at first • Hill climbing • Change delivery order • Even though it increases travel time • Good idea to save best solution first • Then try local perturbation around that new solution • Maybe you find something better! • If not, eventuallycan go back to saved solution • Lets you explore more options

  20. Simulated Annealing • Annealing metals • Cool slowly • Atoms gradually move to low energy state • Strong metal • Simulated annealing • Optimization framework that mimics annealing • Start with poor initial solution & high temperature (T) • Perturb solution (move atoms) • Most perturbations accepted when T high • Only good ones (reduce cost/energy) accepted when T approaches 0

  21. Simulated Annealing S = InitialSolution; C = Cost (S); // E.g. travel time T = high temperature; // big number while (solution changing) { Snew = perturb (S); Cnew = Cost (S); C = Cnew - C if (Cnew< C) { S = Snew; // Update solution C = Cnew; } T = reduceTemp (T); } How to perturb? Smaller perturbations as T drops? || random(0,1) < e-C/T ) { Fast update methods will let you evaluate more perturbations How quickly to reduce T?

  22. Time Limits & Using Multiple CPUs

  23. Managing the Time Limit • Can get better results with more CPU time • Multi-start: • Run algorithm again with a new starting point • Keep best • Iterative improvement • Keep looking for productive changes • But 30 s limit to return solution • For every problem • Regardless of city size & num intersections • How many starting points? • How many iterative perturbations? • Solution: check how much time has passed • End optimization just before time limit

  24. Time Limit Inside namespace chrono #include <chrono> // Time utilities #define TIME_LIMIT 30 // m4: 30 second time limit int main ( ) { auto startTime= std::chrono::high_resolution_clock::now(); bool timeOut = false; while (!timeOut) { myOptimizer (); auto currentTime = std::chrono::high_resolution_clock::now(); auto wallClock = std::chrono::duration_cast<chrono::duration<double>>( currentTime- startTime); // Keep optimizing until within 10% of time limit if (wallClock.count() > 0.9 * TIME_LIMIT) timeOut = true; } ... } Static member function: can call without an object Time difference Gives actual elapsed time no matter how many CPUs you are using Time difference in seconds

More Related