More tweaks

This commit is contained in:
Lars Tveito 2019-11-18 19:40:43 +01:00
parent 3e4c0d5561
commit 3bd283478c

View File

@ -32,7 +32,7 @@
| E: | 60 | | E: | 60 |
| F: | 30 | | F: | 30 |
Det er snakk om sensur i inf1300 med 566 besvarelser. D og E kan ikke rette Det er snakk om sensur i inf1300 med 283 besvarelser. D og E kan ikke rette
mot hverandre. De bør helst rette mot B eller C. mot hverandre. De bør helst rette mot B eller C.
Har du et bra forslag til meg? Jeg blir GAL. Det var bedre før, da jeg hadde Har du et bra forslag til meg? Jeg blir GAL. Det var bedre før, da jeg hadde
@ -167,18 +167,21 @@
from z3 import * from z3 import *
#+END_SRC #+END_SRC
This allows us to generate instances for Z3 to solve with Python. This allows us to generate instances with Python that Z3 can solve.
** Instances ** Instances
Let's formulate an instance as a four-tuple $(N, C, S, A)$ where Let's formulate an instance as a four-tuple $(N, C, S, A)$ where
- $N$ is the number of exams to correct - $N$ is the number of exams to correct
- $C$ is a list of capacities, where each examiner is identified by - $C$ is a list of capacities, where each examiner is identified by
her position of the list their position of the list
- $S$ is a relation, relating an examiner to one they /should/ form a - $S$ is a mapping from a single examiner to a set of examiners they
committee with /should/ form a committee with
- $A$ is a relation, relating examiners that we should /avoid/ placing in - $A$ is a symmetric relation, relating examiners that we should /avoid/
the same committee placing in the same committee
We define a committee as a set of exactly two examiners (identified by their
index in the list of capacities).
The instance, described in the introduction, can be represented with the The instance, described in the introduction, can be represented with the
following Python code: following Python code:
@ -205,18 +208,20 @@
The end result needs to be a set of committees, where each committee The end result needs to be a set of committees, where each committee
consists of two examiners with a number of exams to correct. An important consists of two examiners with a number of exams to correct. An important
part of finding a reasonable encoding is to balance what part of the problem part of finding a reasonable encoding is to balance what part of the problem
should be solved in pure Python and what should be solved by the SMT-solver. should be solved with Python and what should be solved by the SMT-solver. My
experience is that a good rule of thumb is to move as much structural
complexity to Python and encode the Z3 instance with simple structures.
** Modeling committees ** Modeling committees
A natural encoding could be modeling all possible committees as an integer A natural encoding could be modeling a committee as an integer constant,
constant, where the value assigned to a committee corresponds to the number where the value assigned to a committee corresponds to the number of exams
of exams they correct. they correct. It is quite easy to compute all possible committees, and make
one integer constant for each of them.
We let a committee be a set of two exactly two examiners, identified by Let's write a function that takes a list of capacities, and return a
their index in the capacity list. Let's write a function that takes a list dictionary, associating (Python) committees to their corresponding integer
of capacities, and return a dictionary, associating (Python) committees to constant.
their corresponding integer constant.
#+BEGIN_SRC python :tangle committees.py #+BEGIN_SRC python :tangle committees.py
def committees(C): def committees(C):
@ -226,11 +231,6 @@
return {c : Int(str(c)) for c in cs} return {c : Int(str(c)) for c in cs}
#+END_SRC #+END_SRC
# However, we also need to capture that each individual examiner don't have to
# correct more exams than their given capacity. A good rule of thumb in
# SMT-solving is to minimize the number of constants we need to find a
# interpretation for.
Now we must ensure that no examiner receives more exams than their capacity. Now we must ensure that no examiner receives more exams than their capacity.
Given an examiner $i$, where $0 <= i < N$, we let $c_i$ denote the set of Given an examiner $i$, where $0 <= i < N$, we let $c_i$ denote the set of
all committees $i$ participates in. Then $\sum{c_i} <= C[i]$, i.e. the sum all committees $i$ participates in. Then $\sum{c_i} <= C[i]$, i.e. the sum