-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_generations.py
42 lines (32 loc) · 1.04 KB
/
test_generations.py
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
import pandas as pd, random, optimality
"""
Generations of some of the deterministic tests.
"""
def make_tests():
gen_small()
gen_medium()
gen_large()
def gen(N, K, csv_filename):
"""Generate any test."""
preferences = [random.sample(range(N), K) for _ in range(N)]
pd.DataFrame(preferences).to_csv('tests/' + csv_filename + '.csv', index=None, header=None)
optimal_val = optimality.find_global_optima(preferences)
optimals = pd.read_csv('tests/optimals.csv')
optimals.loc[optimals.shape[0]] = ([csv_filename,optimal_val])
optimals.to_csv('tests/optimals.csv', index=None)
def gen_small():
"""Generate small test"""
N = random.randint(50, 100)
K = random.randint(30, N)
gen(N, K, 'small_determ')
def gen_medium():
"""Generate medium test"""
N = random.randint(100, 500)
K = random.randint(100, N)
gen(N, K, 'medium_determ')
def gen_large():
"""Generate large test"""
N = random.randint(1000, 5000)
K = random.randint(750, N)
gen(N, K, 'large_determ')
make_tests()