This project is a Django-based backend for a class scheduling system. It employs Constraint Satisfaction Problem (CSP) techniques, specifically AC-3 (Arc Consistency Algorithm #3) and backtracking, to generate feasible timetables for classes.
- Backend Setup
- Configuration
- Usage
- Timetable Scheduling
- Frontend Setup
- Video Demonstration
- Screenshots
- Contributing
-
Clone the repository:
git clone https://github.com/ATOUIYakoub/Class-Scheduling-CSP.git
-
Create and activate a virtual environment:
python -m venv env .\env\Scripts\activate # On Linux use `source env/bin/activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Apply migrations:
python manage.py makemigrations python manage.py migrate
Note: If the migrations do not work, you can comment out the contents of
csp_utils.py
and related references inviews.py
. After running the migration commands, uncomment the previously commented lines. -
Run the development server:
python manage.py runserver
Ensure that you configure your database and other settings in the settings.py
file as required. The default configuration uses SQLite for simplicity.
- Access the Django admin interface at
http://127.0.0.1:8000/admin
and log in using the superuser credentials created earlier. - Use the admin interface to input data about classrooms, courses, instructors, and timeslots.
- The timetable scheduling algorithm can be triggered via the provided endpoints or by implementing custom views.
- To test with Swagger, access the API documentation at
http://127.0.0.1:8000/api/schema/docs
.
The timetable scheduling feature is implemented using CSP techniques. Here's a brief overview of how AC-3 and backtracking are used:
AC-3 is used to reduce the search space before applying the backtracking algorithm. It works by enforcing consistency between variable pairs (arcs). If any variable's domain is emptied, the problem is unsolvable under the current constraints.
After the initial reduction by AC-3, backtracking is employed to search for solutions. The backtracking algorithm recursively assigns values to variables while ensuring that constraints are satisfied. If a conflict arises, it backtracks to the previous step and tries a different assignment.
- csp_utils.py: Contains utility functions to support the CSP solver.
To execute the timetable scheduling:
- Ensure that you have populated the database with the necessary data (classrooms, courses, instructors, and timeslots).
- Use the provided management commands or views to trigger the scheduling process.
The frontend for this project is built using React and is located in the Front-end
folder. Follow these steps to set up and run the frontend:
-
Navigate to the
Front-end
directory:cd front-end
-
Install the required dependencies:
npm install
-
Install Axios:
npm install axios
-
Start the Vite development server:
npm run dev
-
Access the React application at
http://localhost:5173
.
Ensure that your backend server is running concurrently to enable full functionality.
Here is a video demonstration of the application in action:
Video_Demonstration.mp4
Here are some screenshots of the application:
Contributions are welcome! Please fork the repository and create a pull request with your changes. Ensure that your code adheres to the project's coding standards and includes appropriate tests.