update readme/previews and add generate data method

This commit is contained in:
SowinskiBraeden committed 2022-08-18 00:15:39 -07:00
1 parent 0bad75a302
commit 8dac93bb9b
4 files changed
+52 -4

No files matched your search

+25 -1
View File
@@ -6,13 +6,37 @@ The algorithm reads student requests and generates a timetable for all requested
The algorithm has been moved out of `tinker.py` into its own python script. Version 1 and 2 are removed and the script can be found in the `/scheduleGenerator` folder. The algorithm has come a long way; using real 2018 course selection data from my school, enabling me to better test the script. V3 has a entirely different approach from V1 and V2, that you can read about at the top of the function in [`generator.py`](/scheduleGenerator/generator.py). The function is broken up into 6 steps, each step is labeled within the function with a comment, giving a brief explination of what that step contributes to the algorithm. The algorithm has been moved out of `tinker.py` into its own python script. Version 1 and 2 are removed and the script can be found in the `/scheduleGenerator` folder. The algorithm has come a long way; using real 2018 course selection data from my school, enabling me to better test the script. V3 has a entirely different approach from V1 and V2, that you can read about at the top of the function in [`generator.py`](/scheduleGenerator/generator.py). The function is broken up into 6 steps, each step is labeled within the function with a comment, giving a brief explination of what that step contributes to the algorithm.
This is the output after running it with the following command Here is the list of commands.
1. Collect latest data from files and generate timetable
``` ```
$ ./tinker.py $ ./tinker.py
``` ```
2. Collect Data and store it in files for later
```
$ ./tinker.py generate_data
```
3. Generate timetable from existing files (faster), requires last command run
```
$ ./tinker.py no_refresh
```
4. More details on errors
```
$ ./tinker.py errors
```
<br>
This is the output after running it with the following command.
```
$ ./tinker.py no_refresh
```
![preview](/preview/generator-preview.png) ![preview](/preview/generator-preview.png)
<br>
A more in depth error log can be read with the additional argument A more in depth error log can be read with the additional argument
``` ```
Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 24 KiB

+27 -3
View File
@@ -1,4 +1,5 @@
#! python #! python
from os.path import exists as file_exists
from prettytable import PrettyTable from prettytable import PrettyTable
from typing import Tuple from typing import Tuple
from time import time, sleep from time import time, sleep
@@ -79,11 +80,18 @@ if __name__ == '__main__':
errors, _, _ = errorOutput(sampleStudents) errors, _, _ = errorOutput(sampleStudents)
print(errors) print(errors)
elif sys.argv[1].lower() == "norefresh" or sys.argv[1].lower() == "no_refresh": with open("./output/timetable.json", "w") as outfile:
json.dump(timetable, outfile, indent=2)
elif sys.argv[1].lower() == "no_refresh":
print('\nGenerating...\n') print('\nGenerating...\n')
st = time() # Start time st = time() # Start time
if not file_exists('./output/students.json') or not file_exists('./output/courses.json'):
print('\n No previous data exists, please use the following command\n./tinker.py generate_data')
exit()
with open('./output/students.json') as f: sampleStudents = json.load(f) with open('./output/students.json') as f: sampleStudents = json.load(f)
with open('./output/courses.json') as f: sampleCourses = json.load(f) with open('./output/courses.json') as f: sampleCourses = json.load(f)
@@ -106,6 +114,24 @@ if __name__ == '__main__':
errors, _, _ = errorOutput(sampleStudents) errors, _, _ = errorOutput(sampleStudents)
print(errors) print(errors)
with open("./output/timetable.json", "w") as outfile:
json.dump(timetable, outfile, indent=2)
elif sys.argv[1].lower() == "generate_data":
t = threading.Thread(target=processing, args=('Collection student requests',))
t.start() # Start animation
_ = getSampleStudents("./sample_data/course_selection_data.csv", True)
done = True # End Animation
print('\nStudent list generated.\n')
t = threading.Thread(target=processing, args=('Collection Course Information',))
done = False # reset animation
t.start() # Start animation
_ = getSampleCourses("./sample_data/course_selection_data.csv", True)
done = True # End Animation
print('\nCourse Information Collected.\n')
print('You can now use the following command\n./tinker.py no_refresh')
elif sys.argv[1].upper() == "ERRORS": elif sys.argv[1].upper() == "ERRORS":
f = open('./output/students.json') f = open('./output/students.json')
studentData = json.load(f) studentData = json.load(f)
@@ -128,5 +154,3 @@ if __name__ == '__main__':
print("Invalid argument") print("Invalid argument")
exit() exit()
with open("./output/timetable.json", "w") as outfile:
json.dump(timetable, outfile, indent=2)