65
Implementing Geometric Algorithms for Real-World Applications With and Without EGC-Support Stefan Huber 1 Martin Held 2 1 Institute of Science and Technology Austria 2 FB Computerwissenschaften Universit¨ at Salzburg, Austria GCC 2013, Rio de Janeiro, Brazil June 17–20 Stefan Huber , Martin Held: Geometric Algorithms for Real-World Applications 1 of 29

Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Implementing Geometric Algorithmsfor Real-World Applications

With and Without EGC-Support

Stefan Huber1 Martin Held2

1Institute of Science and Technology Austria

2FB ComputerwissenschaftenUniversitat Salzburg, Austria

GCC 2013, Rio de Janeiro, BrazilJune 17–20

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications 1 of 29

Page 2: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Outline

1. Three industrial codes and their design principles:

FIST VRONI STALGO

2. Adding CORE and MPFR backend.

3. Open problems and future directions.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications 2 of 29

Page 3: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

FIST

I Triangulates polygons with holes in 2D and 3D,I based on ear-clipping andI multi-level geometric hashing to speed up computation [Held, 2001a].

I HandlesI degenerate input,

I self-overlapping input,I self-intersecting input.

I No Delaunay triangulation, but heuristics to generate “decent” triangles.

I Typical applications in industry: triangulation of (very) large GIS datasets,triangulation of “planar” faces of 3D models.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 3 of 29

Page 4: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

FIST

I Triangulates polygons with holes in 2D and 3D,I based on ear-clipping andI multi-level geometric hashing to speed up computation [Held, 2001a].

I HandlesI degenerate input,I self-overlapping input,

I self-intersecting input.

I No Delaunay triangulation, but heuristics to generate “decent” triangles.

I Typical applications in industry: triangulation of (very) large GIS datasets,triangulation of “planar” faces of 3D models.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 3 of 29

Page 5: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

FIST

I Triangulates polygons with holes in 2D and 3D,I based on ear-clipping andI multi-level geometric hashing to speed up computation [Held, 2001a].

I HandlesI degenerate input,I self-overlapping input,I self-intersecting input.

I No Delaunay triangulation, but heuristics to generate “decent” triangles.

I Typical applications in industry: triangulation of (very) large GIS datasets,triangulation of “planar” faces of 3D models.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 3 of 29

Page 6: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

FIST

I Triangulates polygons with holes in 2D and 3D,I based on ear-clipping andI multi-level geometric hashing to speed up computation [Held, 2001a].

I HandlesI degenerate input,I self-overlapping input,I self-intersecting input.

I No Delaunay triangulation, but heuristics to generate “decent” triangles.

I Typical applications in industry: triangulation of (very) large GIS datasets,triangulation of “planar” faces of 3D models.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 3 of 29

Page 7: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Vroni/ArcVroni

I Computes Voronoi diagrams ofI points, straight-line segments and circular arcs,I based on randomized incremental insertion and a topology-oriented approach

[Held and Huber, 2009, Held, 2001b].

I Also computesI (weighted) medial axis,

I offset curves, andI maximum-inscribed

circle.

I Typical applications in industry: generation of tool paths (e.g., for machiningor sintering), generation of buffers in GIS applications.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 4 of 29

Page 8: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Vroni/ArcVroni

I Computes Voronoi diagrams ofI points, straight-line segments and circular arcs,I based on randomized incremental insertion and a topology-oriented approach

[Held and Huber, 2009, Held, 2001b].

I Also computesI (weighted) medial axis,

I offset curves, andI maximum-inscribed

circle.

I Typical applications in industry: generation of tool paths (e.g., for machiningor sintering), generation of buffers in GIS applications.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 4 of 29

Page 9: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Vroni/ArcVroni

I Computes Voronoi diagrams ofI points, straight-line segments and circular arcs,I based on randomized incremental insertion and a topology-oriented approach

[Held and Huber, 2009, Held, 2001b].

I Also computesI (weighted) medial axis,I offset curves, andI maximum-inscribed

circle.

I Typical applications in industry: generation of tool paths (e.g., for machiningor sintering), generation of buffers in GIS applications.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 4 of 29

