Difference between revisions of "Parallel Enclosing Circle Algorithm"
Line 21: | Line 21: | ||
This algorithm has terrible time-performance characteristics, so we make the assumption that we can divide a large number of points with k-means and then solve those subproblems. | This algorithm has terrible time-performance characteristics, so we make the assumption that we can divide a large number of points with k-means and then solve those subproblems. | ||
In other words, we make the simplifying assumption that the Enclosing Circle Algorithm has [https://en.wikipedia.org/wiki/Optimal_substructure Optimal Substructure]. | In other words, we make the simplifying assumption that the Enclosing Circle Algorithm has [https://en.wikipedia.org/wiki/Optimal_substructure Optimal Substructure]. | ||
+ | |||
+ | == Structure of Program == | ||
+ | * TODO | ||
== Parameters == | == Parameters == | ||
* in <code>circles.py</code>: | * in <code>circles.py</code>: | ||
+ | ** <code>PATH_SEPARATOR</code>: the string that separates parts of the filename for both input and output files. For example, an input could look like "St. Louis#MO#2017#0.tsv" for PATH_SEPARATOR = '#' | ||
** <code>ITERATIONS</code>: the number of iterations to attempt for each <code>k</code> to find minimum for that <code>k</code> | ** <code>ITERATIONS</code>: the number of iterations to attempt for each <code>k</code> to find minimum for that <code>k</code> | ||
** <code>MIN_POINTS_PER_CIRCLE</code> (AKA <code>n</code>): the minimum number of data points that must be included in a circle | ** <code>MIN_POINTS_PER_CIRCLE</code> (AKA <code>n</code>): the minimum number of data points that must be included in a circle | ||
Line 32: | Line 36: | ||
** <code>TIMEOUT_MINUTES</code>: maximum running time of a parallel instance of the algorithm | ** <code>TIMEOUT_MINUTES</code>: maximum running time of a parallel instance of the algorithm | ||
** <code>SPLIT_THRESHOLD</code>: if a dataset has more than this threshold of data points, it will be split via k-means | ** <code>SPLIT_THRESHOLD</code>: if a dataset has more than this threshold of data points, it will be split via k-means | ||
+ | ** <code>EXECUTABLE_INSTANCE_PATH</code>: the path to circles.py | ||
+ | ** <code>OUTJOINER_INSTANCE_PATH</code>: the path to outjoiner.py | ||
+ | ** <code>DATA_DIRECTORY</code>: the input directory | ||
+ | ** <code>OUTPUT_DIRECTORY</code>: the directory to write the outputs of circle.py to | ||
+ | ** <code>GENERATE_REPORTS</code>: whether or not to call outjoiner.py (writes reports on the output of circles.py) | ||
+ | ** <code>REPORT_DIRECTORY</code>: the directory to write reports to | ||
+ | |||
== Example Usage == | == Example Usage == |
Revision as of 14:48, 8 November 2017
Parallel Enclosing Circle Algorithm | |
---|---|
Project Information | |
Project Title | Parallel Enclosing Circle Algorithm |
Owner | Oliver Chang |
Start Date | July 31, 2017 |
Deadline | October 4, 2017 |
Primary Billing | |
Notes | |
Has project status | Complete |
Is dependent on | Enclosing Circle Algorithm |
Copyright © 2016 edegan.com. All Rights Reserved. |
A thin-wrapper around the enclosing circle algorithm which allows for instance-level parallelization.
This project consists of the python files in E:\McNair\Projects\OliverLovesCircles\src\python
.
Parallelization is implemented via Python2's subprocess.open()
which is non-blocking and available in the standard library.
Contents
The Problem
Note that this is not the classical enclosing circle algorithm.
Rather, we seek to minimize the sum of enclosing circles containing at least n
points.
Thus, multiple circles are allowed and inclusion in multiple circles is possible.
This algorithm has terrible time-performance characteristics, so we make the assumption that we can divide a large number of points with k-means and then solve those subproblems. In other words, we make the simplifying assumption that the Enclosing Circle Algorithm has Optimal Substructure.
Structure of Program
- TODO
Parameters
- in
circles.py
:PATH_SEPARATOR
: the string that separates parts of the filename for both input and output files. For example, an input could look like "St. Louis#MO#2017#0.tsv" for PATH_SEPARATOR = '#'ITERATIONS
: the number of iterations to attempt for eachk
to find minimum for thatk
MIN_POINTS_PER_CIRCLE
(AKAn
): the minimum number of data points that must be included in a circle
- in
vc_circles.py
NUMBER_INSTANCES
: number of parallel instances to run; assume no data-races between instancesSWEEP_CYCLE_SECONDS
: amount of time before removing completed jobs from the current job and adding new jobs if any files are left to processTIMEOUT_MINUTES
: maximum running time of a parallel instance of the algorithmSPLIT_THRESHOLD
: if a dataset has more than this threshold of data points, it will be split via k-meansEXECUTABLE_INSTANCE_PATH
: the path to circles.pyOUTJOINER_INSTANCE_PATH
: the path to outjoiner.pyDATA_DIRECTORY
: the input directoryOUTPUT_DIRECTORY
: the directory to write the outputs of circle.py toGENERATE_REPORTS
: whether or not to call outjoiner.py (writes reports on the output of circles.py)REPORT_DIRECTORY
: the directory to write reports to
Example Usage
$ python vc_circles.py --infile E:/McNair/Projects/OliverLovesCircles/CoLevelForCirclesNotRunGTE200.txt
where CoLevelForCirclesNotRunGTE200.txt
is a tab-separated values file with the columns
placestate, place, statecode, year, latitude, longitude, coname, datefirstinv, placens, geoid, city
This command will populate (and overwrite) any files in data/
and reports/
. The format of the filenames in this directory are {city}{sep}{state}{sep}{year}{sep}{num}.tsv
where num
is a 0-indexed integer of a split city/state/year infile
that has greater than SPLIT_THRESHOLD
Bugs/Issues
- "St. Paul" and "St. Louis" have un-enclosed points--speculate because of weird file path issues
- Some place/state/year combinations do not run to completion regardless of how tractable the number of points
- How to merge small enclosing circles? This is a better measure of agglomeration regardless
- How to separate outliers?
Plotting Circles
- Connect to database with command
psql -U postgres arc
- password is tabspaceenter I think
\d
lists tables- Now run SQL script LoadCircles.sql in OliverLovesCircles
- Open ArcMap
- Add data -> Top of file tree -> Database connection -> localhost for instance, database arc -> connect to localhost and table testcirclegeom
- Add points from local files, make sure they are txt or tab files, not tsv