Skip to content

Code for calculating the upper envelope of a set of linear approximation functions described by points.

License

Notifications You must be signed in to change notification settings

maleksware/upper-envelope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

upper-envelope

Code for calculating the upper envelope of a set of linear approximation functions described by points.

My algorithm is implemented using, among other tricks, a lightweight interpolation with optimisations which improves the expected calculation time by ~30%. The time complexity is $O(n^2)$, and this is the fastest algorithm I know to solve this variant of the upper envelope problem.

The plot describes the problem nicely. The red line is the upper envelope of the set of three functions (blue, orange and green). It is guaranteed that all functions' domain is the same (the starting and ending points have the same X-coordinate).

C++ notice

As connecting C++ and Python turned out to be more difficult than expected, the functions have been completely rewritten to Python. The new file structure became easier to read and maintain. C++ version is now in /cpp along with the required i/o files.

Example

import gen_data
import plot_data
import envelope as ev
from converter import tuplelines2lines

generated_lines = gen_data.gen_random_data()
upper_envelope = ev.get_ue(tuplelines2lines(generated_lines))

plot_data.plot_nice_picture(generated_lines, upper_envelope)

About

Code for calculating the upper envelope of a set of linear approximation functions described by points.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published