Page 10: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Vroni/ArcVroni

I Computes Voronoi diagrams ofI points, straight-line segments and circular arcs,I based on randomized incremental insertion and a topology-oriented approach

[Held and Huber, 2009, Held, 2001b].

I Also computesI (weighted) medial axis,I offset curves, andI maximum-inscribed

circle.

I Typical applications in industry: generation of tool paths (e.g., for machiningor sintering), generation of buffers in GIS applications.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 4 of 29

Page 11: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Stalgo

I Computing straight skeletons ofI planar straight-line graphs,I based on a refined wavefront propagation using the motorcycle graph

[Huber and Held, 2012, Huber, 2012].

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 5 of 29

Page 12: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Stalgo

I Computing straight skeletons ofI planar straight-line graphs,I based on a refined wavefront propagation using the motorcycle graph

[Huber and Held, 2012, Huber, 2012].

Also computes

I Mitered offset curves, and

I roof models resp. terrains.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 5 of 29

Page 13: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Stalgo

I Computing straight skeletons ofI planar straight-line graphs,I based on a refined wavefront propagation using the motorcycle graph

[Huber and Held, 2012, Huber, 2012].

Also computes

I Mitered offset curves, and

I roof models resp. terrains.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 5 of 29

Page 14: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Success stories

I More than 100 commercial licenses world-wide for FIST, Vroni/ArcVroni andSTALGO.

I A few hundred Euros (for ArcVroni) up to a few thousand Euros/Dollars(FIST, VRONI, STALGO).

I “Industrial-strength” implementations achieved:I Only a handful of bug reports in more than ten yearsI of heavy commercial and academic use, and lots of satisfied customers.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 6 of 29

Page 15: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Success stories

I More than 100 commercial licenses world-wide for FIST, Vroni/ArcVroni andSTALGO.

I A few hundred Euros (for ArcVroni) up to a few thousand Euros/Dollars(FIST, VRONI, STALGO).

I “Industrial-strength” implementations achieved:I Only a handful of bug reports in more than ten yearsI of heavy commercial and academic use, and lots of satisfied customers.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 6 of 29

Page 16: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Datasets from industry

I Real-world data often means no quality at all:I brute-force simplifications / approximations of data,I data cleaned up manually and “visually”,I etc.

I As a consequence:I All sorts of degeneracies, self-intersections, tiny gaps, etc.

General position must not be assumed.

Data sizes:

I From a few thousand segments/arcs in a machining application

I to a few million segments in a GIS application.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 7 of 29

Page 17: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Efficiency requirements

I From real-time map generation on a smart phone

I to minutes of CPU time allowed on some high-end machine.

I In general, linear space complexity and a close-to-linear time complexity isexpected.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 8 of 29

Page 18: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Use alternative computations

I Algebraically equivalent terms need not be equally reliable on fp arithmetic.

I Check whether a computation becomes instable, and use an alternativeapproach.

I Sample application: Compute the bisector b between f and g .

g

f

b

p u

v

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 9 of 29

Page 19: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Use alternative computations

I Algebraically equivalent terms need not be equally reliable on fp arithmetic.

I Check whether a computation becomes instable, and use an alternativeapproach.

I Sample application: Compute the bisector b between f and g .

g

f

b

p u

v

g

f

b

p

u

v

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 9 of 29

Page 20: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Topology-oriented approach

I First used by Sugihara et alii [1992, 2000].

I Define topological criteria that the output has to meet.I Use fp-computations to choose among different topological set-ups if two or

more set-ups fulfill all criteria.

I Sample application:I Incremental insertion of

a point into a Voronoidiagram.

I The portion of theVoronoi diagram to bedeleted forms a tree.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 10 of 29

Page 21: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Topology-oriented approach

I First used by Sugihara et alii [1992, 2000].

I Define topological criteria that the output has to meet.I Use fp-computations to choose among different topological set-ups if two or

more set-ups fulfill all criteria.

I Sample application:I Incremental insertion of

a point into a Voronoidiagram.

I The portion of theVoronoi diagram to bedeleted forms a tree.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 10 of 29

Page 22: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Topology-oriented approach

