the crazy fly
play

The crazy fly Timothy Bourke 1 , 2 Marc Pouzet 3 , 2 , 1 1. INRIA - PowerPoint PPT Presentation

The crazy fly Timothy Bourke 1 , 2 Marc Pouzet 3 , 2 , 1 1. INRIA Paris-Rocquencourt 2. cole normale suprieure (DI) 3. Universit Pierre et Marie Curie http://www.di.ens.fr/ParkasTeam.html Synchron 2013, November 19, Daghstuhl, Germany A


  1. The crazy fly Timothy Bourke 1 , 2 Marc Pouzet 3 , 2 , 1 1. INRIA Paris-Rocquencourt 2. École normale supérieure (DI) 3. Université Pierre et Marie Curie http://www.di.ens.fr/ParkasTeam.html Synchron 2013, November 19, Daghstuhl, Germany

  2. A very fast fly

  3. A very fast fly Girona 100km Barcelona

  4. A very fast fly Girona 100km car 1 = 50km/hr Barcelona

  5. A very fast fly Girona car 2 = -50km/hr 100km car 1 = 50km/hr Barcelona

  6. A very fast fly Girona car 2 = -50km/hr 100km fly = 80km/hr changes direction whenever it reaches a car car 1 = 50km/hr Barcelona

  7. A very fast fly The usual questions 1. How far has the fly traveled when the two cars meet? 2. How many zig-zags does the fly do during this period?

  8. A very fast fly The usual questions 1. How far has the fly traveled when the two cars meet? 2. How many zig-zags does the fly do during this period? Extra credit (Thanks to Rafel Cases and Jordi Cortadella) 1. Where will the fly be when the two cars reach their destinations?

  9. Simulink model Hit Crossing: fly − carA Zerocrossings Hit Crossing: fly − carB 80 simout >= 0 fly <= carA −u >= 0 carA fly >= carB travelled >= 0 carB carA <= carB 100 1 s >= 0 distance fly position fly <= carB −u >= 0 fly >= carA last(fly velocity) |u| 5 direction changes

  10. Simulink model Hit Crossing: fly − carA Zerocrossings Hit Crossing: fly − carB 80 simout >= 0 fly <= carA −u >= 0 carA fly >= carB travelled >= 0 carB carA <= carB 100 1 s >= 0 distance fly position fly <= carB −u >= 0 fly >= carA last(fly velocity) |u| 5 direction changes

  11. Simulink model Hit Crossing: fly − carA Zerocrossings Hit Crossing: fly − carB 80 simout >= 0 fly <= carA −u >= 0 carA fly >= carB travelled >= 0 carB carA <= carB 100 1 s >= 0 distance fly position fly <= carB −u >= 0 zigzags? fly >= carA last(fly velocity) |u| 5 direction changes

  12. Simulink Results Girona 100 80 distance (kilometres) 60 40 20 0 0 0.5 1 1.5 2 Barcelona time (hours) (Simulink R2012a: ode45, relative tolerance = 1e-3)

  13. Simulink model Hit Crossing: fly − carA Zerocrossings Hit Crossing: fly − carB 80 simout >= 0 fly <= carA −u >= 0 carA fly >= carB travelled >= 0 carB carA <= carB 100 1 s >= 0 distance fly position fly <= carB −u >= 0 zigzags fly >= carA last(fly velocity) |u| 5 direction changes

  14. Simulink model (with more zero-crossings) Hit Crossing: fly − carA Zerocrossings Hit Crossing: fly − carB 80 simout >= 0 fly <= carA −u >= 0 carA fly >= carB travelled >= 0 carB carA <= carB 100 1 s >= 0 distance fly position fly <= carB −u >= 0 zigzags? fly >= carA last(fly velocity) |u| 42 direction changes

  15. Simulink Results (with more zero-crossings) Girona 100 80 distance (kilometres) 60 40 20 0 0 0.5 1 1.5 2 Barcelona time (hours) (Simulink R2012a: ode45, relative tolerance = 1e-3)

  16. Simulink Results (with more zero-crossings) Girona 100 80 distance (kilometres) 60 distance (kilometres) 40 20 time (hours) [0.9999999999999:1.0000000000001] 0 0 0.5 1 1.5 2 Barcelona time (hours) (Simulink R2012a: ode45, relative tolerance = 1e-3)

  17. Simulink model (with more zero-crossings) Hit Crossing: fly − carA Zerocrossings Hit Crossing: fly − carB 80 simout >= 0 fly <= carA −u >= 0 carA fly >= carB travelled >= 0 carB carA <= carB 100 1 s >= 0 distance fly position fly <= carB −u >= 0 zigzags fly >= carA last(fly velocity) |u| 42 direction changes

  18. 42!

  19. Let us try Zélus...

  20. Zélus model 1 let barcelona = 0.0 let girona = 100.0 let fly_velocity = 80.0 let car_velocity = 50.0 let hybrid model () = (car1, car2, fly, zigzag, zeros) where rec der car1 = car_velocity init barcelona and der car2 = − . car_velocity init girona and der fly = dir ∗. fly_velocity init barcelona and automaton | Above → (∗ the line above the fly ∗) do car_above = car2 and car_below = car1 until up(car1 − . car2) then Below | Below → (∗ the line below ∗) do car_above = car1 and car_below = car2 done end and present up (car_below − . fly) | up(fly − . car_above) → (∗ the fly changes her direction ∗) (∗ when she crosses the line below or the line above ∗) do dir = − . (last dir) and zeros = last zeros + 1 and emit zigzag = () done and init dir = 1.0 and init zeros = 0

  21. Zélus model 1 let barcelona = 0.0 let girona = 100.0 let fly_velocity = 80.0 let car_velocity = 50.0 let hybrid model () = (car1, car2, fly, zigzag, zeros) where rec der car1 = car_velocity init barcelona and der car2 = − . car_velocity init girona and der fly = dir ∗. fly_velocity init barcelona and automaton | Above → (∗ the line above the fly ∗) do car_above = car2 and car_below = car1 until up(car1 − . car2) then Below | Below → (∗ the line below ∗) do car_above = car1 and car_below = car2 done end and present up (car_below − . fly) | up(fly − . car_above) → (∗ the fly changes her direction ∗) (∗ when she crosses the line below or the line above ∗) do dir = − . (last dir) and zeros = last zeros + 1 and emit zigzag = () done and init dir = 1.0 and init zeros = 0

  22. Zélus model 1 let barcelona = 0.0 let girona = 100.0 let fly_velocity = 80.0 let car_velocity = 50.0 zigzags=48 let hybrid model () = (car1, car2, fly, zigzag, zeros) where rec der car1 = car_velocity init barcelona and der car2 = − . car_velocity init girona and der fly = dir ∗. fly_velocity init barcelona and automaton | Above → (∗ the line above the fly ∗) do car_above = car2 and car_below = car1 until up(car1 − . car2) then Below | Below → (∗ the line below ∗) do car_above = car1 and car_below = car2 done end and present up (car_below − . fly) | up(fly − . car_above) → (∗ the fly changes her direction ∗) (∗ when she crosses the line below or the line above ∗) do dir = − . (last dir) and zeros = last zeros + 1 and emit zigzag = () done and init dir = 1.0 and init zeros = 0 1 zelus.di.ens.fr

  23. Zélus Results Girona 100 80 distance (kilometres) 60 40 20 0 0 0.5 1 1.5 2 Barcelona time (hours) (Sundials CVODE with our custom Illinois implementation)

  24. Zélus Results Girona 100 80 distance (kilometres) 60 distance (kilometres) 40 20 time (hours) [0.999999999999995:1.000000000000005] 0 0 0.5 1 1.5 2 Barcelona time (hours) (Sundials CVODE with our custom Illinois implementation)

  25. Concluding remarks Simulink 42 is the answer to “The Ultimate Question of Life, the Universe and Everything” 2 . Trop fort! Well... ◮ All very well, but the problem is mathematically not well posed. ◮ The system is not well defined at the instant the cars pass each other. Question: should a hybrid modeler ◮ statically detect and reject such programs? ◮ stop with an error at runtime? 3 (Thanks to Rafel Cases, Jordi Cortadella, and Gérard Berry.) 2 cf Douglas Adams, The Hitchhiker’s Guide to the Galaxy. 3 In the same way variable-step integration fails when reaching a minimal horizon.

Recommend


More recommend