Examples
Here we describe how to download test date, and run some of the examples. Here, I assume you are installing the package directly from github, and not from Julia package manager.
Getting started
To get the source code, do
mkdir FrechetDist
cd FrechetDist
git clone git@github.com:sarielhp/FrechetDist.jl.git .The examples have their own environment, examples/Project.toml. To install its packages (this takes a few minutes), from the root of the repository:
julia --project=examples -e 'using Pkg; Pkg.instantiate()'Run the examples from the root of the repository, with julia --project=examples examples/<dir>/<script>.jl. Their results and pictures go to output/.
examples/demos/: small programs on one or two curves (curve files of x y lines).
| File | Contents |
|---|---|
examples/demos/minimal_example.jl | The Fréchet distance of two small fixed curves, and its morphing drawn (output/morphing.pdf) |
examples/demos/compare_two_curves.jl | Two curve files under the continuous Fréchet distance, the VE-retractable distance and FEVER_compute, with their times |
examples/demos/approx.jl | Approximations of the distance of two curve files (ratios 4, 1.1, 1.01), drawn (output/approx_*) |
examples/demos/morphing.jl | The continuous (exact and 1.1-approximate) and discrete morphings of two curve files, drawn with their leash (output/morphing.pdf) |
examples/demos/profile.jl | The leash along the optimal morphings from the first curve file to the others (output/profiles.png) |
examples/demos/animate.jl | An animation of the optimal morphing of two curves given by formulas (output/frechet.gif) |
examples/demos/show_polygon.jl, examples/demos/show_polygon_hierarchy.jl | Draw a curve, and its hierarchy of simplifications |
examples/demos/simplify_hausdorff.jl | A curve and its Hausdorff simplification, drawn |
examples/demos/search_in_dir.jl | The closest pairs among the .plt curves of a directory |
examples/webpage/: the gallery of examples (below).
| File | Contents |
|---|---|
examples/webpage/generate_examples.jl | Builds the gallery in output/gallery/ from the curves of examples/webpage/fr_examples.jl and the data in data/ |
examples/webpage/fr_examples.jl | The curves of the examples |
examples/webpage/player.js | Draws the animated morphings of the gallery in the browser, from small data files (no movies) |
examples/webpage/deploy_gallery.rb | Publishes output/gallery/ on GitHub Pages, in gallery/ of the gh-pages branch |
examples/benchmarks/: the scripts of Reproducing the benchmarks (the script reproduce.rb, frog/, cpp_compare/), and
| File | Contents |
|---|---|
examples/benchmarks/run_test_queries.rb | Runs the decider queries of one dataset (below) |
examples/benchmarks/run_queries_test.jl | The decider those queries run (frechet_decider_PID), and the query reader |
examples/benchmarks/direct_test.jl | Times the algorithms on two curve files: output/julia_results.csv and its LaTeX tables |
examples/benchmarks/table_latex.jl | The LaTeX tables of direct_test.jl |
examples/benchmarks/csv2latex.jl | A CSV file as a LaTeX table |
examples/datasets/: data for the examples.
| File | Contents |
|---|---|
examples/datasets/geolife_download/geolife_converter.py | The Geolife converter of Bringmann, Künnemann and Nusser, modified to keep the trajectories that leave Beijing (data/geolife) |
examples/datasets/movebank_splice.jl | The GPS tracks of a Movebank CSV, split into curves: the pigeons (data/pigeons) and the white storks (data/birds) |
examples/datasets/csv2plt.jl, examples/datasets/flight_csv2plt.jl | CSV files of points, or of flights (latitude, longitude), to .plt curves |
examples/common/: examples/common/graphics.jl, the drawing code the demos and the web page share, and examples/common/tmp_space.jl, where their temporary files go.
examples/Project.toml is the environment of all of them.
ruby examples/run_all.rb runs every example and script, of examples/ and example_higher/, on small inputs and on a virtual display (xvfb-run), so no window opens on the desktop. It reports the scripts that fail or that write anything outside output/ and example_higher/output/, and removes the files the runs add there. --long adds the slow runs (every characters query, the comparison with the C++ code), --display runs them on the current display instead, --list lists them, and --help describes the options. Several cases need the data of reproduce.rb setup.
Getting the data
ruby examples/benchmarks/reproduce.rb setup downloads and converts the data of the benchmarks (see Reproducing the benchmarks); ruby examples/benchmarks/reproduce.rb setup decider only the curves and queries of Bringmann, Künnemann and Nusser, into raw/frechet/. The web page also reads data/characters and data/birds, which ruby examples/benchmarks/reproduce.rb setup webpage makes (the setup of all the benchmarks does too).
Testing the data
We use test data available from earlier project, which in turn was inspired (or is from) sigspatial competition. In any case, examples/benchmarks/run_test_queries.rb runs the queries of one dataset (characters, geolife or sigspatial; geolife takes several hours), on their curves and query files in raw/frechet/:
ruby examples/benchmarks/run_test_queries.rb characters
ruby examples/benchmarks/run_test_queries.rb geolife
ruby examples/benchmarks/run_test_queries.rb sigspatialThe queries run on one thread; add --threads to run them on all threads, which is ***much*** faster. The list of query files and the results go to output/queries/.
The gallery of examples
The gallery shows pairs of curves with their distances, free-space diagrams, and their morphings animated in the browser. Each example, and the index, gives the exact distance and the times of frechet_c_compute_exact and frechet_c_compute. On example 35, two zig-zags of 15 and 16 vertices, frechet_c_compute takes many minutes and gigabytes of memory (its refinement keeps growing the curves), against under a millisecond for frechet_c_compute_exact, so its page has only the exact distance, as a record of the limits of that refinement. generate_examples.jl full35 builds its full page; this is not recommended, as it takes well over half an hour. To build the gallery and publish it:
ruby examples/benchmarks/reproduce.rb setup webpage # the curves of data/
julia --project=examples examples/webpage/generate_examples.jl
ruby examples/webpage/deploy_gallery.rb # shows what would change
ruby examples/webpage/deploy_gallery.rb --push # publishes itThe generator writes output/gallery/ and skips the examples whose directory exists (remove output/gallery/ to rebuild all of them). The animations are drawn by player.js from the curves and the morphing (no movies), the refinement steps are PNG frames, the PNG files are compressed with pngquant when it is installed, and the pages have no PDF files, so the gallery stays small. The deploy script copies it to gallery/ of the gh-pages branch, which the docs deployment leaves alone; it refuses a gallery over 100 MB.
For a minimal example...
See the test/ subdirectory.
High-dimensional curves
example_higher/ holds the high-dimensional experiments: freeway traffic (ℝ^963), video (ℝ^19200) and hydraulic sensor (ℝ^6000) curves, the scripts that run FrechetDist and Fred on them, and an independent checker. See Reproducing the results.