I First used by Sugihara et alii [1992, 2000].

I Define topological criteria that the output has to meet.I Use fp-computations to choose among different topological set-ups if two or

more set-ups fulfill all criteria.

I Sample application:I Incremental insertion of

a point into a Voronoidiagram.

I The portion of theVoronoi diagram to bedeleted forms a tree.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 10 of 29

Page 23: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Topology-oriented approach

I First used by Sugihara et alii [1992, 2000].

I Define topological criteria that the output has to meet.I Use fp-computations to choose among different topological set-ups if two or

more set-ups fulfill all criteria.

I Sample application:I Incremental insertion of

a point into a Voronoidiagram.

I The portion of theVoronoi diagram to bedeleted forms a tree.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 10 of 29

Page 24: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Topology-oriented approach

I First used by Sugihara et alii [1992, 2000].

I Define topological criteria that the output has to meet.I Use fp-computations to choose among different topological set-ups if two or

more set-ups fulfill all criteria.

I Sample application:I Incremental insertion of

a point into a Voronoidiagram.

I The portion of theVoronoi diagram to bedeleted forms a tree.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 10 of 29

Page 25: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Epsilon relaxation

1 TypicalComputationalUnit()

2 begin3 ε ← εmin // Set ε to maximum precision

4 while ε ≤ εmax do5 result ← ComputeUnit(ε) // Compute some data

6 if CheckResult(result, ε) then // Topological/numerical checks

7 return result8 else9 ComputeUnitReset()

10 ε ← 10 · ε // Relaxation of epsilon

11 end

12 end13 if not CheckInputLocally() then // Is input sound?

14 CleanInputLocally() // Fix problems in the input

15 RestartComputationGlobally() // Restart from scratch

16 else17 return ComputeUnitDesperateMode() // Time to hope for the best

18 end

19 end

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 11 of 29

Page 26: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Avoiding geometric decisions

extendedwavefront

I Simulation of wavefront propagation, DCEL

I Straight-forward: remove e1, e2, v1, v2

I Add v and relink it with v ′1, v′2.

I Involves geometric decisions! And multiple events can occur simultaneously.

I Better: remove v1, v2 but repot e1, e2 to v .I No geometric decisions involved.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 12 of 29

Page 27: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Avoiding geometric decisions

I Simulation of wavefront propagation, DCEL

I Straight-forward: remove e1, e2, v1, v2

I Add v and relink it with v ′1, v′2.

I Involves geometric decisions! And multiple events can occur simultaneously.

I Better: remove v1, v2 but repot e1, e2 to v .I No geometric decisions involved.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 12 of 29

Page 28: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Avoiding geometric decisions

v1 v2

v ′1

v ′2

e1e2

I Simulation of wavefront propagation, DCEL

I Straight-forward: remove e1, e2, v1, v2

I Add v and relink it with v ′1, v′2.

I Involves geometric decisions! And multiple events can occur simultaneously.

I Better: remove v1, v2 but repot e1, e2 to v .I No geometric decisions involved.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 12 of 29

Page 29: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Avoiding geometric decisions

v1 v2

v

v ′1

v ′2

e1e2

I Simulation of wavefront propagation, DCEL

I Straight-forward: remove e1, e2, v1, v2

I Add v and relink it with v ′1, v′2.

I Involves geometric decisions! And multiple events can occur simultaneously.

I Better: remove v1, v2 but repot e1, e2 to v .I No geometric decisions involved.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 12 of 29

Page 30: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Engineering principles: Avoiding geometric decisions

v1 v2

v

v ′1

v ′2

e1e2

I Simulation of wavefront propagation, DCEL

I Straight-forward: remove e1, e2, v1, v2

I Add v and relink it with v ′1, v′2.

I Involves geometric decisions! And multiple events can occur simultaneously.

I Better: remove v1, v2 but repot e1, e2 to v .I No geometric decisions involved.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Geometric codes in industry 12 of 29

Page 31: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Adding CORE backend

Canonical adaptions:

I Set EPS to 0.

I Migrate fabs(expr) < EPS to fabs(expr) <= EPS.

Migrating C to C++:

