mknapsack {mknapsack} | R Documentation |
Optimal packing into multiple containers
Description
Gets containers based on the utility of individual items, their volume and container size
Usage
mknapsack(profit, volume, moq = rep(0, length(profit)), cap = 65,
sold = rep(0, length(profit)))
Arguments
profit |
vector with profit for item |
volume |
vector of item sizes in cubic meters |
moq |
vector of flags where 1 means that row contans mininum order quantity (MOQ). Defaults to zero vector matching profit in length. |
cap |
size of the container in cubic meters |
sold |
vector with a number of items that were sold on demand |
Value
vector with container numbers keeping the permutation of the original data
Examples
# Calculate the optimal containers summary for a sample dataset
data(unitsbro)
library(data.table)
units.combined <- data.table(unitsbro)
moq <- units.combined$moq
profit <- units.combined$utility
volume <- units.combined$volume
res <- mknapsack(profit, volume, moq, 65)
units.combined$container <- as.factor(res)
#Aggregate solution to container
containers <- units.combined[order(container), .(volume = sum(volume),
profit = sum(profit)), by = container]
[Package mknapsack version 0.1.0 Index]