{"id":16717184,"url":"https://github.com/mseri/owlde-demo-icfp2019","last_synced_at":"2025-04-05T05:13:33.905Z","repository":{"id":69444367,"uuid":"202431556","full_name":"mseri/owlde-demo-icfp2019","owner":"mseri","description":"Demos for OwlDE ICFP 2019 talk","archived":false,"fork":false,"pushed_at":"2019-08-23T20:59:33.000Z","size":3108,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T13:12:15.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://icfp19.sigplan.org/details/ocaml-2019-papers/1/OwlDE-making-ODEs-first-class-Owl-citizens","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mseri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-14T21:56:45.000Z","updated_at":"2022-05-02T23:35:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"89fd64b9-fdc4-4141-aad4-15a6f9807e28","html_url":"https://github.com/mseri/owlde-demo-icfp2019","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mseri%2Fowlde-demo-icfp2019","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mseri%2Fowlde-demo-icfp2019/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mseri%2Fowlde-demo-icfp2019/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mseri%2Fowlde-demo-icfp2019/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mseri","download_url":"https://codeload.github.com/mseri/owlde-demo-icfp2019/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289430,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T21:30:35.618Z","updated_at":"2025-04-05T05:13:33.899Z","avatar_url":"https://github.com/mseri.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Demo material for ICFP 2019 talk\n\nYou can build all examples with\n```\n$ opam switch import opam-switches/PICK_ONE\n$ eval $(opam env)\n$ dune build @examples --profile=release\n```\n\nOn osx you may need to set `PKG_CONFIG_PATH=/usr/local/opt/openblas/lib/pkgconfig:/usr/local/Cellar/libffi/3.2.1/lib/pkgconfig/`, similarly on some linux distribution.\n\nNote that the opam switches do not contain `gp` nor `juplot`.\n\n\n# Standalone dynamic teaching material\n\nIt has become possible only recently to export jupyter notebooks to interactive html-based widgets by means of `nbinteract` and the `binder` API (see University of California, Berkeley, Technical Report No. UCB/EECS-2018-57).\nHowever in many courses, we would like to be able to share interactive demonstrations with the students by minimising (or completely removing) the visible code, and by providing something that works out of the box and does not require to install a Mathematica viewer, a python distribution, matlab, ...\n\nIf you run `dune build @jsdemo --profile=release` in a browser, you can see an example of this at work. Otherwise you can head to http://www.mseri.me/owlde-demo-icfp2019/ where an example of the generated files is published.\n\nThe javascript included in the page generates all the content and integrates the demonstration in the browser.\nIt can be provided to students as is, via a static websita, and does not require any specific knowledge or hardware to be used.\n\nThis ~~currently~~ requires ~~the development branch of~~ `owl-ode`~~, will be upstreamed in~~ version `0.2.0`.\n\n\n# N-Body problem with a large number of bodies\n\n\"Benchmark\" running for a system with 1000 randomly generated bodies for 200 iterations (unless differently specified).\n\n```\n# OCaml 4.08.1 + flambda\n$ dune build @example --profile=release\n$ bench _build/default/planets/bench.exe\nbenchmarking _build/default/planets/bench.exe\ntime                 8.340 s    (8.242 s .. 8.439 s)\n                     1.000 R²   (1.000 R² .. 1.000 R²)\nmean                 8.282 s    (8.261 s .. 8.312 s)\nstd dev              29.18 ms   (9.034 ms .. 38.84 ms)\nvariance introduced by outliers: 19% (moderately inflated)\n\n# OCaml 4.08.1\n$ bench _build/default/planets/bench.exe\nbenchmarking _build/default/planets/bench.exe\ntime                 10.07 s    (9.419 s .. 11.27 s)\n                     0.998 R²   (0.997 R² .. 1.000 R²)\nmean                 10.28 s    (10.08 s .. 10.52 s)\nstd dev              278.6 ms   (113.4 ms .. 352.8 ms)\nvariance introduced by outliers: 19% (moderately inflated)\n```\n\nThis is, of course, not a real benchmark. The implementations below are more aggressive in reusing memory and mutation, a feature that is planned but not yet supported by `OwlDE`.\n\n```\n$ bench \"python3 planets/bench_numpy.py\"\nbenchmarking python3 planets/bench_numpy.py\ntime                 9.609 s    (8.724 s .. 11.06 s)\n                     0.997 R²   (0.996 R² .. 1.000 R²)\nmean                 9.763 s    (9.461 s .. 10.19 s)\nstd dev              404.1 ms   (175.1 ms .. 521.6 ms)\nvariance introduced by outliers: 19% (moderately inflated)\n```\n\nPure python implementation, **only doing 10 iterations** (instead of the 200 of the runs above):\n```\n$ bench \"python3 planets/bench_pure.py\"\nbenchmarking python3 planets/bench_pure.py\ntime                 7.001 s    (6.913 s .. 7.176 s)\n                     1.000 R²   (1.000 R² .. 1.000 R²)\nmean                 7.303 s    (7.171 s .. 7.435 s)\nstd dev              169.9 ms   (83.88 ms .. 220.8 ms)\nvariance introduced by outliers: 19% (moderately inflated)\n```\n\nA pure OCaml implementation can severely outperform the others though, at least for these \"small\" dimensional examples.\n```\n# OCaml 4.08.1 + flambda\n$ bench _build/default/planets/bench_pure.exe\nbenchmarking _build/default/planets/bench_pure.exe\ntime                 998.3 ms   (971.2 ms .. 1.027 s)\n                     1.000 R²   (1.000 R² .. 1.000 R²)\nmean                 993.1 ms   (988.8 ms .. 999.3 ms)\nstd dev              5.854 ms   (2.102 ms .. 7.500 ms)\nvariance introduced by outliers: 19% (moderately inflated)\n\n# OCaml 4.08.1\n$ bench _build/default/planets/bench_pure.exe\nbenchmarking _build/default/planets/bench_pure.exe\ntime                 983.8 ms   (963.3 ms .. 1.013 s)\n                     1.000 R²   (1.000 R² .. 1.000 R²)\nmean                 1.004 s    (993.8 ms .. 1.013 s)\nstd dev              10.78 ms   (8.465 ms .. 11.81 ms)\nvariance introduced by outliers: 19% (moderately inflated)\n```\n\n# Mini benchmark using the three body problem\n\nThis is mini benchmark of different algorithms over an integration of the restricted three body problem.\n\nIn the RK45 case we are comparing an OCaml+Owl implementation with a C implementation, nevertheless the ocaml implementation is doing a good job and is almost as fast as the C implementation.\nIn the RK4 case we are comparing OCaml+Owl to python+numpy, in this case we are twice as fast.\nIn the LSODA case, the underlying FORTRAN library is the same but we are twice as slow. This will be investigated in the future.\n\n``` \n# OCaml 4.08.1 + flambda\n$ dune build @example --profile=release\n$ _build/default/minibench/minibench.exe \nEstimated testing time 30s (3 benchmarks x 10s). Change using '-quota'.\n┌───────┬──────────┬─────────────┬──────────┬──────────┬────────────┐\n│ Name  │ Time/Run │     mWd/Run │ mjWd/Run │ Prom/Run │ Percentage │\n├───────┼──────────┼─────────────┼──────────┼──────────┼────────────┤\n│ RK45  │  10.89ms │    766.50kw │   6.69kw │   5.91kw │      3.20% │\n│ RK4   │ 340.29ms │ 30_634.95kw │ 219.02kw │ 185.02kw │    100.00% │\n│ LSODA │  38.26ms │  4_997.82kw │ 223.20kw │ 189.20kw │     11.24% │\n└───────┴──────────┴─────────────┴──────────┴──────────┴────────────┘\nBenchmarks that take 1ns to 100ms can be estimated precisely. For more reliable \nestimates, redesign your benchmark to have a shorter execution time.\n\n# OCaml 4.08.1\n$ _build/default/minibench/minibench.exe\nEstimated testing time 30s (3 benchmarks x 10s). Change using '-quota'.\n┌───────┬──────────┬─────────────┬──────────┬──────────┬────────────┐\n│ Name  │ Time/Run │     mWd/Run │ mjWd/Run │ Prom/Run │ Percentage │\n├───────┼──────────┼─────────────┼──────────┼──────────┼────────────┤\n│ RK45  │  11.26ms │    778.47kw │   6.72kw │   5.94kw │      3.38% │\n│ RK4   │ 333.18ms │ 32_062.78kw │ 233.07kw │ 199.07kw │    100.00% │\n│ LSODA │  39.62ms │  5_204.75kw │ 224.58kw │ 190.58kw │     11.89% │\n└───────┴──────────┴─────────────┴──────────┴──────────┴────────────┘\nBenchmarks that take 1ns to 100ms can be estimated precisely. For more reliable \nestimates, redesign your benchmark to have a shorter execution time.\n\n# Python 3.7.4\n$ python3 minibench/minibench.py\nRK45:\t8.65 msec\nRK4:\t656 msec\nLSODA:\t19.2 msec\n```\n\n# Adjoint problem and Neural ODE\n\nBased on https://github.com/tachukao/adjoint_ode/\n\nTo replicate the demonstration, clone the repository and execute\n```sh\ndune exec adjoint_ode/examples/initial_value_problem.exe --profile=release\ngnuplot -e 'plot \"results/actual_ivp\"; pause -1'\n```\nor\n```sh\ndune exec adjoint_ode/examples/params_adjoint.exe --profile=release \ngnuplot -e 'plot \"results/target_pa\" using 1:2 w p ps .5 pt 7, \"results/target_pa\" using 1:3 w p ps .5 pt 7, \"results/actual_pa\" using 1:2 w p ps 1 pt 1, \"results/actual_pa\" using 1:3 w p ps 1 pt 1; pause -1'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmseri%2Fowlde-demo-icfp2019","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmseri%2Fowlde-demo-icfp2019","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmseri%2Fowlde-demo-icfp2019/lists"}