I printf("%f", val); scanf("%f", &val);

I malloc, free → new, delete

More subtle problems encountered:

I Expr::intValue() rounds “inexact”:I Rounds up or down, depending on expression tree.I Decision based on finitely many bits.I Work-around: migrate intValue() to floor().

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 13 of 29

Page 32: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Adding CORE backend

Canonical adaptions:

I Set EPS to 0.

I Migrate fabs(expr) < EPS to fabs(expr) <= EPS.

Migrating C to C++:

I printf("%f", val); scanf("%f", &val);

I malloc, free → new, delete

More subtle problems encountered:

I Expr::intValue() rounds “inexact”:I Rounds up or down, depending on expression tree.I Decision based on finitely many bits.I Work-around: migrate intValue() to floor().

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 13 of 29

Page 33: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Adding CORE backend

Canonical adaptions:

I Set EPS to 0.

I Migrate fabs(expr) < EPS to fabs(expr) <= EPS.

Migrating C to C++:

I printf("%f", val); scanf("%f", &val);

I malloc, free → new, delete

More subtle problems encountered:

I Expr::intValue() rounds “inexact”:I Rounds up or down, depending on expression tree.I Decision based on finitely many bits.I Work-around: migrate intValue() to floor().

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 13 of 29

Page 34: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Adding CORE backend

Summary:

I FIST works with CORE.

I Vroni and Stalgo could not be executed.I Willi Mann’s bug fixes and performance patches in CORE-2.1.I Still, several CPU-minutes did not suffice to determine sign of a single

expression stemming from simple inputs.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 14 of 29

Page 35: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Adding MPFR backend

Canonical adaptions:

I EPS needs to depend on precision.I We used a heuristic formula:

EPS := εfp · 2−100·(√

prec/53−1),

where εfp is the former machine-precision EPS.

Practical work required:

I MPFR is not shipped with a C++ wrapper.I Code that generates wrapper classes with the required operators overloaded.

I Partial C to C++ migration, as for CORE.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 15 of 29

Page 36: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Adding MPFR backend

Canonical adaptions:

I EPS needs to depend on precision.I We used a heuristic formula:

EPS := εfp · 2−100·(√

prec/53−1),

where εfp is the former machine-precision EPS.

Practical work required:

I MPFR is not shipped with a C++ wrapper.I Code that generates wrapper classes with the required operators overloaded.

I Partial C to C++ migration, as for CORE.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 15 of 29

Page 37: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Experimental results: FIST

I 21175 polygons (w/ and w/o holes).

I Six arithmetic configurations:I fistFp, fistShew, fistCore, fistMp{53, 212, 1000}

I Conclusion:I Shewchuck’s predicates have negligible impact on speed.I fistMP* about 24× slower than fistFp.I fistCore about 60× slower than fistFp.

10−8

10−7

10−6

10−5

10−4

103 104 105 106

0.08 to 0.20 · n log n µs

103 104 105 106

1.5 to 8 · n log n µs

103 104 105 106

4 to 10 · n log n µs

Figure: Runtime per seconds divided by n log n. fistFp, fistMp212, fistCore.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 16 of 29

Page 38: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Experimental results: FIST

I 21175 polygons (w/ and w/o holes).

I Six arithmetic configurations:I fistFp, fistShew, fistCore, fistMp{53, 212, 1000}

I Conclusion:I Shewchuck’s predicates have negligible impact on speed.I fistMP* about 24× slower than fistFp.I fistCore about 60× slower than fistFp.

10−8

10−7

10−6

10−5

10−4

103 104 105 106

0.08 to 0.20 · n log n µs

103 104 105 106

1.5 to 8 · n log n µs

103 104 105 106

4 to 10 · n log n µs

Figure: Runtime per seconds divided by n log n. fistFp, fistMp212, fistCore.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 16 of 29

Page 39: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Experimental results: FIST

Correctness of inexact configurations?

I Verification code:I Bentley-Ottmann, implemented with exact mpq_t from GMP.

I Take 0.1 as closest fp-number using atof().

I No errors found!

Conclusion: Non-exactness no practical issue in pure fp applications.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 17 of 29

