Git Product home page Git Product logo

apportion's Introduction

Apportion travis yard docs code climate

A Ruby implementation for apportionment

Description

Apportionment is most often associated with the US Congressional apportionment, using the Equal Proportions (or Huntington-Hill) method.

In general, apportionment involves the division of a scarce resource among recipients, according to a pre-determined set of recipient weights. Further, a series of apportionments might occur over time, with each new apportionment overlaying the previous.

Different domains might make use of apportionment. One example is the allocation (or distribution) of sellable inventory among a number of retail stores, according to the expected sales rate for each store. For this usage, recipients would likely begin an apportionment with varying quantities of existing inventory.

Other apportionment methods exist, notably the Quota method, that address issues with Equal Proportions.

Installation

Add this line to your application's Gemfile:

gem 'apportion'

And then execute

$ bundle

Or install it yourself as

$ gem install apportion

Usage

Apportion.division(weights, size, options = {})

Returns a hash (a key for each recipient) with the size quantity distributed among recipients (as values)

Parameters

weights (required) a [Hash] of relative integer proportions for each recipient

size (required) an [Integer] quantity to apportion

options (optional) [Hash] keys

  • :prior_portions a [Hash] prior portions for each recipient from a previous apportionment
  • :required_minimum an [Integer] smallest portion for each recipient

Development

To install dependencies

$ bundle

To run the tests

$ rake

License

The gem is available as open source under the terms of the MIT License.

apportion's People

Contributors

garyf avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

kaito0228

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.