Giter Club home page Giter Club logo

optimizer-api's Introduction

Mapotempo Optimizer API

Run an optimizer depending of contraints for a Vehicle Routing Problem (VRP).

Installation

bundle

Configuration

Adjust config/environments files.

Running

bundle exec rake server

And in production mode:

APP_ENV=production bundle exec rake server

Start Redis and then start the worker

APP_ENV=production COUNT=5 QUEUE=* bundle exec rake resque:workers

Usage

The API is defined in Swagger format at http://localhost:1791/swagger_doc and can be tested with Swagger-UI http://swagger.mapotempo.com/?url=http://optimizer.mapotempo.com/swagger_doc

curl -X POST --header "Content-Type:application/json" --data '{"vrp":{vehicles":[]}}' http://localhost:1791/0.1/vrp/submit.json?api_key=key

Test

Run tests :

APP_ENV=test bundle exec rake test

You can add your own tests on specific Vehicle Routing Problem (for instance data from real cases). Let's see how to create a new test called "new_test". You will find template for test in test/real_cases_test.rb

Before creating test, you need to capture scenario. Launch process with environment variable DUMP_VRP to record it:

DUMP_VRP=new_test bundle exec rake server
DUMP_VRP=new_test COUNT=5 QUEUE=* bundle exec rake resque:workers

Just run the original scenario to record it. Then two files are created in test/fixtures after running scenario:

  • new_test.json file corresponding to original vrp sent by api
  • new_test.dump file corresponding to complete vrp (for instance containing matrices if they are not provided in original vrp)

Now to create your test, just copy test template in test/wrappers/real_cases_test.rb with either .json or .dump depending on your data (e.g. if your vrp sent to api contains matrices you can use .json file, in other case use .dump file.)

If you create a test by using .dump, your test will fail as soon as vrp model is changed. Just run following task to update fixtures:

DUMP_VRP=my_test APP_ENV=test bundle exec rake test TEST=test/real_cases_test.rb

TODO: create a task to update all fixtures at once.

Note: you can update a test and run the modified scenario with new vrp .json:

bundle exec rake server
COUNT=5 QUEUE=* bundle exec rake resque:workers
curl -X POST --header "Content-Type:application/json" --data @test/fixtures/my_test.json http://localhost:1791/0.1/vrp/submit.json?api_key=key

If you don't want to run real cases tests you can deactive them:

SKIP_REAL_CASES=true APP_ENV=test bundle exec rake test

optimizer-api's People

Contributors

frodrigo avatar fab-girard avatar braktar avatar flomapo avatar xals 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.