packerman

A lightweight library for general purpose bin-packing of a collection with arbitrary values.

License

License

GroupId

GroupId

com.github.alexsniffin
ArtifactId

ArtifactId

packerman_2.12
Last Version

Last Version

0.4.0-RC1
Release Date

Release Date

Type

Type

jar
Description

Description

packerman
A lightweight library for general purpose bin-packing of a collection with arbitrary values.
Project URL

Project URL

https://github.com/alexsniffin/packerman
Project Organization

Project Organization

com.github.alexsniffin
Source Code Management

Source Code Management

https://github.com/alexsniffin/packerman

Download packerman_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.alexsniffin/packerman_2.12/ -->
<dependency>
    <groupId>com.github.alexsniffin</groupId>
    <artifactId>packerman_2.12</artifactId>
    <version>0.4.0-RC1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.alexsniffin/packerman_2.12/
implementation 'com.github.alexsniffin:packerman_2.12:0.4.0-RC1'
// https://jarcasting.com/artifacts/com.github.alexsniffin/packerman_2.12/
implementation ("com.github.alexsniffin:packerman_2.12:0.4.0-RC1")
'com.github.alexsniffin:packerman_2.12:jar:0.4.0-RC1'
<dependency org="com.github.alexsniffin" name="packerman_2.12" rev="0.4.0-RC1">
  <artifact name="packerman_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.alexsniffin', module='packerman_2.12', version='0.4.0-RC1')
)
libraryDependencies += "com.github.alexsniffin" % "packerman_2.12" % "0.4.0-RC1"
[com.github.alexsniffin/packerman_2.12 "0.4.0-RC1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.8

Project Modules

There are no modules declared in this project.

packerman

Build Status

This is a lightweight library for general purpose bin-packing of a collection with arbitrary values.

Supported Language Version

  • Scala 2.12

SBT

libraryDependencies += "com.github.alexsniffin" %% "packerman" % version

Usage

The design of this library allows you to define your usage on how to bin-pack your input collection.

Example

case class Input(key: String, value: Int)

val collection = Seq(
    Input("29b482bca2af868b0cc6c7c409fe3d14", 588665550),
    Input("d724b748d259fa0f39a4ac776a86ad61", 1045661516), 
    Input("df1662f0aed98c78c192654461afb6f6", 232359110)
  )

val packerman = PackermanEngine(collection)
  .groupBy(x => x.key)
  .packBy(x => x.value)
  .distributionStrategy(UniformDistribution(weighted = true, .5))
  .compute()

val output = packerman match {
  case Right(result) => result
  case l @ Left(err) => l // handle error
}

Distribution Strategies

Uniform Distribution

Distributes the field specified by packBy uniformly from the specified groupBy field.

Parameters Description
weighted Specifies if the field will be adjusted against other groups in the collection when distributed.
limit Specifies the upper limit of a group for which to distribute. If the amount of groups * limit < 1, the limit is too small.

Versions

Version
0.4.0-RC1
0.4.0-M1