Page 40: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Experimental results: Voronoi diagrams

I Vroni versus CGAL.

I 18787 polygons (< 100000 vertices)

I Six configurations:I vroniFp, vroniMp{53, 212, 1000}, cgvdFpI cgvdEx: CORE-based predicate kernel

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 18 of 29

Page 41: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Experimental results: Voronoi diagrams

I Conclusion:I vroniMp* about 50–70× slower than vroniFp.I cgvd* about 50–80× slower than vroniFp.I cgvdFp only 1.5× faster than cgvdEx.

I Crashed on 937 datasets due to fp-exception.I On average, cgvdEx slightly faster than vroniMp*.

I cgvdEx timings vary by a factor of 20.I A few cgvdEx results were numerically clearly wrong.

10−7

10−6

10−5

10−4

10−3

10−2

102 103 104 105

0.5 to 1.6 · n log n µs

102 103 104 105

25 to 80 · n log n µs

102 103 104 105

9 to 170 · n log n µs

Figure: Runtime per seconds divided by n log n. vroniFp, vroniMp212, cgvdEx.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 19 of 29

Page 42: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Experimental results: Voronoi diagrams

Numerical precision of Voronoi nodes:

I Deviation: difference in the distances of a node to its defining sites.

I Violation: another site is closer to a node than defining sites.

10−16

10−13

10−10

10−7

10−4

10−1

20000 40000 60000 80000

cgvdEx

vroniFp

vroniMp212

10−16

10−13

10−10

10−7

10−4

10−1

2000 4000 6000 8000 10000

cgvdEx

vroniFp

vroniMp212

Figure: Left: Deviation. Right: violation

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications MPFR- and CORE-support 20 of 29

Page 43: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

EGC: A simple case study

A function test(N):

I Generate a shuffled array A with elements ±k1, . . . ,±kN , with ki beingrandom integers.

I We build the sum S over A.

I How long does S == Expr(0) take?

Results depend on the set-up:

I Are filters working?

I How is the sum built?I Naive for-loop, orI in a balanced fashion.

The “default case”: with filters, naive for-loop.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications EGC: a simple case study 21 of 29

Page 44: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

EGC: A simple case study

A function test(N):

I Generate a shuffled array A with elements ±k1, . . . ,±kN , with ki beingrandom integers.

I We build the sum S over A.

I How long does S == Expr(0) take?

Results depend on the set-up:

I Are filters working?

I How is the sum built?I Naive for-loop, orI in a balanced fashion.

The “default case”: with filters, naive for-loop.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications EGC: a simple case study 21 of 29

Page 45: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

I CORE, naive sum:I O(n2) timeI w/ filter: O(n2) mem

I LEDA: virtually zeroruntime

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications EGC: a simple case study 22 of 29

Page 46: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

EGC: a simple case study

What if we put stress on the filters?

I Add to the array A five times sqrt(2) and -sqrt(2).

I How long will S == Expr(0) take now?

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications EGC: a simple case study 23 of 29

Page 47: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

I naive sum:I O(n2) timeI O(n2) mem

I balanced sum:I O(1) or O(n) timeI O(n) memI filters have more

impact

Disclaimer: Of course, these

expressions will unlikely occur in

real-world software.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications EGC: a simple case study 24 of 29

Page 48: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

EGC/MPFR: Conclusion

I EGC software can be fast, see Shewchuck’s Triangle.

I Height-balancing expression trees might reduce the costs for time and spacesignificantly.

I We might observe different complexities in terms of big-Oh.I On- and offline structural optimization strategies for expression trees are worth

to be investigated.

I Adding EGC support to non-trivial software a-posteriori can be extremelychallenging.

I Different programming styles due to focus on either numerical accuracy orawareness of expression trees.

I EGC-aware programming right from the start is necessary.

I Adding MPFR support is straight-forwardI MPFR boosts numerical accuracy.I MPFR helps to distinguish numerical errors from logical bugs.I Precision-elevation instead of epsilon-relaxation?

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications EGC: a simple case study 25 of 29

Page 49: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

EGC/MPFR: Conclusion

I EGC software can be fast, see Shewchuck’s Triangle.

