A comprehensive solution for the Job Scheduling Problem using multiple algorithms including Backtracking and Genetic Algorithm approaches. Features both graphical and command-line interfaces for easy interaction and algorithm comparison.
- Multiple Algorithms: Backtracking and Genetic Algorithm implementations
- Dual Interface: Both GUI and CLI support
- Algorithm Comparison: Built-in performance comparison tools
- Input Validation: Robust error handling and input validation
- Dependency Support: Handle job dependencies in scheduling
- Resource Constraints: Manage resource capacity limitations
- Performance Metrics: Detailed scheduling metrics and visualizations
- Installation
- Quick Start
- Project Structure
- Usage
- Algorithms
- API Reference
- Testing
- Contributing
- License
- Python 3.7 or higher
- tkinter (usually included with Python)
-
Clone the repository:
git clone https://github.com/AhmedFatthy1040/Job-Scheduling-Problem-Solver.git cd Job-Scheduling-Problem-Solver -
Install dependencies:
pip install -r requirements.txt
-
Verify installation:
python main.py --help
python main.pypython main.py --clipython test_scheduling.pyJob-Scheduling-Problem-Solver/
β
βββ main.py # Main application entry point
βββ test_scheduling.py # Comprehensive test suite
βββ requirements.txt # Project dependencies
βββ README.md # Project documentation
β
βββ algorithms/ # Algorithm implementations
β βββ __init__.py
β βββ backtracking_algorithm.py # Backtracking solver
β βββ genetic_algorithm.py # Genetic algorithm solver
β
βββ models/ # Data models
β βββ __init__.py
β βββ job.py # Job class definition
β βββ resource.py # Resource class definition
β βββ job_scheduling_problem.py # Problem instance class
β
βββ gui/ # Graphical user interface
β βββ __init__.py
β βββ main_window.py # Main GUI window
β βββ result_window.py # Results display window
β βββ algorithms_comparison_window.py # Algorithm comparison GUI
β
βββ utils/ # Utility modules
β βββ __init__.py
β βββ random_generator.py # Random instance generator
β βββ scheduler_evaluator.py # Performance evaluator
β
βββ resources/ # Documentation and diagrams
βββ documentation.pdf
βββ package_diagram.PDF
βββ use_case_diagram.jpg
-
Launch the application:
python main.py
-
Add Jobs:
- Enter processing time
- Optionally specify dependency (job ID that must complete first)
- Click "Add Job"
-
Add Resources:
- Enter capacity (total processing time available)
- Click "Add Resource"
-
Solve:
- Choose "Solve with Backtracking" or "Solve with Genetic"
- View results in the popup window
-
Compare Algorithms:
- Click "Algorithm Comparison" for automated testing
Algorithm Comparison:
python main.py --cliThis will:
- Generate 5 random problem instances
- Solve each with both algorithms
- Compare performance and solution quality
- Display detailed results
from models.job import Job
from models.resource import Resource
from models.job_scheduling_problem import JobSchedulingProblem
from algorithms.backtracking_algorithm import BacktrackingAlgorithm
# Create problem instance
jobs = [
Job(1, 3, None), # Job 1: 3 time units, no dependency
Job(2, 2, 1), # Job 2: 2 time units, depends on Job 1
Job(3, 4, None) # Job 3: 4 time units, no dependency
]
resources = [
Resource(1, 10), # Resource 1: capacity 10
Resource(2, 8) # Resource 2: capacity 8
]
problem = JobSchedulingProblem(jobs, resources)
# Solve with backtracking
algorithm = BacktrackingAlgorithm(problem)
solution = algorithm.solve()
if solution:
print("Solution found!")
for job, resource in solution:
print(f"Job {job.job_id} β Resource {resource.resource_id}")- Approach: Exhaustive search with pruning
- Guarantees: Optimal solution (if exists)
- Time Complexity: O(R^J) where R = resources, J = jobs
- Best For: Small to medium problems, exact solutions required
- Approach: Evolutionary optimization
- Guarantees: Near-optimal solution
- Time Complexity: O(G Γ P Γ J) where G = generations, P = population, J = jobs
- Best For: Large problems, approximate solutions acceptable
- Dependency Handling: Both algorithms properly handle job dependencies
- Resource Constraints: Respect resource capacity limitations
- Validation: Comprehensive solution validation
- Performance Tracking: Built-in timing and quality metrics
Job(job_id: int, processing_time: int, dependency: Optional[int] = None)job_id: Unique identifierprocessing_time: Time required (must be positive)dependency: ID of prerequisite job (optional)
Resource(resource_id: int, capacity: int)resource_id: Unique identifiercapacity: Maximum processing time available (must be positive)
JobSchedulingProblem(jobs: List[Job], resources: List[Resource])jobs: List of jobs to scheduleresources: List of available resources
BacktrackingAlgorithm(problem_instance: JobSchedulingProblem)solve(): Returns optimal schedule or Noneis_valid_schedule(schedule): Validates a given schedule
GeneticAlgorithm(problem_instance, population_size=50, generations=100,
crossover_prob=0.8, mutation_prob=0.2)evolve(): Returns best schedule foundfitness(schedule): Calculates schedule fitness (lower is better)
Run the comprehensive test suite:
python test_scheduling.pyTest Coverage:
- β Model validation (Job, Resource)
- β Algorithm correctness (Backtracking, Genetic)
- β Input validation and error handling
- β Schedule validation
- β Integration testing
- β Random generation utilities
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run tests:
python test_scheduling.py - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow PEP 8 style guidelines
- Add type hints for new functions
- Include docstrings for all public methods
- Add tests for new functionality
- Update README for new features
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by classic job scheduling optimization problems
- Built with Python's tkinter for cross-platform GUI support
- Uses evolutionary algorithms for heuristic optimization
- Issues: GitHub Issues
- Documentation: Check the
resources/folder for additional diagrams - Email: Contact the maintainer
Made with β€οΈ by Ahmed Fathy