我有一群人每个都提交了一个会议的演示文稿。每个演示文稿需要由其他提交者审核7次,但没有提交者应该审核自己的演示文稿。我想随机分配每个人审查7个演示文稿,每个演示文稿只审核7次,没有人审查自己的演示文稿。随机分配数据
实施例的数据:
DT = data.frame(First_Name = letters[1:10], Presentation = 1:10)
我公开在R或Excel中这样做。任何帮助表示赞赏。
我有一群人每个都提交了一个会议的演示文稿。每个演示文稿需要由其他提交者审核7次,但没有提交者应该审核自己的演示文稿。我想随机分配每个人审查7个演示文稿,每个演示文稿只审核7次,没有人审查自己的演示文稿。随机分配数据
实施例的数据:
DT = data.frame(First_Name = letters[1:10], Presentation = 1:10)
我公开在R或Excel中这样做。任何帮助表示赞赏。
使用的Excel被表示为具有10个顶点,每度7.
这里是在库中一种这样的方法的曲线图该组中的成员列A:
和运行此宏:
Sub Reviewers()
Dim N As Long, i As Long, j As Long, rA As Range
N = Cells(Rows.Count, "A").End(xlUp).Row
Set rA = Range("A1:A" & N)
'
'----------------------------------PART 1
'
For i = 1 To N
j = i + 1
rA.Copy Cells(1, j)
Cells(i, j).Delete shift:=xlUp
Next i
'
'---------------------------------PART 2
'
For i = 2 To N + 1
Call SkrambleRange(Range(Cells(1, i), Cells(N - 1, i)))
Next i
End Sub
Sub SkrambleRange(rng As Range)
Dim arr(), r As Range, i As Long
ReDim arr(1 To rng.Count)
i = 1
For Each r In rng
arr(i) = r.Value
i = i + 1
Next r
Call Shuffle(arr)
i = 1
For Each r In rng
r.Value = arr(i)
i = i + 1
Next r
End Sub
Public Sub Shuffle(InOut() As Variant)
Dim i As Long, j As Long
Dim tempF As Double, Temp As Variant
Hi = UBound(InOut)
Low = LBound(InOut)
ReDim Helper(Low To Hi) As Double
Randomize
For i = Low To Hi
Helper(i) = Rnd
Next i
j = (Hi - Low + 1) \ 2
Do While j > 0
For i = Low To Hi - j
If Helper(i) > Helper(i + j) Then
tempF = Helper(i)
Helper(i) = Helper(i + j)
Helper(i + j) = tempF
Temp = InOut(i)
InOut(i) = InOut(i + j)
InOut(i + j) = Temp
End If
Next i
For i = Hi - j To Low Step -1
If Helper(i) > Helper(i + j) Then
tempF = Helper(i)
Helper(i) = Helper(i + j)
Helper(i + j) = tempF
Temp = InOut(i)
InOut(i) = InOut(i + j)
InOut(i + j) = Temp
End If
Next i
j = j \ 2
Loop
End Sub
第1部分产生评价者对每个提交者的列表。所以第B是Mary Smith (Mary Smith自己的名字已被删除)的评论列表;列ç是帕特里夏·约翰逊审稿列表等
第2个部分每个评审列:
要得到7个审稿玛丽·史密斯,拉头7洗牌来自列B的名称。
要获取Patricia Johnson的7位审阅者,请从列C等中提取前7个名称。
下面是使用线性编程的解决方案。 (由Randomly assign elements repeatedly to a limited number of groups和https://acoppock.github.io/subpages/Random_Assignment_Subject_To_Constraints.html启发)
library(lpSolve)
library(tidyverse)
df <-
# get all possible person-presentation combinations
expand.grid(person = letters[1:10], presentation = 1:10) %>%
mutate(person_number = match(person, letters)) %>%
# throw out self-matches
filter(presentation != person_number)
# Two constraints:
# each presentation is reviewed 7 times.
# Each person conducts 7 reviews
first <- t(sapply(1:10, function(i) as.numeric(df$presentation == i)))
second <- t(sapply(letters[1:10], function(i) as.numeric(df$person == i)))
const.mat <- rbind(first, second)
const.dir <- rep(c("=", "="), c(10, 10))
const.rhs <- rep(c(7, 7), c(10, 10))
# This is the acutal stochastic part
random_objective <- runif(ncol(const.mat))
mod <- lp(
direction = "max",
objective.in = random_objective,
const.mat = const.mat,
const.dir = const.dir,
const.rhs = const.rhs,
all.bin = TRUE
)
df$assign_review <- mod$solution
with(df, table(assign_review))
with(df, table(assign_review, presentation))
with(df, table(assign_review, person))
这产生输出作为期望:
> with(df, table(assign_review, presentation))
presentation
assign_review 1 2 3 4 5 6 7 8 9 10
0 2 2 2 2 2 2 2 2 2 2
1 7 7 7 7 7 7 7 7 7 7
> with(df, table(assign_review, person))
person
assign_review a b c d e f g h i j
0 2 2 2 2 2 2 2 2 2 2
1 7 7 7 7 7 7 7 7 7 7
有多少人的组中?? –
我们有142个人 – josh453
我的解决方案可以使用任何编号...............见下文........... –