-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
54 lines (36 loc) · 1.71 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
output: github_document
---
# GroupAssignment
## Documentation
## Installation
```r
devtools::install_github("hkunda/GroupAssignment")
```
### Inputs
@rankings [NumericMatrix]: a matrix of rankings for each student. The ith row corresponds to student i,
and the jth column corresponds to the student in position j on any student's ranking list. If there are
N students, then each student should have an ID in the range [1,N], which is used both as the row index
(to refer to a student's rankings) and entries of the matrix. For example, if rankings[i,j] = k, then
student i has placed student k in position j on i's ranking.
@students [int]: the number of students. This should be equal to the number of rows in @rankings.
@leaders [int]: the number of leaders to pick; equivalently, the number of groups to form.
@minGroupSize [int]: the minimum number of students in a group. NOTE: this value does include the group
leader. So if minGroupSize = 4, then every group must consist of 1 leader and at least 3 other students.
@maxGroupSize [int]: the maximum number of students in a group. NOTE: this value does include the group
leader. So if maxGroupSize = 6, then every group must consist of 1 leader and at most 5 other students.
### Outputs
Returns a NumericVector of length students+1. The ith element of the output is the id of the student
leading the group that student i is in (for 0 <= i <= N). The N+1st element of the output is the total
cost of the optimal matching.
### Examples
```{r Simple example}
library(igraph)
library(GroupAssignment)
set.seed(712)
x <- sample_smallworld(1, 20, 4, .1)
d <- distances(x) + 1
d <- max(d) - d + 1
ans <- optimalAssignment(d, leaders = 3, minGroupSize = 2, maxGroupSize = 10)
ans
```