The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
This package solves multiple knapsack problem by assigning items optimally to knapsacks using Mixed Integer Linear Programming (MILP) solver of choice.
We start with a list of items that we want to order with each assigned a:
Those items should be optimally packed into multiple containers of the a given size (cap). Items should be aded to containers in the way that each container is more profitable than the following one.
Package implements interface to several solvers which can be set via
mknapsack.solver
option.
Currently you can choose from those options:
lpsolve
is default option.
Solve problem with CBC COIN-OR solver:
set.seed(100)
::install_github("dirkschumacher/rcbc")
devtools::install_github("dirkschumacher/ROI.plugin.cbc")
devtools::install_github("madedotcom/mknapsack")
devtoolslibrary(rcbc)
library(ROI)
library(ROI.plugin.cbc)
library(data.table)
library(mknapsack)
options(mknapsack.solver = "cbc")
<- data.table(
items volume = pmin(rlnorm(100, log(2), log(3)), 15),
profit = rgamma(100, shape = 1, scale = 100) - 25
)
:=
items[, knapsack mknapsack(
profit = profit,
volume = volume,
cap = 65
)]
#Aggregate solution to knapsacks
<- items[order(knapsack),
knapsacks volume = sum(volume), profit = sum(profit)),
.(= knapsack]
by
knapsacks
# knapsack volume profit
# 1: 1 64.89659 5000.27608
# 2: 2 64.40358 1540.40302
# 3: 3 64.97235 340.92516
# 4: 4 53.33824 88.02793
# 5: NA 91.13399 -272.54349
#
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.