Skip to content

ayush-saklani/classsync-generator

Repository files navigation

This is the all new addition to the ClassSync where we are introducing the automation in timetable generation using genetic algorithm.
(currently in the Finalizing-coding-ish phase of development)

Steps to follow

  1. Get whole teacher allocated timetable, room data and faculty data from the mongoDB database
    classsync.tables.json,
    classsync.rooms.json,
    classsync.faculties.json
  2. Run ABconvert.js which converts the Class-Sync data into the format required by this genetic algorithm.
  3. The converted data format is saved as
    classsync.converted.tables.json,
    classsync.converted.faculties.json,
    classsync.converted.rooms.json
  4. Run algorithm.js to run the algorithm and get the best solution saved as classsync.win.selected.tables.json
  5. Run AB.Reverse.convert.js which converts the data format required by this genetic algorithm into the Class-Sync data format.
  6. Run faculty.reverse.js which converts the faculty data format to Class-Sync data format.
  7. Run room.reverse.js which converts the data format to Class-Sync data format.
  8. Run DBupload.js which uploads the converted data back to the MongoDB database which can be reflected to the Class-sync Website or downloaded for recirculation. (the data can be ironed out from here)
  9. Outputs of the algorithm.
    classsync.backtonormal.tables.json,
    classsync.backtonormal.faculties.json,
    classsync.backtonormal.rooms.json

Languages, Frameworks and Tools

Architecture and Algorithm Flow


This is an abstract representation of our data structure as timetable set


Step Description
Data Collection Gather all necessary data including teacher availability, room availability, and subject requirements.
Initial Population Generation Create an initial set of possible timetables (population).
Fitness Evaluation Evaluate each timetable based on predefined criteria such as teacher conflicts, room conflicts, and adherence to subject requirements.
Selection Select the best-performing timetables to serve as parents for the next generation.
Crossover and Mutation Generate new timetables by combining parts of the selected parents and introducing small random changes (mutations).
Iteration Repeat the evaluation, selection, and crossover/mutation steps for several generations until an optimal timetable is found.
Final Timetable Select the best timetable from the final generation as the solution.

This process ensures that the generated timetable is optimized for the given constraints and requirements.

Data Structure Used

{
    "fitness": 0,
    "data":[
        {
            "local_fitness": 0,
            "course": "",
            "semester": "",
            "section": "A1",
            "joint": true,  // false if not joint
            "merged_section": [
                "A2"
            ],
            "timetable": [
                [{ "roomid": "", "teacherid": "", "subjectid": "", "type": ""}, ........ for 10 periods ],
                [{ "roomid": "", "teacherid": "", "subjectid": "", "type": ""}, ........ for 10 periods ],
                .
                .
                .
                .
                .... for 7 days a week
            ],
            "subjects": [
                {
                    "subjectid": "TEST1",
                    "teacherid": "2118526",
                    "weekly_hrs": 3,
                    "type": "theory",
                    "room_type": "class"
                },
                {
                    "subjectid": "PTEST1",
                    "teacherid": "21185299",
                    "weekly_hrs": 2,
                    "type": "practical",
                    "room_type": "computerlab"
                },
                ... as many subject as we want to plot
            ]
        },
        {
            "local_fitness": 0,
            "course": "",
            "semester": "",
            "section": "A1",
            "joint": false,
            "merged_section": [],
            "timetable": [....],
            "subjects": [.....]
        },
        .... as many sections as we need with predecided teacher and subjects
    ]
}

File Structure *(under updation)

File Name Description
JSON
classsync.faculties.json Faculty imported from class-sync database
classsync.rooms.json Room data imported from class-sync database
classsync.tables.json TimeTable data imported from class-sync database
classsync.converted.faculties.json Faculty data for algorithm
classsync.converted.rooms.json Room data format for algorithm
classsync.converted.tables.json Timetable data format for algorithm
classsync.backtonormal.faculties.json Faculty data converted back to Class-Sync format
classsync.backtonormal.rooms.json Room data converted back to Class-Sync format
classsync.backtonormal.tables.json Timetable data converted back to Class-Sync format
classsync.win.chechpoint.tables.json Timetable saving checkpoint
classsync.win.selected.tables.json Population data selected for further processing
accepetedsol.json Accepted solutions from algorithm (if best solution is found)
=============================
Algorithm
algorithm.js This is the main driver file which runs the genetic algorithm. It includes the main loop for the algorithm, including selection, crossover, mutation, and fitness evaluation.
plot_timetables.js This is sub-driver file for plotting the initial generation
config.js This file contains configuration settings for the algorithm, including parameters for mutation rates, population size, and other algorithm-specific settings.
crossover.js Crossover function
mutation.js Mutation function
fitness_func.js Fitness function
generate_initial_population.js Initial population of timetables based on the provided data and constraints.
teacher_room_clash_map_generator.js Internal helper function
validate_timetable.js Internal helper function to ensure the timetables meet constraints.
=============================
Utils
ABconvert.js Original Class-Sync format => Algorithm format
BAconvert.js Algorithm format => Original Class-Sync format
constant.js Constants for the algorithm
=============================
DBupload
DBupload.js This file handles the uploading of data to the database.
faculty.model.js Necessary Models for mongoose
room.model.js Necessary Models for mongoose
table.model.js Necessary Models for mongoose
=============================

Terminology

Algorithm Terminology Common Terminology Description Example
Generation Population Represent a Set of probable group of Timetable 20 set of 20 section's Timetable
(20 Genomes)
Genome / Chromosome Timetable Set / Person (or unit) of a generation It is the Set of probable Timetables 20 section's Timetable
(20 Genes)
Gene Timetable It is the single Timetable Timetable of section A

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •