GithubHelp home page GithubHelp logo

stock_math_api's Introduction

Stock math api

Search for the best way through the warehouse to collect different goods for further shipment to the client.

Application environment

following system environment variables are used for auth0 connection configuration.

  • APPLICATION_URL - URL of current instance, e.g. http://localhost:8080
  • APPLICATION_PORT - Port number backend shall listen on. Unless provided, port number from URL will be used, or default 8080
  • APPLICATION_BIND - IP address server shall listen on. Unless provided, 0.0.0.0 will be used
  • APPLICATION_ALLOWED_ORIGIN - Allowed origin for processing http requests. Unless provided, http://localhost:8000 will be used
  • APPLICATION_MACHINE_ID - Machine ID for current instance, used for snowflake generation (default: 1)
  • APPLICATION_NODE_ID - Node ID for current instance, used for snowflake generation (default: 1)

API Documentation

POST /calculate_optimal_path

request body:

  • geometry stock geometry how 2d array when i index how Y and j index how X
  • points is array of points (i,j) on which a person stands when he takes goods from the shelves.

responce body:

  • algorithm is algorithm type
  • distance_matrix_time how many time need for calculate graph (more details in "Solution" section)
  • traveling_salesman_time how many time need for calculate min path from graph (more details in "Solution" section)
  • distance how many steps need for getting goods from stock all shelves
  • path route min path

Example

POST /calculate_optimal_path
body
{
  "geometry": [
    ["W","W","W","W","W","W","W","W"],
    ["W","P","_","_","_","P","_","W"],
    ["W","W","W","_","W","W","W","W"],
    ["W","_","_","_","_","_","P","W"],
    ["W","W","W","_","W","W","W","W"],
    ["W","P","_","_","_","_","_","W"],
    ["W","W","W","_","W","W","W","W"],
    ["W","_","_","_","_","_","P","W"],
    ["W","S","_","_","_","_","_","_"],
    ["W","W","W","W","W","W","W","W"]
  ],
  "points": [
    [8, 1],
    [1, 1],
    [1, 5],
    [3, 6],
    [5, 1],
    [7, 6]
  ]
}
return:
{
    "algorithm": "simulated_annealing",
    "distance_matrix_time": "162.47µs",
    "traveling_salesman_time": "1.000004241s",
    "distance": 48.0,
    "path": [
        [8, 1],
        [1, 5],
        [1, 1],
        [3, 6],
        [5, 1],
        [7, 6],
        [8, 1]
    ]
}

Development

To start server use command: cargo run --bin chat

Open url: http://localhost:8080/

Docker

Build image

$ docker build --target runtime -t stock_math_api .

Run tests

$ docker build --progress=plain --target test -t chat-test .

Postmen examples

stock_math_api.postman_collection.json - located in repo

Solution

  1. Calculate graph when set of nodes is 'Pi' and set of edges ('Pi', 'Pj') = min_path(geometry, Pi, Pj) min_path we calculate use bfs algorithm.
  2. Solve traveling salesman problem for all nodes in calculated graph using Simulated_annealing algorithm.

Geometry example

W - wall or shelf P - point S - start point

WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WP_____P______P_______P________P________P______W
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
W________________P__P______________P________P__W
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
W__P_________P________________P________P_______W
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WP_______________P__________________P_________PW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
W___P___________P______________P__________P____W
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
W____________P________P_____________P________P_W
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
W______________________________________________W
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
W__P___________P____________________PP_________W
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
W__________________P_______P__________________PW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
W_____P_____________________P_________P________W
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWW__WWWWWWWWWWWWWWWWWWWWW
W______________________________________________W
W______________________________________________W
W_______________________________________________
W___S___________________________________________
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

Debug OPTIONS

curl -i -X OPTIONS -H "Origin: http://127.0.0.1:3000" \
    -H 'Access-Control-Request-Method: POST' \
    -H 'Access-Control-Request-Headers: Content-Type' \
    "http://localhost:8080"

Next implementation

  1. investigate Concorde TSP Solver
  2. impement algorithms used concorde for TSP on rust

stock_math_api's People

Contributors

sergo007 avatar

Watchers

 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.