Skip to content

Commit b198d58

Browse files
authored
Merge pull request #1 from Benezivas/oldproblems
Include problems from the algobattle directory, s.t. they can be removed from that repository.
2 parents bb10a9d + 4c5b87f commit b198d58

File tree

167 files changed

+3571
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+3571
-1
lines changed

.github/workflows/python-app.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Algorithmic Battle - Problem Files
5+
6+
on:
7+
push:
8+
branches: [ main, develop ]
9+
pull_request:
10+
branches: [ main, develop ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python 3.9
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.9
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install flake8 flake8-docstrings
27+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28+
git clone https://github.com/Benezivas/algobattle.git
29+
cd algobattle && pip install . --user && cd ..
30+
- name: Lint with flake8
31+
run: |
32+
# stop the build if there are Python syntax errors or undefined names
33+
flake8 . --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics --exclude algobattle
34+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
35+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics \
36+
--per-file-ignores="__init__.py:F401,D104 */solver/main.py:D100 */generator/main.py:D100" \
37+
--docstring-convention numpy --ignore=D100,D105,D102,W503 --exclude algobattle
38+
- name: Test with unittest
39+
run: |
40+
python -m unittest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Clone the [algobattle](https://github.com/Benezivas/algobattle) repository:
77
git clone https://github.com/Benezivas/algobattle.git
88
```
99
Follow the installation and usage instructions in the `README`.
10-
Use the problem folders as input paths for the `battle` script.
10+
Use the specific problem folders as input paths for the `battle` script.

problems/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Problem Files used in Practice
2+
This directory contains several problem tasks that you may use for your
3+
students. Each problem directory contains a `README.md` describing the problem
4+
and the I/O that the generator and solver use. The `generator` and `solver`
5+
directories contain dummy solvers that output instances which are technically
6+
legal, but rather unexiting.
7+
8+
The simplest problem is currently the `pairsum` problem, which well suited as a
9+
primer task at the start of the lab. For this task, a simple randomized
10+
generator and solver are implemented which you may use for to see how the
11+
program behaves when the solver runs into a timeout at some instance size.

problems/biclique/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# The Bipartite Clique Problem
2+
The *Bipartite Clique* problem is closely related to the *Maximum Clique*
3+
problem. In it, we want to find the biggest complete bipartite subgraph in a
4+
given Graph.
5+
6+
**Given**: Undirected graph `G = (V,E)` with `|V(G)| = n`
7+
**Problem**: Find the biggest subgraph `G' = (V_1 union V_2, E')` of `G` such that
8+
`G' = K_{i,j}`
9+
10+
The generator is given an instance size and outputs an undirected graph of at most this size.
11+
Along with the graph, it outputs a certificate solution for the biggest
12+
bipartite clique of the graph that it knows.
13+
14+
The solver then receives this graph and has to find a bipartite clique of
15+
maximum size within the time limit and output it. The solution is valid if its
16+
size is at least as big as the certificate solution of the generator.
17+
18+
# I/O
19+
We use a format similar to the DIMACS-format for this task:
20+
* **Edges**: These lines are of the form `e i j`
21+
for an edge `(i,j) in E(G)`. As we are working on an undirected graph,
22+
the symmetrical edge `(j,i)` does not need to be supplied.
23+
* **Solution lines**: For each node `i` of `V_1(G')` add a line `s set1 i`,
24+
accordingly a line `s set2 j` for each node `j` of `V_2(G')`.
25+
26+
Isolated nodes can not be part of a bipartite clique, thus this format does not
27+
allow supplying them in an instance.
28+
29+
Any malformed lines or lines not following the format above are discarded.
30+
Each of the lines described above are to be written into their own line.
31+
The generator reads the instance size from `stdin` and writes its instance
32+
and certificate to `stdout`. The order of the lines does not matter. For an
33+
instance size of `n`, vertices may only be given indices in `{1,...,n}`.
34+
35+
The following output is a valid stream to stdout for the generator, given
36+
`n >= 10` (line breaks inserted for better readability):
37+
```
38+
The described graph contains a K_{2,3} between {7,9} and {6,8,10}\n
39+
s set1 7\n
40+
s set1 9\n
41+
s set2 6\n
42+
s set2 8\n
43+
s set2 10\n
44+
e 1 2\n
45+
e 2 3\n
46+
e 2 8\n
47+
e 8 5\n
48+
e 8 10\n
49+
e 8 7\n
50+
e 6 5\n
51+
e 6 7\n
52+
e 6 9\n
53+
e 10 9\n
54+
e 10 7
55+
```
56+
The solver receives all edge lines, seperated by line breaks, just like above,
57+
via `stdin`. It is then supposed to output edge sets `E'` and `E''` as described
58+
above to `stdout`. The solution may deviate from that of the generator.
59+
60+
For the instance above, a valid output of the solver may look like this:
61+
```
62+
s set1 8\n
63+
s set1 6\n
64+
s set1 10\n
65+
s set2 9\n
66+
s set2 7
67+
```

problems/biclique/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .problem import Biclique as Problem
205 Bytes
Binary file not shown.
2.38 KB
Binary file not shown.
646 Bytes
Binary file not shown.
2.4 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM python:3
2+
3+
COPY main.sh /
4+
COPY main.py /
5+
6+
CMD ["./main.sh"]

0 commit comments

Comments
 (0)