FancyPackRLiU6-package: Knapsack

Description Details Author(s) References Examples

Description

Solve a test Knapsack problem with different coding methods

Details

The DESCRIPTION file: This package was not yet installed at build time.

Index: This package was not yet installed at build time.
The package presents three typical ways of resolving Knapsack problem, with brutal force, dynamic programing and approximate solutions. By means of exploring different computing complexities, a better understanding of fast code has been reached. brute_force_knapsack(x,W) knapsack_dynamic(x,W) greedy_knapsack(x,W)

Author(s)

Jun Li

Maintainer: Jun Li <junli559@student.liu.se>

References

https://en.wikipedia.org/wiki/Knapsack_problem

Examples

1
2
3
4
5
6
7
set.seed(42)
n<- 2000
knapsack_objects<-data.frame(
    w=sample(1:4000, size = n, replace = TRUE),
    v=runif(n = n, 0, 10000))
system.time(brute_force_knapsack(x = knapsack_objects[1:16,], W = 3500))[2]
system.time(knapsack_dynamic(x = knapsack_objects[1:500,], W = 3500))[2]

LiU-Task/FancyPackRLiU6 documentation built on Oct. 30, 2019, 8:24 p.m.