Conversation
…ill be used for autgogen DRV logic.
…nt, search result and variable to recursively build a valid timetable.
Got rid of LockedSectionConstraint.java and replaced it with a VariableFactory that builds the required variables in such a way that if something has locked sections only those appear. This saves times and doesn't add wrong sections and go down the wrong path for no reason.
…ava to PotentialTimetable.java as per SeriousGuy's Comments.
Adds the blocked time constraint to the main PR so we can review it as a whole
|
Need to turn into clean architecture. |
…urning autogen use case into Clean architecture by implementing InputBoundary and Interactor.
|
Updated top comment with all new changes have been made. Autogen now abides by clean architecture (hopefully). |
SeriousGuy888
left a comment
There was a problem hiding this comment.
i may have written a lot of comments in the code
but they're mostly style concerns or typo fixes
the main thing that actually matters is
im a bit iffy still on the CourseVariableFactory class
(see comments there)
most things are good though
i don't think there's anything major to change
# Conflicts: # .idea/workspace.xml
…n-autogen fixed broken SaveWorkbookInteractorTest in autogen branch
# Conflicts: # .idea/workspace.xml
# Conflicts: # .idea/workspace.xml # src/main/java/app/AppBuilder.java
CarolineLyu
left a comment
There was a problem hiding this comment.
good work this was heavy lift
Timetable Autogeneration Usecase
This PR introduces a basic auto-generation system that uses a depth-first search (DFS) backtracking algorithm to produce a valid timetable based on course offerings, locked sections, and user-defined constraints.
Entities
CourseVariable: One course var each containing the course offering and domain of all it's sectionsTimeConflictConstraint(avoids conflicts between 2 sections) andBlockedTimeConstraint(checks that no section's meetings collide with blocked times provided)PotentialTimetable: This is a class used by the interactor to conduct it's searches. It returns a possible timetable-(a timetable that has been built) and a boolean- true if all constraints are met or else false.Interface Adapter
AutogenController: Converts UI-level selections (courses, locked sections, blocked blocks) intoAutogenInputDataand contains no business logic.AutogenPresenter: Bridges the gap between pure use-case output and UI state and separates success message and error message so the view can decide how to show eachUse_Case
Autogen Input Data
Bundles all inputs required by the use case:
Set<CourseCode> selectedCoursesSet<Section> lockedSectionsWeeklyOccupancy blockedTimesImmutable DTO to keep the interactor free of UI concerns.
AutogenOutputData
AutogenInputBoundary / AutogenOutputBoundary
Autogen Interactor:
execute: uses the AutogenInputData provided by the Controller to get necessary variables and constraint for generation algorithm to work using the AutogenDataAccessObject. Calls thebuildConstraintsandapplyLockhelpers to set up a proper constraint system.buildConstraints: Creates a list ofConstraintsor rules that the generated table needs to meet such asBlockedTimeConstraintandTimeConflictConstraint.applyLock: Goes through all the sections from the timetable that have been locked. If a certain section is locked it ensures that its CourseVariable only contains that section rather all the other sections it it's domain. This is can thought of as an automatic locking system, where it filters the locked sections for the timetable rather than introducing a new entity.generateTimetable: returns aPotentialTimetableby calling the recursive function timetableSearchtimetableSearch: THE MVP. Uses depth first search a recursive backtracking algorithm. The ideal base case occurs when all variables have been assigned. It acts like a tree- starts with an potential timetable which is initially empty. Picks a variable, and iterates through all it's sections. For each one it tries using that section and moves ahead to the next variable, essentially forming a tree path. Each time it meets a dead end, it backtracks and tries a different section. A dead end is met after each section in a variable doesn't return a successful result. In each loop, a isConsistent( timetable) is called where we check if the potential timetable so far is valid else we backtrack.isConsistent: Takes in a Timetable and ensures that it meets all the necessary rules by looping through the list of constraints. Returns a boolean, true if all constraints are met else false.UI Integration (View)
GlobalView(affected byGlobalPresenterviaAutogenPresenter) creates a new tab on the workbook with the brand new timetable loaded inData Access
AutogenDataAccessObject, has a methodgetSelectedCourseOfferingswhich gets all the sections for a course that has been selected on the timetable. This is done by using aJsonCourseDataRepositoryobject that holds the mappings to all courses and their domains.Tests
Update: Full Coverage done in later PR- Autogen update tests
Design/SOLID Notes
Single Responsibility Principle
Open/Closed Principle
New constraints (e.g., professor preference, campus location) can be added by:
Dependency Inversion Principle
TODO;
TLDR; Finished Autogen Implementation, and applied clean architecture, need to finish data tut-section mapping