-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dennis Rohde
committed
Feb 6, 2020
0 parents
commit d71ddbf
Showing
24 changed files
with
2,018 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
src/.vscode | ||
!build/.gitignore | ||
dimensionality_reduction.egg-info | ||
.git | ||
dist | ||
.idea | ||
.vscode | ||
.vscode/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) | ||
project(Fred LANGUAGES CXX) | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -shared") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") #supress error in older gcc | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined") | ||
|
||
include_directories(${CMAKE_SOURCE_DIR}/include) | ||
|
||
find_package(PythonInterp REQUIRED) | ||
find_package(PythonLibs REQUIRED) | ||
find_package(Boost 1.63 COMPONENTS chrono ${BPY} ${BNPY} REQUIRED) | ||
find_package(OpenMP REQUIRED) | ||
|
||
include_directories(${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) | ||
link_libraries(${PYTHON_LIBRARIES} ${Boost_LIBRARIES} OpenMP::OpenMP_CXX) | ||
|
||
add_definitions(-D_GLIBCXX_PARALLEL) | ||
|
||
PYTHON_ADD_MODULE(Fred | ||
src/fred_python_wrapper.cpp | ||
src/curve.cpp | ||
src/point.cpp | ||
src/interval.cpp | ||
src/frechet.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Dennis Rohde | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pre: | ||
sudo apt install libboost-all-dev | ||
sudo apt-get install python3-setuptools | ||
sudo apt-get install python3-numpy | ||
sudo apt-get install python3-pandas | ||
sudo apt-get install python-setuptools | ||
sudo apt-get install python-numpy | ||
sudo apt-get install python-pandas | ||
|
||
python3: | ||
cd py && python3 ./setup.py install --user | ||
|
||
python2: | ||
cd py && python2 ./setup.py install --user | ||
|
||
clean: | ||
pip3 uninstall Fred -y | ||
pip2 uninstall Fred -y | ||
rm -r py/dist py/build/ py/Fred.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Fred  | ||
A fast, scalable and light-weight C++ Fréchet distance library, exposed to python. | ||
|
||
## Ingredients | ||
- continous Fréchet distance | ||
- signature: `Fred.continuous_frechet(curve1, curve2, approximation_error)` default for approximation_error is 0.001 | ||
- returns: `Fred.Continuous_Frechet_Result` with members `value`, `time_bounds`: running-time for upper and lower bound, `number_searches`: number of free space diagrams built, `time_searches`: running-time for free spaces | ||
- discrete Fréchet distance | ||
- signature: `Fred.discrete_frechet(curve1, curve2)` | ||
- returns: `Fred.Discrete_Frechet_Result` with members `value` and `time` | ||
- discrete k-center clustering (continuous Fréchet) [Without simplification; from **Approximating (k,l)-center clustering for curves**](https://dl.acm.org/doi/10.5555/3310435.3310616) | ||
- signature: `Fred.discrete_kcenter(k, curves, approximation_error, with_assignment)` with parameters `approximation_error`: see continuous Fréchet, `with_assignment`: defaults to false; assigns curves to nearest centers if true | ||
- returns: `Fred.Clustering_Result` with mebers `value`: objective value, `time`, `assignment`: empty if with_assignment=false | ||
- discrete k-median clustering (continuous Fréchet) [Algorithm 6 in **Coresets for (k,l)-Clustering under the Fréchet distance**](https://arxiv.org/pdf/1901.01870.pdf) | ||
- signature: `Fred.discrete_kmedian(k, curves, approximation_error, with_assignment)` with parameters `approximation_error`: see continuous Fréchet, `with_assignment`: defaults to false; assigns curves to nearest centers if true | ||
- returns: `Fred.Clustering_Result` with mebers `value`: objective value, `time`, `assignment`: empty if with_assignment=false | ||
- discrete one-median clustering (continuous Fréchet) via sampling [Section 3 in **Random Projections and Sampling Algorithms for Clustering of High Dimensional Polygonal Curves**](https://papers.nips.cc/paper/9443-random-projections-and-sampling-algorithms-for-clustering-of-high-dimensional-polygonal-curves) | ||
- signature: `Fred.discrete_onemedian_sampling(curves, epsilon_sampling, approximation_error, with_assignment)` with parameters `approximation_error`: see continuous Fréchet, `epsilon_sampling`: (1+epsilon) approximation parameter, `with_assignment`: defaults to false; assigns curves to nearest centers if true | ||
- returns: `Fred.Clustering_Result` with mebers `value`: objective value, `time`, `assignment`: empty if with_assignment=false | ||
- dimension reduction via. gaussian random projection [Section 2 in **Random Projections and Sampling Algorithms for Clustering of High Dimensional Polygonal Curves**](https://papers.nips.cc/paper/9443-random-projections-and-sampling-algorithms-for-clustering-of-high-dimensional-polygonal-curves) | ||
- signature: `Fred.dimension_reduction(curves, epsilon, empirical_constant)` with parameters `epsilon`: (1+epsilon) approximation parameter, `empirical_constant`: use constant of empirical study (faster, but less accurate) | ||
- returns: `Fred.Curves` collection of curves | ||
|
||
## Installation | ||
Get requirements under Ubuntu: `make pre` | ||
|
||
Python3 installation into userdir: `make python3` | ||
|
||
Python2 installation into userdir: `make python2` | ||
|
||
## Test | ||
Just run `python py/test.py`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!/*.hpp |
Oops, something went wrong.