enumerateCombinations: enumerate combination

Description Usage Arguments Details Value Examples

Description

This function is based on the output of analyseShoppingCart(). Using the mathematical partition function from the package partitions every combination is enumerated. Afterwards the combinations are filtered so only combinations are returned which make sense for the practical utilization.

Usage

1
enumerateCombinations(listFromASC, intermediateSteps = FALSE)

Arguments

listFromASC

list as it comes from analyseShoppingCart()

intermediateSteps

logical; if TRUE, additionally a list is returned which contains the intermediate steps. More in details; default is FALSE

Details

If intermediateSteps is set to TRUE, the output of this function will change to a list of length 2. The first element will be the same matrix as it is produced with intermediateSteps == FALSE. The second element is a list containing the intermediate steps which are done within this function. These steps include: 1. Enumerate every possible partition using partitions::restrictedparts(). 2. filter1: Since we have only up to five different items in the shopping cart and discount is given for the items' dissimilarity, the greatest 'discount set' can only be the number of different items in the shopping cart. 3. filter2: Accordingly the smallest summand need to be greater or equal to the 'number of maxima' in our shopping cart. This filter minimizes the combinations of partitions which can't lead to a discount set later on. Because there are still some combinations of partitions that can't be a discount set, another function is necessary to point only the possible discount sets out.

Value

Depending on intermediateSteps a matrix or a list is returned. Matrix represents the combinations which shall be used for calculating the discount.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
```
### setup
books <- dplyr::tibble(
  itemID = 1:5,
  name = c(
    "Stein der Weisen",
    "Kammer des Schreckens",
    "Gefangene von Askaban",
    "Feuerkelch",
    "Orden des Phönix"
  )
)
set.seed(1) # for reproducibility
shoppingCart <- dplyr::sample_n(books, 8, replace = TRUE)
shoppingCart <- dplyr::arrange(shoppingCart, itemID)
ls <- analyseShoppingCart(shoppingCart, itemID, name)
### end of setup
enumerateCombinations(ls)
```

frumentum/BuyPotterSaveMoney documentation built on May 15, 2019, 10:49 a.m.