GithubHelp home page GithubHelp logo

cwtwm / locationallocation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benjbaron/locationallocation

0.0 0.0 0.0 680.67 MB

A Qt Application to execute a location-allocation problem (Maximum set covering location problem) on a set of given demands and given candidate facilities. The routing part is done with OSRM.

Python 2.07% C++ 97.49% QMake 0.17% CMake 0.27%

locationallocation's Introduction

Ad-hoc cloud storage for mobile nodes

This project designs and simulates an ad-hoc distributed storage system for mobile users (e.g., people with their mobile devices or vehicles) to store and retrieve files.

The mobile users generate a put request to store a file and a get request to retrieve an available file. The file storage system relies on distributed storage nodes scattered over a geographical area that store the files. Whenever a mobile user is in the vicinity of a storage node, it sends its requests to the storage node to either store or retrieve a file. The user requests have a deadline until which the request must be executed by a storage node. Past the deadline, the user request is considered failed.

Location Allocation of the storage nodes

We designed a framework in Qt C++ to visualize (GUI), understand and compute an allocation of the storage nodes under different constraints and for different mobility traces.

GPS Trace visualization

The framework is capable of visualizing a GPS trace of mobile nodes under the format timestamp, node_id, lon, lat. The representation is done by displaying all the successive points of the trace. The intermediate positions of the nodes (i.e., in between each pair of points) can also be computed and displayed.

Each computation that leads to an additional set of graphic elements to be displayed is put on a layer (abstract class Layer). A layer manager contains the list of all the computed layers. The list allows to display or not a layer and reorder (the layers displayed on the GraphicScene are then reordered according to their z-index).

Shapefile and WKT visualization

In addition, we used the GDAL/OGR library to load and display Shapefiles and WKT files. We also used the PROJ.4 library to project each trace and subsequent layer under the same projected coordinate system (e.g., universal transverse Mercator, UTM) from a geographic coordinate system (with longitudes and latitues) to avoid complex distance calculations and spatial transformations. There is an additional tool that computes the intersections of LineStrings of the file.

Spatial toolset

We also designed a spatial toolset to visualize the spatial interaction of the nodes on the geographical area. Given the successive locations each node visited, the spatial toolset computes and represents statistical attributes for a set of geometry elements (e.g., cells on a grid that covers the whole geographical area, or intersections of two LineStrings). The statistics we calculate are the distributions of the inter-visits durations and the travel time between two geometry elements, as well as the frequency of the visits at and between geometry elements.

Spatial toolset preview

Location allocation procedure

Finally, the location allocation procedure computes the location allocation for the storage nodes, given the target number of storage nodes to allocate and the deadline of the user requests. Location allocation aims to determine the optimal locations for the given number of facilities given a set of candidate locations for to allocate the storage nodes and a set of demand points. The deadline of the user requests define an impedance from a demand point to a candidate location. We used the work of Chruch and Revelle to turn our problem into a Maximal Covering Location Problem. Since this problem is NP-Hard, we used the Greedy Adding with Substitution (GAS) algorithm mentioned in their work to solve it (in a non-optimal manner).

We used the geometry elements as candidates and demands. To take into account all the trajectories of the mobile nodes, the cells that are part of the grid covering the whole geographical area are the demand points. Candidate locations can be any geometry element, including the same cells, or known intersections between LineStrings. The weight of each demand for a candidate location represents the rate and intensity of mobile nodes traveling from the demand to the candidate location. We prefer constant flow over bursty flow, so we defined the weight as the mean frequency of mobile nodes traveling from the demand to the candidate location over the mean inter-visit duration. The impedance from a demand point to a candidate location corresponds to the mean travel time to go from the demand point to the candidate location.

Dependencies and build instructions

The project depends on the following libraries:

  • Qt5.5: brew install qt5
  • GDAL (Spatial library): brew install gdal --enable-unsupported
  • Proj.4 (Projection library): brew install proj
  • QHTTP (included in the project)

I included a ``.profile to build the framework in Qt Creator (fileLocation-allocation.pro`), as well as a `.cmake` file to build the framework using CMake (file `CMakeLists.txt`). You might need to change the include paths in either of these files to adapt to your configuration. I personally used Mac OSX El Capitan and Homebrew.

I also tested the project on Debian Squeeze:

Download the latest version of cmake

cmake .
make

Simulation with The ONE

Batch processing with Python

Pipeline

The project pipeline is done with a single Python script. The pipeline is multiprocessed to increase its speed. An initial trace (either synthetic or real) is fed to the Location Allocation framework (described above) through a REST server. The framework includes a REST JSON server to get the location allocation parameters (as input) and outputs the resulting location allocation in JSON format. The JSON result is turned into an allocation file by the Python script and fed to the simulation file generation procedure. The simulation is then run through a process call by the Python script using the generated simulation (settings) file.

Some projections for the included datasets

Cabspotting cab traces collected from May 17th, 2008 to June 10th, 2008 in the San Francisco Bay Area:

  • Input projection is ESPG (WGS84): +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
  • Output projection is ESPG 26910 (UTM 10N): +proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs

Run the location allocation from the REST server: http://localhost:8080/allocation/loc?distance=auto&delFactor=0.5&deadline=2400&travelTime=avg&nbFacilities=3

locationallocation's People

Contributors

benjbaron avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.