```{r installation, eval = FALSE} devtools::install_github("nourqweder/AdvRLab6", build_vignettes = TRUE)
### 1.1.2 Brute force search
## *Question*:
### How much time does it takes to run the algorithm for n = 16 objects?
**Answer:**
```{r, echo=TRUE, eval=TRUE, message=FALSE}
system.time(brute_force_knapsack(x = knapsack_objects[1:16,], W = 3500))
```{r, echo=TRUE, eval=TRUE, message=FALSE} profvis(brute_force_knapsack(x = knapsack_objects[1:16,], W = 3500))
### 1.1.3 Dynamic Programming
## *Question*:
### How much time does it takes to run the algorithm for n = 500 objects?
```{r, echo = TRUE, eval = FALSE, message = FALSE, results='asis'}
system.time(knapsack_dynamic(x = knapsack_objects[1:500,], W = 3500))
```{r, echo = TRUE, eval = FALSE, message = FALSE, results='asis'} profvis(knapsack_dynamic(x = knapsack_objects[1:500,], W = 3500))
**Answer:**
### 1.1.4 Greedy heuristic
## *Question*:
### How much time does it takes to run the algorithm for n = 1000000 objects?
```{r, echo=TRUE, eval=FALSE, message=FALSE, results='asis'}
system.time(greedy_knapsack(x = knapsack_objects[1:1000000,], W = 3500))
Answer:
NOTE: Package lineprof
is not available for R version 3.6.1, so we will use package profvis
instead.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.