"**Warning**: Depending on the slot size and the number of papers, this approach gets very slow very fast. It is recommended to limit the number of papers and `max_slot_size`.\n",
"\n",
"</div>"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
"id": "d737af19",
"id": "ea63212b",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -232,22 +244,7 @@
...
@@ -232,22 +244,7 @@
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
"id": "067ea4ea",
"id": "05dd3bc9",
"metadata": {},
"outputs": [],
"source": [
"def score_paper(paper) -> int:\n",
" if len(paper.reviewers) > 0:\n",
" review_score = 2 - abs(paper.score)\n",
" return review_score\n",
" else:\n",
" return 0"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "23670286",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -274,28 +271,6 @@
...
@@ -274,28 +271,6 @@
" return True"
" return True"
]
]
},
},
{
"cell_type": "markdown",
"id": "b96637c3",
"metadata": {},
"source": [
"## The Models"
]
},
{
"cell_type": "markdown",
"id": "dd6a6099",
"metadata": {},
"source": [
"### Slow approach\n",
"\n",
"<div class=\"alert alert-warning\">\n",
" \n",
"**Warning**: Depending on the slot size and the number of papers, this approach gets very slow very fast. It is recommended to limit the number of papers and `max_slot_size`.\n",
This notebook shows a example of how to user linear programming to solve following optimization problem.
This notebook shows a example of how to user linear programming to solve following optimization problem.
## Problem Description
## Problem Description
Given a set of papers, a set of reviewers, which are a assigned to the papers a and set of time slots from which the reviewers selected their availabilty, we want to assign the papers to time slots in such a way that the optimal number of papers can be discussed with the reviewers. Papers with disagreeing reviews, i.e. the paper score is close to 0, should be assigned with higher priority.
Given a set of papers, a set of reviewers, which are a assigned to the papers a and set of time slots from which the reviewers selected their availabilty, we want to assign the papers to time slots in such a way that the optimal number of papers can be discussed with the reviewers. Papers with disagreeing reviews, i.e. the paper score is close to 0, should be assigned with higher priority.
## General approach
## General approach
In this notebook, we present two approaches. The first one does not scale very well and gets very slow with growing datasets. The second one scales well.
In this notebook, we present two approaches. The first one does not scale very well and gets very slow with growing datasets. The second one scales well.
### Slow approach
### Slow approach
1. Create all possible combinations of papers given the maximum number of papers for a time slot.
1. Create all possible combinations of papers given the maximum number of papers for a time slot.
2. Remove combinations which are impossible to satisfy because authors have conflicting time slot preferences.
2. Remove combinations which are impossible to satisfy because authors have conflicting time slot preferences.
3. Add a contraint to limit the number of time slots.
3. Add a contraint to limit the number of time slots.
4. Add a constraint to make sure that a paper can only appear in up to one time slot.
4. Add a constraint to make sure that a paper can only appear in up to one time slot.
5. Solve.
5. Solve.
### Fast approach
### Fast approach
1. Create a binary variable for every combination of paper and time slot. This variable indicates whether a paper is assigned to a time slot.
1. Create a binary variable for every combination of paper and time slot. This variable indicates whether a paper is assigned to a time slot.
2. Fix variables which should never be True to False. This is the case if there are time slot preferences but none match the given slot.
2. Fix variables which should never be True to False. This is the case if there are time slot preferences but none match the given slot.
3. Add a constraint to make sure that a paper can only appear in up to one time slot.
3. Add a constraint to make sure that a paper can only appear in up to one time slot.
**Warning**: Depending on the slot size and the number of papers, this approach gets very slow very fast. It is recommended to limit the number of papers and `max_slot_size`.
</div>
%% Cell type:code id:ea63212b tags:
```
```
def score_time_slot(time_slot) -> int:
def score_time_slot(time_slot) -> int:
'''
'''
Takes a time slot (i.e. a list of papers) and calculates a score.
Takes a time slot (i.e. a list of papers) and calculates a score.
The scores takes the number of papers in the time slot and the review score into account.
The scores takes the number of papers in the time slot and the review score into account.
'''
'''
paper_count = len(time_slot)
paper_count = len(time_slot)
if paper_count == 1:
if paper_count == 1:
if len(time_slot[0].reviewers) > 0:
if len(time_slot[0].reviewers) > 0:
review_score = 2 - abs(time_slot[0].score)
review_score = 2 - abs(time_slot[0].score)
return paper_count + review_score
return paper_count + review_score
else:
else:
return 0
return 0
result = paper_count
result = paper_count
for p in time_slot:
for p in time_slot:
review_score = 2 - abs(p.score)
review_score = 2 - abs(p.score)
if len(p.reviewers) == 1:
if len(p.reviewers) == 1:
result += review_score
result += review_score
elif len(p.reviewers) > 1:
elif len(p.reviewers) > 1:
result += review_score
result += review_score
# for multiple reviewers, we could also take into account the number of reviewers or how many
# for multiple reviewers, we could also take into account the number of reviewers or how many
# reviewers are available at the same time, but currently this is not used
# reviewers are available at the same time, but currently this is not used
# all_ts_lists = []
# all_ts_lists = []
# for rev in p.reviewers:
# for rev in p.reviewers:
# if len(rev.time_slots) > 0:
# if len(rev.time_slots) > 0:
# all_ts_lists.append(rev.time_slots)
# all_ts_lists.append(rev.time_slots)
# inters = set.intersection(*[set(x) for x in all_ts_lists])
# inters = set.intersection(*[set(x) for x in all_ts_lists])
# if len(inters) > 0:
# if len(inters) > 0:
# result += review_score
# result += review_score
return result
return result
```
```
%% Cell type:code id:067ea4ea tags:
%% Cell type:code id:05dd3bc9 tags:
```
def score_paper(paper) -> int:
if len(paper.reviewers) > 0:
review_score = 2 - abs(paper.score)
return review_score
else:
return 0
```
%% Cell type:code id:23670286 tags:
```
```
def check(time_slot) -> bool:
def check(time_slot) -> bool:
'''
'''
Takes a time slot (i.e. a list of papers) and checks if there are any contradictions, i.e., for every paper
Takes a time slot (i.e. a list of papers) and checks if there are any contradictions, i.e., for every paper
with at least one reviewer, there is a time slot where at least one reviewer for every paper is available.
with at least one reviewer, there is a time slot where at least one reviewer for every paper is available.
'''
'''
all_ts_lists = []
all_ts_lists = []
for p in time_slot:
for p in time_slot:
all_p_ts = []
all_p_ts = []
for rev in p.reviewers:
for rev in p.reviewers:
if len(rev.time_slots) > 0:
if len(rev.time_slots) > 0:
all_p_ts.extend(rev.time_slots)
all_p_ts.extend(rev.time_slots)
all_ts_lists.append(all_p_ts)
all_ts_lists.append(all_p_ts)
if len(all_ts_lists) > 0:
if len(all_ts_lists) > 0:
result = len(set.intersection(*[set(x) for x in all_ts_lists]))
result = len(set.intersection(*[set(x) for x in all_ts_lists]))
return result >= 1
return result >= 1
else:
else:
return True
return True
```
```
%% Cell type:markdown id:b96637c3 tags:
## The Models
%% Cell type:markdown id:dd6a6099 tags:
### Slow approach
<divclass="alert alert-warning">
**Warning**: Depending on the slot size and the number of papers, this approach gets very slow very fast. It is recommended to limit the number of papers and `max_slot_size`.