-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata_generator.py
42 lines (38 loc) · 1.53 KB
/
data_generator.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 random
import argparse
class trial_data:
def __init__(self):
self.candidates = set()
self.courses = set()
self.candidate_preference = dict()
self.course_preference = dict()
self.qualification = dict()
self.course_capacity = dict()
def generate(num_candidate, num_course):
data = trial_data()
for i in range(num_candidate):
data.candidates.add('candidate' + str(i))
data.candidate_preference['candidate' + str(i)] = dict()
for i in range(num_course):
data.courses.add('course' + str(i))
data.course_preference['course' + str(i)] = dict()
data.course_capacity['course' + str(i)] = random.choice([1, 2, 3, 4, 5])
for candidate in data.candidates:
for course in data.courses:
data.candidate_preference[candidate][course] = round(random.uniform(0, 1), 1)
data.course_preference[course][candidate] = round(random.uniform(0, 1), 1)
for candidate in data.candidates:
data.qualification[candidate] = dict()
for course in data.courses:
prob = random.uniform(0, 1)
if prob < 0.8:
data.qualification[candidate][course] = 1
else:
data.qualification[candidate][course] = 0
return data
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--num_candidate', type=int)
parser.add_argument('--num_course', type=int)
args = parser.parse_args()
trial_data = generate(args.num_candidate, args.num_course)