This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
example2.py
50 lines (44 loc) · 1.81 KB
/
example2.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
43
44
45
46
47
48
49
50
"""
an example about how to load data and generate a schedule
"""
import CourseScheduling as cs
from DataHelper.loadData import DataLoading
import time
__author__ = "Jenny Zeng"
__email__ = "[email protected]"
if __name__ == '__main__':
start_time = time.time()
# config upper standing units
upper_units = 10
# load taken info
startQ, applied_units, taken = DataLoading.load_taken(filename="test/taken.txt")
# load avoid info
avoid = DataLoading.load_avoid(filename="test/avoid.txt")
# load graph, config if user is upper standing
G = DataLoading.load_courses(prereq_filename="test/testcourses.txt",
show_upper=cs.is_upper_standing(applied_units, upper_units))
# load requirement sheet
R_detail, R = DataLoading.load_requirements(
requirements=["firstReq","secondReq"],
filename="test/test_spec.txt")
# update requirement table based on the taken information
cs.update_requirements(R_detail, R, taken)
# load max width for each quarter
max_widths = DataLoading.load_width_func_table("test/test_widthFunc.txt")
# construct CourseGraph. graph is labeled after init
graph = cs.CourseGraph(G, r_detail=R_detail, R=R, avoid=avoid, taken=taken)
# construct Schedule with width func requirements
L = cs.Schedule(widths=max_widths)
# construct the scheduling class
generator = cs.Scheduling(start_q=startQ)
# get the best schedule when the upper bound ranges from 0 to 10, inclusive.
L, best_u, best_r = generator.get_best_schedule(graph, L, R, 0, 10)
print(L)
print(best_u)
print(R_detail)
print(best_r)
print(graph)
print("--- %s seconds ---" % (time.time() - start_time))
# in terminal, type:
# python -m cProfile example.py
# to see the time and calls for each function