I Height-balancing expression trees might reduce the costs for time and spacesignificantly.

I We might observe different complexities in terms of big-Oh.I On- and offline structural optimization strategies for expression trees are worth

to be investigated.

I Adding EGC support to non-trivial software a-posteriori can be extremelychallenging.

I Different programming styles due to focus on either numerical accuracy orawareness of expression trees.

I EGC-aware programming right from the start is necessary.

I Adding MPFR support is straight-forwardI MPFR boosts numerical accuracy.I MPFR helps to distinguish numerical errors from logical bugs.I Precision-elevation instead of epsilon-relaxation?

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications EGC: a simple case study 25 of 29

Page 50: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

EGC/MPFR: Conclusion

I EGC software can be fast, see Shewchuck’s Triangle.

I Height-balancing expression trees might reduce the costs for time and spacesignificantly.

I We might observe different complexities in terms of big-Oh.I On- and offline structural optimization strategies for expression trees are worth

to be investigated.

I Adding EGC support to non-trivial software a-posteriori can be extremelychallenging.

I Different programming styles due to focus on either numerical accuracy orawareness of expression trees.

I EGC-aware programming right from the start is necessary.

I Adding MPFR support is straight-forwardI MPFR boosts numerical accuracy.I MPFR helps to distinguish numerical errors from logical bugs.I Precision-elevation instead of epsilon-relaxation?

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications EGC: a simple case study 25 of 29

Page 51: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

EGC/MPFR: Conclusion

I EGC software can be fast, see Shewchuck’s Triangle.

I Height-balancing expression trees might reduce the costs for time and spacesignificantly.

I We might observe different complexities in terms of big-Oh.I On- and offline structural optimization strategies for expression trees are worth

to be investigated.

I Adding EGC support to non-trivial software a-posteriori can be extremelychallenging.

I Different programming styles due to focus on either numerical accuracy orawareness of expression trees.

I EGC-aware programming right from the start is necessary.

I Adding MPFR support is straight-forwardI MPFR boosts numerical accuracy.I MPFR helps to distinguish numerical errors from logical bugs.I Precision-elevation instead of epsilon-relaxation?

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications EGC: a simple case study 25 of 29

Page 52: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Discontinuous problems and EGC

Straight skeletons can change discontinuously with the input:

vu

I The polygon is stored with finite precision to a file.I fp-codes are likely to produce the left skeleton/roof, which is intended.I EGC-codes produce the right skeleton/roof, which is undesired.

What is the lesser evil?

I Either waive EGC,

I Or forsake the desired output of the algorithm.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Open problems 26 of 29

Page 53: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Discontinuous problems and EGC

Straight skeletons can change discontinuously with the input:

vu

I The polygon is stored with finite precision to a file.I fp-codes are likely to produce the left skeleton/roof, which is intended.I EGC-codes produce the right skeleton/roof, which is undesired.

What is the lesser evil?

I Either waive EGC,

I Or forsake the desired output of the algorithm.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Open problems 26 of 29

Page 54: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Discontinuous problems and EGC

Straight skeletons can change discontinuously with the input:

vu

I The polygon is stored with finite precision to a file.I fp-codes are likely to produce the left skeleton/roof, which is intended.I EGC-codes produce the right skeleton/roof, which is undesired.

What is the lesser evil?

I Either waive EGC,

I Or forsake the desired output of the algorithm.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Open problems 26 of 29

Page 55: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Discontinuous problems and EGC

Straight skeletons can change discontinuously with the input:

vu

I The polygon is stored with finite precision to a file.I fp-codes are likely to produce the left skeleton/roof, which is intended.I EGC-codes produce the right skeleton/roof, which is undesired.

What is the lesser evil?

I Either waive EGC,

I Or forsake the desired output of the algorithm.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Open problems 26 of 29

Page 56: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Discontinuous problems and EGC

Straight skeletons can change discontinuously with the input:

vu

I The polygon is stored with finite precision to a file.I fp-codes are likely to produce the left skeleton/roof, which is intended.I EGC-codes produce the right skeleton/roof, which is undesired.

What is the lesser evil?

