Skip to main content

TSP Rest Api Server - Rest Api Server using Dijsktra's algorithm applied to travelling salesman problem.

Project description

https://raw.githubusercontent.com/caputomarcos/tsp-rest-api-server/master/logotipo-pickngo.png

tsp-rest-api-server

TSP Rest Api Server - Rest Api Server using Dijsktra’s algorithm applied to travelling salesman problem.

License

Licensed under the MIT License.

Install

Follow the steps below to get everything up and running.

pip

  1. Create project folder:

    $ mkdir tsp-rest-api-server && cd tsp-rest-api-server
    
  2. Create virtualenv in the normal way:

    $ virtualenv env --python=python
    
  3. Active your new virtualenv:

    $ source env/bin/activate
    
  4. Install tsp-rest-api-server:

    $ pip install tsp-rest-api-server
    
  5. Create setting file:

    $ tsp_rest_api_server settings
    
  6. Set EVE_SETTINGS:

    $ export EVE_SETTINGS=$PWD/settings.py
    
  7. Run tsp rest api server:

    $ tsp_rest_api_server runserver
    

Git

  1. Clone repository:

    $ git clone git@github.com:caputomarcos/tsp_rest_api_server.git
    
  2. Go to tsp_rest_api_server source folder:

    $ cd tsp-rest-api-server/
    
  3. Create virtualenv in the normal way:

    $ virtualenv env --python=python
    
  4. Active your new virtualenv:

    $ source env/bin/activate
    
  5. Create dev environment:

    $ make develop
    

Usage

  1. Create routes:

    $ curl -d "@map.json"  -H "Content-Type: application/json" -X POST http://0.0.0.0:5000/maps
    
    or
    
    $ curl -d '{ "title":"Sao Paulo", "routes":[{"origin":"A","destiny":"B","distance":10},{"origin":"B","destiny":"D","distance":15},{"origin":"A","destiny":"C","distance":20},{"origin":"C","destiny":"D","distance":30},{"origin":"B","destiny":"E","distance":50},{"origin":"D","destiny":"E","distance":30}]}' -H "Content-Type: application/json" -X POST http://0.0.0.0:5000/maps
    
  2. Search shortest route:

    $ curl 'http://0.0.0.0:5000/maps/shortest?map=Sao%20Paulo&origin=A&destiny=D&price=2.50&autonomy=10'
    
    {
      "data": [
        {
          "Path": "['A', 'B', 'D']"
        },
        {
          "Total KM": "25.00"
        },
        {
          "Cost": "6.25"
        }
      ]
    }
    

Drop all mongodb databases

# dropall.js

var dbs = db.getMongo().getDBNames()
for(var i in dbs){
    db = db.getMongo().getDB( dbs[i] );
    print( "dropping db " + db.getName() );
    db.dropDatabase();
}

usage

mongo dropall.js

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for tsp-rest-api-server, version 3.6
Filename, size File type Python version Upload date Hashes
Filename, size tsp_rest_api_server-3.6.macosx-10.12-intel.tar.gz (9.3 kB) File type Source Python version None Upload date Hashes View
Filename, size tsp_rest_api_server-3.6-py2-none-any.whl (8.8 kB) File type Wheel Python version py2 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page