Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chriskonnertz/binpacking
Examples of algorithms that solve the bin packing problem implemented in Kotlin
https://github.com/chriskonnertz/binpacking
algorithm bin-packing binpacking example first-fit first-fit-decreasing kotlin optimization solving
Last synced: about 1 month ago
JSON representation
Examples of algorithms that solve the bin packing problem implemented in Kotlin
- Host: GitHub
- URL: https://github.com/chriskonnertz/binpacking
- Owner: chriskonnertz
- License: mit
- Created: 2018-02-13T18:59:29.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-14T22:17:20.000Z (almost 7 years ago)
- Last Synced: 2024-10-14T02:25:27.170Z (3 months ago)
- Topics: algorithm, bin-packing, binpacking, example, first-fit, first-fit-decreasing, kotlin, optimization, solving
- Language: Kotlin
- Size: 19.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BinPacking
Well documented examples of algorithms that solve the bin packing problem. Implemented in Kotlin.
A demo is included (`Demo.kt`)."In the bin packing problem, objects of different volumes must be packed into a finite number of bins or containers
each of volume V in a way that minimizes the number of bins used."
Learn more about the problem and the algorithms: https://en.wikipedia.org/wiki/Bin_packing_problem## Implemented algorithms
* First Fit (class `FirstFit`)
* First Fit Decreasing (class `FirstFitDecreasing`)The concrete algorithm classes inherit from the abstract super class `BinPackagingAlgorithm`.
## Usage
```kotlin
/** These are the available capacities (sizes) of the bins */
val availableBinCapacities = arrayOf(5000, 6000, 70000)
/** These are the lengths (parts) that we want to put into bins */
val parts: List = listOf(1000, 2000, 3000, 4000)val firstFit = FirstFit()
val result = firstFit.solve(availableBinCapacities, parts)
result.print()
```## Example demo output
Output from the demo (`Demo.kt`):
```
Testing algorithms...
Available bin capacities: 5000, 6000, 70000,
Parts: [1000, 2000, 3000, 4000]Using class de.chriskonnertz.firstFit.FirstFit
Optimization done.
Result:
Best bin capacity: 6000 - Used bins: 2 - Evaluation value: 2000
1. Bin - Unused space: 0 - Parts: [1000, 2000, 3000]
2. Bin - Unused space: 2000 - Parts: [4000]Using class de.chriskonnertz.firstFit.FirstFitDecreasing
Optimization done.
Result:
Best bin capacity: 5000 - Used bins: 2 - Evaluation value: 0
1. Bin - Unused space: 0 - Parts: [4000, 1000]
2. Bin - Unused space: 0 - Parts: [3000, 2000]Process finished with exit code 0
```> Note: The demo is similar to the example code in the "usage" section but more detailed