I Either waive EGC,

I Or forsake the desired output of the algorithm.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Open problems 26 of 29

Page 57: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Discontinuous problems and EGC

f

p

p′

p′′S

Input space

Output space

I f is discontinuous on a sub-space S (red) of the input space.I “Reversed simulation of simplicity”?

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Open problems 27 of 29

Page 58: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

A common yardstick

“Our algorithm runs in O(n log n) time in practice.”

“Our implementation behaved reliable in our tests.”

However:

I Experiments often comprise only a few datasets.

I Datasets have no diversity.

I Different papers compare against different data, if at all.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Conclusion 28 of 29

Page 59: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

A common yardstick

“Our algorithm runs in O(n log n) time in practice.”

“Our implementation behaved reliable in our tests.”

However:

I Experiments often comprise only a few datasets.

I Datasets have no diversity.

I Different papers compare against different data, if at all.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Conclusion 28 of 29

Page 60: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

A common yardstick

A standard computational geometry dataset library (SCGDL) would havemany benefits:

I Experiments become more meaningful and comparable:I Precise timings and memory consumption.I How often did an implementation crash?I How many results were wrong?

I Enables a culture of extensive experimental evaluation.I Brings CG and industry closer together.

I Implementing reliable geometric codes requires testing.I An incentive to provide “gapless” and practial descriptions of algorithms.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Conclusion 29 of 29

Page 61: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

A common yardstick

A standard computational geometry dataset library (SCGDL) would havemany benefits:

I Experiments become more meaningful and comparable:I Precise timings and memory consumption.I How often did an implementation crash?I How many results were wrong?

I Enables a culture of extensive experimental evaluation.I Brings CG and industry closer together.

I Implementing reliable geometric codes requires testing.I An incentive to provide “gapless” and practial descriptions of algorithms.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Conclusion 29 of 29

Page 62: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

A common yardstick

A standard computational geometry dataset library (SCGDL) would havemany benefits:

I Experiments become more meaningful and comparable:I Precise timings and memory consumption.I How often did an implementation crash?I How many results were wrong?

I Enables a culture of extensive experimental evaluation.I Brings CG and industry closer together.

I Implementing reliable geometric codes requires testing.I An incentive to provide “gapless” and practial descriptions of algorithms.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Conclusion 29 of 29

Page 63: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

A common yardstick

A standard computational geometry dataset library (SCGDL) would havemany benefits:

I Experiments become more meaningful and comparable:I Precise timings and memory consumption.I How often did an implementation crash?I How many results were wrong?

I Enables a culture of extensive experimental evaluation.I Brings CG and industry closer together.

I Implementing reliable geometric codes requires testing.I An incentive to provide “gapless” and practial descriptions of algorithms.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Conclusion 29 of 29

Page 64: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Figure: Taken from http://joyreactor.com/post/818128

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Conclusion 30 of 29

Page 65: Implementing Geometric Algorithms for Real-World ... · 6 if CheckResult(result, ) then //Topological/numerical checks 7 return result 8 else 9 ComputeUnitReset() 10 10 //Relaxation

Bibliography I

Held, M. (2001a).

FIST: Fast Industrial-Strength Triangulation of Polygons.

Algorithmica, 30(4):563–596.

Held, M. (2001b).

VRONI: An Engineering Approach to the Reliable and Efficient Computation of VoronoiDiagrams of Points and Line Segments.

Comput. Geom. Theory and Appl., 18(2):95–123.

Held, M. and Huber, S. (2009).

Topology-Oriented Incremental Computation of Voronoi Diagrams of Circular Arcs andStraight-Line Segments.

Comput. Aided Design, 41(5):327–338.

Huber, S. (2012).

Computing Straight Skeletons and Motorcycle Graphs: Theory and Practice.

Shaker Verlag.

ISBN 978-3-8440-0938-5.

Huber, S. and Held, M. (2012).

A Fast Straight-Skeleton Algorithm Based on Generalized Motorcycle Graphs.

Internat. J. Comput. Geom. Appl., 22(5):471–498.

Stefan Huber, Martin Held: Geometric Algorithms for Real-World Applications Conclusion 31 of 29