Git Product home page Git Product logo

custo's Introduction

custo

Cutting Stock Problem (1D) algorithms implemented with Python 3

Purpose

The intent of this project is to code algorithm solutions the Cutting Stock Problem, an area of operations research.

In short, the Cutting Stock Problem is a problem where we have material (like a metal pipe, or wood boards) which needs to be cut into pieces. These pieces should be laid out, across several boards, such that we can minimize wasted material (bits to short to use).

Code should be correct, readable, easy to use, and well-commented.

Getting Started

Requirements

Python 3.6

Installation

Clone repo into your project directory.

or

git install git+https://github.com/filipwodnicki/custo.git

Tests

cd custo    
  
python -m unittest discover tests

Algorithms

1. Greedy Algorithm

custo/greedy.py

This is the first algorithm implemented, a "hello world" of sorts. The First-fit Algorithm is a type of greedy approximation algorithm. It's called "greedy" because it optimizes at each step of calculation without considering the solution as a whole. Furthermore, even as a greedy algorithm it's only an approximation of the optimal result. Namely, at each step it doesn't check which piece fits best, it's just first-come-first-served!

Here's how it works:

  1. Sort input pieces by size
  2. Initialize the first Board, which will be output
  3. Try to arrange the largest item on the Board
  4. If there is space, place the item
  5. If there is no space, take a new Board off the shelf and place the item on that new Board
  6. Repeat #3-5 for each item, then return solution.

Interestingly, Fit-first has been shown to always give results within 20-25% of the truly optimal solution.

Example usage

from custo import greedy_algorithm
greedy_algorithm([450, 444, 436, 430, 389, 389, 386, 375, 362, 362, 261, 261, 261], 2050.)

Greedy Algorithm Example

Contributing

Please email author if interested.

Changelog

v0.1.1 (01-09-2018) Fix known bugs with import
v0.1.0 (31-08-2018) Project launch. Implement Greedy Algorithm with tests

Acknowledgements

License

MIT © Filip Wodnicki 2018

custo's People

Contributors

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