Coder Social home page Coder Social logo

jwidauer / cutsolver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from modischfabrications/cutsolver

0.0 0.0 0.0 192 KB

Webservice to determine ideal cut placement on stocks

License: GNU Lesser General Public License v3.0

Python 82.15% Shell 12.69% Dockerfile 5.16%

cutsolver's Introduction

CutSolver

GitHub Pipenv locked dependency version Travis Build Status Docker Image Version Docker Image Size Codacy Badge pre-commit Rating

This API can be used to solve the common problem of finding the perfect placement of cuts for specified lengths. It seems like no other free service tackles this specific problem in an easy to use format, so this is my attempt.

cutsolver

This Solver is using ints exclusively, as there is no need for arbitrary precision yet. It also has no concept of units so you can use whatever you want. Try using mm instead of cm if you have fractions.

Nerd talk: This is the 2D "Cutting Stock Problem", which is NP-hard. It can be reduced to the Bin-Packing-Problem (BPP). No efficient algorithm exists to calculate a perfect solution in an acceptable timeframe, therefore brute force (perfect solution) is used for small jobs and a heuristic (fast solution) für larger ones. Don't be surprised if you get different results, many combinations have equal trimmings and are therefore seen as equally good.

Usage

This is a backend, see CutSolverFrontend for a human usable version.

Send POST-Requests to [localhost]/solve, see /docs for further informations.

The easiest (and advised) way to deploy this is by using Docker.

Docker Hub

Now with 100% more Multiarchitecture! Both linux/amd64 and linux/arm/v7 are currently supported, message me if you use another platform.

You don't need to checkout this repository, I am building images and pushing them to Docker Hub.

Download and start this container by using the provided docker-compose file or running: docker run [--rm -it] -p80:80 modischfabrications/cutsolver:latest.

Note: Replace latest with a version number if you depend on this interface, I can guarantee you that the interface will change randomly. It's not like I know what I'm doing, it's more like a learning curve.

Local build

  1. Build and start this image using docker-compose up
  2. wait a while for uvloop to build... (1000s)
  3. See usage for interactions.

Developing

Feel free to contact me or make a pull-request if you want to participate.

Install pre-commit with pre-commit install && pre-commit install -t pre-push.

Change version number in:

  1. main.py:version
  2. git tag
  3. Dockerfile?

This should be checked and or fixed by pre-commit, execute pre-commit run --all-files --hook-stage push to run manually.

Prebuild docker images

Docker Hub should be updated automatically by Travis, but it's a broken mess (#16).

Installation of a multibuilder (once): check "experimental features" in Docker Desktop.

docker buildx inspect multibuilder --bootstrap

Update manually with the following steps (replace with version, e.g. v0.3.7):

docker login -u modischfabrications
docker buildx build --platform linux/amd64,linux/arm/v7 \
    -t modischfabrications/cutsolver:<VERSION> \
    -t modischfabrications/cutsolver:latest --push .

Wait a while for uvloop to build (~1000s) and all layers to be pushed (~400s).

Check https://hub.docker.com/repository/docker/modischfabrications/cutsolver to see results.

Want to check the size prior to pushing it? Rebuild the docker image with docker-compose up --build and check uncompressed image size with docker-compose images.

Dependencies

Everything should be handled by Docker

This project uses:

  • pipenv: library management
  • FastAPI: easy webservice (this includes much more!)
  • httpie: curl-like for docker healthcheck

External links

https://scipbook.readthedocs.io/en/latest/bpp.html

cutsolver's People

Contributors

modischfabrications avatar codacy-badger avatar dependabot[bot] 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.