Line Approximation Tools for Python.

Karl Skretting, University of Stavanger.


The page is still under construction.

Contents on this page: Relevant papers and links to other pages:
  1. A brief introduction
  2. Some example problems
  3. Methods
  4. Results
  5. Files and details
  • The presentation given at the NOBIM conference in Tromsø, June 7th-8th 2023.

1. A brief introduction

This page may interest readers that want to solve problems where a set of points should be approximated by a smaller set of straight line segments. The example problems are solved using Python.

2. Some example problems

The mathematical-like definition of the problem is:
From a path given by a large ordered set of points, x[i] = x[ti] where ti are the time indexes for i in 1,2,3,...,L and x is a scalar or more commonly a vector of N dimensions, a subset of K of these points are to be selected, always first and last, such that the line segments between these K points approximate the path as well as possible.
One way to express "as well as possible" is to say that the sum of all (squared) errors should be as low as possible. Each point n is approximated by a point on the line segment between selected point i where i is as large as possible but smaller or equal to n and selected point j where j is as small as possible but larger (or equal) to n. The approximation can be the orthogonal projection onto this line segment, or it can be a point on the line segment given by the t-value of points i, j, and n. The distance between a point and its approximation gives the error measure used, here often the squared error (SE) is used.
The goal is to find a subset of K points where the sum of squared errors (SSE) is minimized. A relaxation, and a more difficult problem, is to don't restrict the selected points to be in the original set of points, to select points "freely" in the M-dimensional space.

3. Methods

more to be inserted here

3.1. Calculations of erros

more to be inserted here

3.2. Greedy algorithms

more to be inserted here

3.3. Optimal algorithm, AFCCSP

more to be inserted here

3.4. Adjust points freely

more to be inserted here

4. Results

more to be inserted here

5. Files and details

As a start only the functions for Always Forward and Cardinality Constrained Shortest Path (AFCCSP) algorithm are included. These as independent and don't need any of the other Python files I have made, although if you want to use data from gpx-file some other code needs to be included or added.

I hope that I soon will include all files needed for the experiments done and presented at NOBIM conference i Tromsø June 2023.

funAFCCSP.py Functions for Always Forward and Cardinality Constrained Shortest Path algorithm.
testAFCCSP.py Functions that test and demonstrate functions in funAFCCSP.py.
clsLineApprox.py Mainly the class LineApprox
testLineApprox.py Functions that test and demonstrate clsLineApprox.py.
testLineApproxOnGpx.py Functions that test and demonstrate clsLineApprox.py using GPX data file.
testAustralia.py Functions that test and demonstrate clsLineApprox.py using Australia contour.
australia.gif Image file used in testAustralia.py.
australiaThin.gif Image file used in testAustralia.py.

Last update: June 20, 2023. Karl Skretting Visit my home page.