Rod Cutting Software

Download my Python implementation of the various rod-cutting algorithms described in CLRS 15.1. Prices can be randomly generated or loaded from a file (e.g., sample prices from book's example). These files can be found on turing at /Public/goldwasser/314/cutrod/.

You may use the -h flag to get a list of command line options:

Usage: cutrod.py [options]

Options:
  -h, --help         show this help message and exit
  -n LENGTH          length of original rod [default: 10]
  -P                 echo price list to console [default: False]

  Algorithm Options:
    Available algorithms: bottomup, memoize, recursion

    -a ALGORITHM     algorithm choice [default: bottomup]
    -V               generate verbose solution [default: False]

  Pricing Options:
    -f FILE          read (whitespace separated) price list from file
    -d DENSITY       average price per unit [default: 10]
    -s SEED          random seed for generating prices [default: none]
    -r DISTRIBUTION  random distribution function for price densities
                     [default: gauss]

  Available Distributions:
    gauss, pareto


Last modified: Thursday, 13 September 2012