GithubHelp home page GithubHelp logo

moldhouse / score-rs Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 1000 KB

score-rs is an optimized min-marginal algorithm to solve the distance assignment problem for glider flights.

License: MIT License

Rust 95.95% Python 4.05%

score-rs's Introduction

score-rs

Find n points out of a set of possible tens of thousands of GPS points, such that the straight distance between them is maximized. There is one constraint: The finish altitude must not be more than 1000 m less than the start altitude.

The algorithm does the same optimization that WeGlide does to assign a distance to every flight:

  1. Build a distance matrix between all points
  2. Build a graph with backward min-marginals
  3. Traverse this graph to find a solution (path)
  4. If this solution does comply with the 1000 m rule, the problem is solved.
  5. If not, all possible start candidates and their maximum achievable distances (without the 1000m rule) are calculated and they are checked one by one (with many optimizations) until the maximum achievable distance of all the remaining ones is lower than the current best valid (complying with 1000m rule) solution

The code is based on the excellent aeroscore-rs library, but differs in three points:

  1. Instead of the full distance matrix, only the triangular half matrix is calculated, minimizing the memory footprint. This comes with the caveat of only allowing for backward min-marginals (optimization is only possible in the backward direction).
  2. If the 1000 m altitude is satisfied by the best result, the optimization is similar. If not, this library uses a caching system to quickly determine if start candidates can give a better solution than the current best without traversing the whole graph.
  3. Also look for potential solutions by adjusting the start- and end points of a given solution and keeping the middle points constant. This is not used to find the actual solution (as it does not guarantee optimality), but it speeds up the optimization by helping to find better intermediate results and discard candidates that do not offer a better solution

Develop

Python bindings are generated with maturin. Create a virtual env first with

python -m venv ./env && source .env/bin/activate

and install numpy in your virtual env:

pip install numpy

To develop, run

maturin develop

or for a (faster) release version

maturin build --release
pip install .

Test

You can run the tests with

cargo test
python -m pytest

score-rs's People

Contributors

moldhouse avatar

Stargazers

 avatar  avatar  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.