- Data Structure & Algorithm Classes (Live)
- System Design (Live)
- DevOps(Live)
- Explore More Live Courses
- Interview Preparation Course
- Data Science (Live)
- GATE CS & IT 2024
- Data Structure & Algorithm-Self Paced(C++/JAVA)
- Data Structures & Algorithms in Python
- Explore More Self-Paced Courses
- C++ Programming - Beginner to Advanced
- Java Programming - Beginner to Advanced
- C Programming - Beginner to Advanced
- Full Stack Development with React & Node JS(Live)
- Java Backend Development(Live)
- Android App Development with Kotlin(Live)
- Python Backend Development with Django(Live)
- Complete Data Science Program(Live)

Mastering Data Analytics
Devops engineering - planning to production, cbse class 12 computer science.
- School Guide
- All Courses
- Linked List
- Binary Tree
- Binary Search Tree
- Advanced Data Structure
- All Data Structures
- Asymptotic Analysis
- Worst, Average and Best Cases
- Asymptotic Notations
- Little o and little omega notations
- Lower and Upper Bound Theory
- Analysis of Loops
- Solving Recurrences
- Amortized Analysis
- What does 'Space Complexity' mean ?
- Pseudo-polynomial Algorithms
- Polynomial Time Approximation Scheme
- A Time Complexity Question
- Searching Algorithms
- Sorting Algorithms
- Graph Algorithms
- Pattern Searching
- Geometric Algorithms
- Mathematical
- Bitwise Algorithms
- Randomized Algorithms
- Greedy Algorithms
- Dynamic Programming
- Divide and Conquer
- Backtracking
- Branch and Bound
- All Algorithms
- Company Preparation
- Practice Company Questions
- Interview Experiences
- Experienced Interviews
- Internship Interviews
- Competitive Programming
- Design Patterns
- System Design Tutorial
- Multiple Choice Quizzes
- Go Language
- Tailwind CSS
- Foundation CSS
- Materialize CSS
- Semantic UI
- Angular PrimeNG
- Angular ngx Bootstrap
- jQuery Mobile
- jQuery EasyUI
- React Bootstrap
- React Rebass
- React Desktop
- React Suite
- ReactJS Evergreen
- ReactJS Reactstrap
- BlueprintJS
- TensorFlow.js
- English Grammar
- School Programming
- Number System
- Trigonometry
- Probability
- Mensuration
- Class 8 Syllabus
- Class 9 Syllabus
- Class 10 Syllabus
- Class 11 Syllabus
- Class 8 Notes
- Class 9 Notes
- Class 10 Notes
- Class 11 Notes
- Class 12 Notes
- Class 8 Formulas
- Class 9 Formulas
- Class 10 Formulas
- Class 11 Formulas
- Class 8 Maths Solution
- Class 9 Maths Solution
- Class 10 Maths Solution
- Class 11 Maths Solution
- Class 12 Maths Solution
- Class 7 Notes
- History Class 7
- History Class 8
- History Class 9
- Geo. Class 7
- Geo. Class 8
- Geo. Class 9
- Civics Class 7
- Civics Class 8
- Business Studies (Class 11th)
- Microeconomics (Class 11th)
- Statistics for Economics (Class 11th)
- Business Studies (Class 12th)
- Accountancy (Class 12th)
- Macroeconomics (Class 12th)
- Machine Learning
- Data Science
- Mathematics
- Operating System
- Computer Networks
- Computer Organization and Architecture
- Theory of Computation
- Compiler Design
- Digital Logic
- Software Engineering
- GATE 2024 Live Course
- GATE Computer Science Notes
- Last Minute Notes
- GATE CS Solved Papers
- GATE CS Original Papers and Official Keys
- GATE CS 2023 Syllabus
- Important Topics for GATE CS
- GATE 2023 Important Dates
- Software Design Patterns
- HTML Cheat Sheet
- CSS Cheat Sheet
- Bootstrap Cheat Sheet
- JS Cheat Sheet
- jQuery Cheat Sheet
- Angular Cheat Sheet
- Facebook SDE Sheet
- Amazon SDE Sheet
- Apple SDE Sheet
- Netflix SDE Sheet
- Google SDE Sheet
- Wipro Coding Sheet
- Infosys Coding Sheet
- TCS Coding Sheet
- Cognizant Coding Sheet
- HCL Coding Sheet
- FAANG Coding Sheet
- Love Babbar Sheet
- Mass Recruiter Sheet
- Product-Based Coding Sheet
- Company-Wise Preparation Sheet
- Array Sheet
- String Sheet
- Graph Sheet
- ISRO CS Original Papers and Official Keys
- ISRO CS Solved Papers
- ISRO CS Syllabus for Scientist/Engineer Exam
- UGC NET CS Notes Paper II
- UGC NET CS Notes Paper III
- UGC NET CS Solved Papers
- Campus Ambassador Program
- School Ambassador Program
- Geek of the Month
- Campus Geek of the Month
- Placement Course
- Testimonials
- Student Chapter
- Geek on the Top
- Geography Notes
- History Notes
- Science & Tech. Notes
- Ethics Notes
- Polity Notes
- Economics Notes
- UPSC Previous Year Papers
- SSC CGL Syllabus
- General Studies
- Subjectwise Practice Papers
- Previous Year Papers
- SBI Clerk Syllabus
- General Awareness
- Quantitative Aptitude
- Reasoning Ability
- SBI Clerk Practice Papers
- SBI PO Syllabus
- SBI PO Practice Papers
- IBPS PO 2022 Syllabus
- English Notes
- Reasoning Notes
- Mock Question Papers
- IBPS Clerk Syllabus
- Apply for a Job
- Apply through Jobathon
- Hire through Jobathon
- All DSA Problems
- Problem of the Day
- GFG SDE Sheet
- Top 50 Array Problems
- Top 50 String Problems
- Top 50 Tree Problems
- Top 50 Graph Problems
- Top 50 DP Problems
- Solving For India-Hackthon
- GFG Weekly Coding Contest
- Job-A-Thon: Hiring Challenge
- BiWizard School Contest
- All Contests and Events
- Saved Videos
- What's New ?
- Divide & Conquer
Related Articles
- Write Articles
- Pick Topics to write
- Guidelines to Write
- Get Technical Writing Internship
- Write an Interview Experience
- Top 50 Array Coding Problems for Interviews
- Introduction to Recursion - Data Structure and Algorithm Tutorials
- Difference between BFS and DFS
- Counting Sort
- A* Search Algorithm
- SDE SHEET - A Complete Guide for SDE Preparation
- Asymptotic Notation and Analysis (Based on input size) in Complexity Analysis of Algorithms
- DSA Sheet by Love Babbar
- How to write a Pseudo Code?
- Types of Asymptotic Notations in Complexity Analysis of Algorithms
- Understanding Time Complexity with Simple Examples
- Worst, Average and Best Case Analysis of Algorithms
- How to analyse Complexity of Recurrence Relation
- Playfair Cipher with Examples
- Recursive Practice Problems with Solutions
- How to Analyse Loops for Complexity Analysis of Algorithms
- What is Algorithm | Introduction to Algorithms
- Quick Sort vs Merge Sort
- Complexity Analysis of Binary Search
- Converting Roman Numerals to Decimal lying between 1 to 3999
- Generate all permutation of a set in Python
- Difference Between Symmetric and Asymmetric Key Encryption
- Comparison among Bubble Sort, Selection Sort and Insertion Sort
- Data Structures and Algorithms Online Courses : Free and Paid
- Mid-Point Circle Drawing Algorithm
- Cyclomatic Complexity
- DDA Line generation Algorithm in Computer Graphics
- Difference between NP hard and NP complete problem
- Introduction to Amortized Analysis
- Design a Chess Game
Scheduling in Greedy Algorithms
- Difficulty Level : Easy
- Last Updated : 03 Nov, 2022
In this article, we will discuss various scheduling algorithms for Greedy Algorithms . Many scheduling problems can be solved using greedy algorithms.
Problem statement: Given N events with their starting and ending times, find a schedule that includes as many events as possible. It is not possible to select an event partially. Consider the below events:
- In this case, the maximum number of events is two. As selected events B and D are as follows:
- It is possible to invent several greedy algorithms for the problem.
Algorithms that work with every case:
Algorithm 1 :
- The first idea is to select as short events as possible. In the example, this algorithm selects the following events:
- However, selecting short events is not always a correct strategy. For example, the algorithm fails in the below case:
- If short event is selected, it can only select one event. However, it would be possible to select both long events.
Algorithm 2 :
- Another idea is to always select the next possible event that begins as early as possible. This algorithm selects the following events:
- However, given a counter example for this algorithm. In this case, the algorithm only selects one event:
- If the first event is selected, it is not possible to select any other events. However, it would be possible to select the other two events.
Algorithm 3 :
- The third idea is to always select the next possible event that ends as early as possible. This algorithm selects the following events:
- It turns out that this algorithm always produces an optimal solution.
- The reason for this is that it is always an optimal choice to first select an event that ends as early as possible.
- After this, it is an optimal choice to select the next event using the same strategy, etc., until any other event can’t be selected.
- One way the algorithm works is to consider what happens if first select an event that ends later than the event that ends as early as possible.
- Now, with having at most an equal number of choices how the next event can be selected.
- Hence, selecting an event that ends later can never yield a better solution, and the greedy algorithm is correct.
Solve DSA problems on GfG Practice.
Please Login to comment...
- cpu-scheduling
- Operating Systems-CPU Scheduling
- Operating Systems Questions
Data Structures & Algorithms in Python - Self Paced
Complete interview preparation - self paced, master c++ programming - complete beginner to advanced, data structures and algorithms - self paced, competitive programming - live, system design - live, complete test series for product-based companies, complete test series for service-based companies, complete machine learning & data science program, dsa live for working professionals - live, master java programming - complete beginner to advanced, python programming foundation -self paced, java backend development - live, master c programming with data structures, full stack development with react & node js - live, improve your coding skills with practice, start your coding journey now.
- Stack Overflow Public questions & answers
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Talent Build your employer brand
- Advertising Reach developers & technologists worldwide
- About the company
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Teacher time schedule algorithm
This is a problem I've had on my mind for a long time. Being the son of a teacher and a programmer, it occurred to me early on... but I still haven't found a solution for it.
So this is the problem. One needs to create a time schedule for a school, using some constraints. These are generally divided in two categories:
Sanity Checks
- A teacher cannot teach two classes at the same time
- A student cannot follow two lessons at the same time
- Some teachers must have at least one day off during the week
- All the days of the week should be covered by the time table
- Subject X must have exactly so-and-so hours each week
Preferences
- Each teacher's schedule should be as compact as possible (i.e. the teacher should work all hours for the day in a row with no pauses if possible)
- Teachers that have days off should be able to express a preference on which day
- Teachers that work part-time should be able to express a preference whether to work in the beginning or the end of the school day.
Now, after a few years of not finding a solution (and learning a thing or two in the meanwhile...), I realized that this smells like a NP-hard problem.
Is it proven as NP-hard?
Does anyone have an idea on how to crack this thing?
Looking at this question made me think about this problem, and whether genetic algorithms would be usable in this case. However it would be pretty hard to mutate possibilities while maintaining the sanity check rules. Also it's not clear to me how to distinguish incompatible requirements.
A small addendum to better specify the problem. This is applied to Italian school style classrooms where all students are associated in different classes (for example: year 1 section A) and the teachers move between classes. All students of the same class have the same schedule, and have no choice over which lessons to attend.
- 1 This is an awfully specific problem to find independently proved NP-hard. You might have better luck looking for a less constrained problem that might be proved NP-hard. Preferences play no part in its complexity unless you can assign some metric (like teachers always get their preferred day off). – David Thornley Oct 11, 2010 at 21:40
10 Answers 10
I am one of the developer that works on the scheduler part of a student information system. During our original approach of the scheduling problem, we researched genetic algorithms to solve constraint satisfaction problems, and even though we were successful initially, we realized that there was a less complicated solution to the problem (after attending a school scheduling workshop)
Our current implementation works great, and uses brute force with smart heuristics to get a valid schedule in a short amount of time. The master schedule (assignment of the classes to the teachers) is first built, taking in consideration all the constraints that each teacher has while minimizing the possibility of conflicts for the students (based of their course requests). The students are then scheduled in the classes using the same method.
Doing this allows you to have the machine build a master schedule first, and then have a human tweak it if needed.
The scheduler current implementation is written in perl, but other options we visited early on were Prolog and CLIPS (expert system)
- Brute force usually hits the wall at about n=10 (depends on the use case). The thing is, even if you double your processing power, the wall hardly moves. Smart forms of brute force (backtracking, pruning) etc may move the wall to n=20 but no further. In my experience, Tabu Search and Late Acceptance works best (much better than Genetic Algorithms). – Geoffrey De Smet Jun 20, 2013 at 10:12
I think you might be missing some constraints.
One would prefer where possible to have teachers scheduled to classes for which they are certified.
One would suspect that the classes that are requested, and the expected headcount in each would be significant.
I think the place to start would be to list all of your constraints, figure out a data structure to represent them.
Then create some sort of engine to that builds a trial solution, then evaluates it for fitness according to the constraints.
You could then throw the fun genetic algorithms part at it, and see if you can get the fitness to increase over time as the genes mix.
Start with a small set of constraints, and increase them as you see success (if you see success)
There might be a way to take the constraints and shoehorn them together with something like a linear programming algorithm.
I agree. It sounds like a fun challenge
- The headcount would be fixed (say x classes of y students). All teachers are equally certified. At least in Italian schools that is... ;) – Sklivvz Oct 16, 2008 at 23:49
- The problem is, I suspect that even generating a bad, but sane solution is almost np-hard... Should I generate a random one to start with? That really doesn't sound feasible – Sklivvz Oct 16, 2008 at 23:52
- Ya, omitting those constraints simplifies things. I think sitting down and drawing a picture of possible data structures for the constraints would be a good step. Do the part you know, and the rest may become visible. – EvilTeach Oct 16, 2008 at 23:54
- Ya, I probably would generate a large initial set, run them through fitness, then start breeding them, injecting new random ones intermittently, if they start to die off too fast. You are really gonna have to do it, to see what happens. – EvilTeach Oct 16, 2008 at 23:56
This is a mapping problem: you need to map to every hour in a week and every teacher an activity (teach to a certain class or free hour ).
Split the problem:
- Create the list of teachers, classes and preferences then let the user populate some of the preferences on a map to have as a starting point.
- Randomly take one element from the list and put it at a random free position on the map if it doesn't cross any sanity checks until the list is empty. If at any certain iteration you can't place an element on the map without crossing a sanity check shift two positions on the map and try again.
- When the map is filled, try shifting positions on the map to optimize the result.
In steps 2 and 3 show each iteration to the user: items left in the list, positions on the map and the next computed move and let the user intervene.
I did not try this, but this would be my initial approach.
I've tackled similar planning/scheduling problems in the past and the AI technique that is often best suited for this class of problem is "Constraint Based Reasoning".
It's basically a brute force method like Laurenty suggested, but the approach involves applying constraints in an efficient order to cause the infeasible solutions to fail fast - to minimise the computation required.
Googling "Constraint Based Reasoning" brings up a lot of resources on the technique and its application to scheduling problems.
- I don't agree. I think that a hybrid between CP-OR and then maybe AI. I have seen good academic generic solutions with CP-OR mix but this research field never gets any money so it seems that we are doomed. – Jonke Oct 26, 2008 at 0:34
Answering my own question:
The FET project mentioned by gnud uses this algorithm:
Some words about the algorithm: FET uses a heuristical algorithm, placing the activities in turn, starting with the most difficult ones. If it cannot find a solution it points you to the potential impossible activities, so you can correct errors. The algorithm swaps activities recursively if that is possible in order to make space for a new activity, or, in extreme cases, backtracks and switches order of evaluation. The important code is in src/engine/generate.cpp. Please e-mail me for details or join the mailing list. The algorithm mimics the operation of a human timetabler, I think.
Following up the "Constraint Based Reasoning" lead by Stringent Software on Wikipedia lead me to these pages which have an interesting paragraph:
Solving a constraint satisfaction problem on a finite domain is an NP-complete problem in general. Research has shown a number of polynomial-time subcases, mostly obtained by restricting either the allowed domains or constraints or the way constraints can be placed over the variables. Research has also established relationship of the constraint satisfaction problem with problems in other areas such as finite model theory and databases.
This reminds me of this blog post about scheduling a conference , with a video explanation here .
How I would do it:
Have the population include two things:
- Who teaches what class (I expect the teachers to teach one subject).
- What a class takes on a specific time slot.
This way we can't have conflicts (a teacher in 2 places, or a class having two subjects at the same time).
The fitness function would include:
- How many time slots each teacher gives per week.
- How many time slots a teacher has on the same day (They can't have a full day of teaching, this too must be balanced).
- How many time slots of the same subject a class has on the same day (They can't have a full day of math!).
Maybe take the standard deviation for all of them since they should be balanced.
Genetic Algorithms are very well suited to problems such as this. Once you come up with a decent representation of the chromosome (in this case, probably a vector representing all of the available class slots) you're most of the way there.
Don't worry about maintaining sanity checks during the mutation phase. Mutation is random. Sanity and preference checks both belong in the selection phase. A failed sanity check would drastically lower the fitness of an individual, while a failed preference would only mildly lower the fitness.
Incompatible requirements are a different problem altogether. If they're completely incompatible, you'll get a population that doesn't converge on anything useful.
Good luck. Being the son of a father with this sort of problem is what took me to the research group that I ended up in ...
When I was a kid my father scheduled match officials in a local sports league, this had a similarly long list of constraints and I tried to write something to help. When I got to University I even used it as my final year project eventually settling on a Monte Carlo implementation (using a Simulated Annealing model).
The basic idea is that if it's not NP, it's pretty close, so rather than assuming there is a solution, I would set out to find the best within a given timeframe. I would weight all the constraints with costs for breaking them: sanity checks would have huge costs, the preferences would have lower costs (but increasing for more breaks, so breaking it once would be less than half the cost of breaking it twice).
The basic idea is that I started with a 'random' solution and costed it; then made changes by swapping a small number of assignments, re-valued it and then, probalistically accepted or declined the change.
After thousands of iterations you inch closer to an acceptable solution.
Believe me, though, that this class of problems has research groups churning out PhDs so you're in very good company.
You might also find some interest in the Linear Programming arena, e.g. simplex and so on.
Yes, I think this is NP complete - or at least to find the optimal solution is NP complete.
I worked on a similar problem in college when i told a friend's father (who was a teacher) that I could solve his scheduling problems for him if he did not find a suitable program for it (this was back in 1990 or so)
I had no idea what I got myself into. Luckily for us all I had to do was find one solution that fit the constraints. But in my testing I was always worried about determining IF there was a solution at all. He never had too many constraints and the program used different heuristics and back tracking. It was a lot of fun.
I think Bill Gates also worked on a system like this in high school or college for his high school. Not sure though.
Good luck. All my notes are gone and I never got around to implementing a solution that I could market. It was a specialty project that I re-coded as I learned new languages (Basic, Scheme, C, VB, C++)
Have fun with it
i see that this problem can be solved by Prolog program by connecting it to a database and the program can make the schedule given a set of constraints read abt "Constraint satisfaction Problem prolog"
Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged algorithm scheduling np-hard or ask your own question .
- The Overflow Blog
- Building an API is half the battle: Q&A with Marco Palladino from Kong
- Developers think AI assistants will be everywhere, but aren’t sure how to...
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
- The Stack Exchange reputation system: What's working? What's not?
- Launching the CI/CD and R Collectives and community editing features for...
- The [amazon] tag is being burninated
- Staging Ground Beta 1 Recap, and Reviewers needed for Beta 2
- Temporary policy: ChatGPT is banned
Hot Network Questions
- Why did my flight leave the gear down for the first 10 minutes of flight?
- Are the Āraṇyaká-s and the Upaniṣád-s part of the Véda?
- Does the Federal Reserve insure the money of all depositors?
- How to notate 3 quarters framed by eighths?
- Why is the ongoing auction for Silicon Valley Bank started privately held (vs. publicly)?
- How useful is a caliper for a home-based bike workshop?
- Is the cabin pressure "worse" at the back of the cabin than in front?
- What's a good word to describe someone who is prone to sudden changes of mood?
- Mechanic sent me this image and said my brake rotors should be replaced. Does this seem right?
- Why Hegel thinks that A and not-A will entail each other?
- Would a spider familiar be able to press the button on the immovable rod whilst swinging from a rope tied to said rod?
- Applying geometry nodes doesn't work on a curve object
- What filter is used on this image?
- Why isn't the derivative of the volume of the cone its surface area?
- What is the concept of hole in semiconductor physics?
- Why is crystal frequency often multiplied inside a microcontroller?
- Fired (seemingly) for finding paycheck inconsistencies. What kind of legal recourse might exist?
- How can I make the rules of my Faerie Portal free from contradiction?
- Can we explain why using `Nothing` twice on a list does not operate twice?
- What's the best word to indicate "not mindless"?
- Is cross examination strictly confined to the subjects that the original examination pertained to, or can the opposing party make their own points?
- Where is the extra hour? Eurostar London to Paris is 2hr 30m but departure is 3hrs 30m before arrival
- Test whether an expression contains a particular pattern
- How to extract the internal key of a simple P2TR address?
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

Jan 10, 2021
Classroom scheduling using heuristics and genetic algorithm
This article is written based on the assumption that the reader has an understanding of genetic algorithms. The code is available on https://github.com/taytzehao/School_scheduling/tree/main
Problem Statement
This problem is centered around making a school schedule for my secondary school using heuristic and genetic algorithm methods.
Unlike scheduling for universities, this school schedule is packed throughout the day with a fixed break in the middle of the morning. The format would be as of the following diagram
Where lower form refers to grades 7–9 and upper form refers to grades 10-12. Recess for the upper form students is at the 6th period while the lower form is at the 5th period. Upper form students have extra classes on Wednesday and Thursday.
The schedule has to conform to the following rules:
- One teacher can only teach 1 class at a time.
- The maximum number of periods for a subject per day is 2.
- Subjects that require teachers who are niche in the subject only allows the teacher who specializes in the subject to teach it.
- Teachers are only allowed to have a maximum of 12 periods per week and 5 periods per day
- Each subject for any class can only be taught by 1 teacher. That means each subject for each class will be assigned to 1 teacher
- Subjects that must be held in the morning must be held before recess.
- Subjects that have the attribute “side_by_side=True” must have the maximum amount of consecutive classes. This means if a subject has 5 periods per week, it must have periods of 2,2,1 for each day.
- Subjects that have the attribute “side_by_side=False” can only have 1 period per day.
Initializing the classes
A form (aka grade) can have multiple classrooms that have a different class name. Therefore, the classroom inherits from From. Each classroom contain would have multiple subjects that have to be taught while each subject can be taught in multiple classes. The same interaction goes for the teacher and the classroom.
The teach object would be a class that associates teacher, classroom, and subject altogether. Every time a class is assigned, the teach object would be appended to the teacher and classroom object to easily identify the information of the activity while pointing to the same object without creating duplicate data in separate classes.
A brief introduction to Genetic algorithm
Genetic algorithm is a metaheuristic method to solve optimization problems. It resembles the genetics to allow the solution to evolve, mutate, and improve over generations, much like a living organism.
It starts off with the step of initializing random sets of solutions called “population” with each solution called “individual”. The better individuals are firstly being selected to eliminate solutions that are bad. The individuals in the population then cross-breed with each other by mixing their solutions together. Then, the individuals mutate by randomly changing some of the genes. If the population solution fulfills the fitness criteria, the process ends there. However, if the fitness criteria is not fulfilled, the process would be reiterated back to the selection step.
Genetic algorithm solution
In the genetic algorithm solution, the problem is being broken down into 2 sections i.e.
a) The assignment of teachers to each subject of each class since each subject of each class can only be taught by 1 teacher as in Rule 5.
b)The assignment of classes to each class.
This is meant to reduce the problem space that the genetic algorithm needs to solve. This is because of the previous iteration of solutions that merged both the problems lead to premature convergence.
Teacher assignment
Initialization
Each teacher is provided a unique ID number to be encoded into the gene. Each gene is initialized with a random teacher. The length of the individual is equivalent to the sum of subjects of all classes. Eg, class A has 10 subjects and class B has 11 subjects, the individual would have 21 genes. Each position of the gene represents the teacher assigned to the subject. The population is being initialized to 300 individuals per population.
Fitness function
The fitness is decreased as to the following 2 criteria:
a) Subjects that require specialized skills that are assigned teachers who are specialized in it would decrease fitness score by 1.
b) Teachers that are assigned more than the maximum number of teaching hours would decrease the fitness by the number of exceeding hours.
As this is a regular encoding problem, the following operators are used for solving this problem
a) Uniform crossover
It selects 2 parents and randomly exchanges the element of both parents from the same position as of below. As compared to 1 or 2 points crossover, this method better promotes exploration.
b) Random mutation
A random teacher ID is selected and switched to another random teacher ID.
The Roulette method is used for selecting individuals from each population.
Class assignment
Encoding method
The classes are being encoded as a permutation type problem here with each ID representing a set of classes. This means for a subject that has “side_by_side=True” and 5 periods allocated to it, the subject would be assigned class sets of 2,2,1 with 3 unique IDs. So, each ID would contain 2 information, the teaching activity and the number of periods for the class set.
The position of each gene in the chromosome represents its location on the schedule. The gene of the next class is at the position after the last position of the former class. The diagram below shows an example of 2 classes that have 10 and 11 class sets
This encoding method is developed after rounds of iteration in order to prevent premature convergence of the population and reduces the problem space significantly by limiting the permutation to involve classes within the classroom.
The fitness function is also designed to maximize the fitness score. The fitness score is decreased as of the following conditions:
a) Each morning period that is assigned after recess decreases the fitness score by 1
b) Each period that intersects with the teaching schedule of the teacher decreases the fitness score by 1.
c) Decrease fitness for every subject that exceeds the limit of its classes per day by the number of excess periods.
d) Decrease the fitness by 1 for every class set that has 2 periods that do not have consecutive periods. For example, the Biology class in the diagram below is interrupted by the Recess would have the fitness decreased by 1.
All operations used in this problem are designed to only include the gene which is of the same classroom. The operators used for this are
a) Ordered Crossover. It selects a substring from parent 1 and maintains its position in the offspring. The remaining elements that are not in the substring would utilize the position of the rest of the elements from parent 2 as in the diagram below. The modified version of it is done for each class.
Heuristic mutation-Each individual would randomly select gamma amount of genes and permutate their position. The permutation with the best arrangement would be selected. The modified version of this mutation separately selects the genes from each class and permutates the arrangement for each class.
Tournament selection. Individuals are randomly selected from the population based on the tournament size. Out of this batch, the best individual is selected for the offspring. This process is repeated until the offspring size reaches the population size. The smaller the tournament size, the better the exploration of the offspring. This is because this gives a higher probability of 2 low fitness individuals to be selected, and thus improving the diversity of the population.
Migration ring. The migration ring emigrates k amount of individuals that are selected using the tournament method stated above to replace random individuals in its destination population. This can help to increase population diversity and reduce the likelihood of premature convergence. This is performed at the end of each iteration.
Heuristics solution
As the class assignment sequence diagram describes, the main goal of creating the process is to minimize the possibility of assigning classes to times that are not viable for the subject. The more clashes there are, the more computing power is required in order to swap blank periods with periods that are already assigned classes.
Every sequence would go through the following processes:
a) Loop through every class
b) Loop through every subject
c) Select the subject that fulfills the criteria as in the diagram
d) Select period coordinates that suit all requirements. If no period is viable, the time of the other classes would be swapped with the period with blank classes. This would significantly increase the computing time.
e) Randomly select the coordinate and assign the period the classes
Morning classes are being assigned first as there is only 1 type of subject for each class that requires the classes to be in the morning. Plus, the requirement of having them in the morning reduces the number of viable periods to assign them to by half.
Next, double period classes are being assigned first before single period classes. This is because single period classes have a higher probability of taking away consecutive blank periods that would be used by the double period classes. Plus, single period classes have higher flexibility in terms of the timing as it does not need 2 consecutive blank classes.
Assessing the results
From the 2 performance graphs above, it is clear the using genetic algorithm utilizes significantly more computing power to solve the problem. Plus, it does not scale well as the number of classes increases as its time required grows exponentially with the number of classrooms.
This is mainly because of the random nature of genetic algorithm that would usually cause some collision with some other constraint while correcting the problem at hand.
It is concluded that the heuristic method would be suited and more scalable to arrange the school schedule. Some other points that could be used to improve this project for the future include:
a) Scale it up to more classes
b) Use simulated annealing algorithm method
c) Include teacher performance into assigning the teachers into each class. This is to ensure all classes are assigned a balanced amount of high and low-performing teachers.
d) Assign classes based on facilities availability according to subjects.
e) Minimization of walking distance by teachers
More from Tay Tze Hao
About Help Terms Privacy
Get the Medium app

Tay Tze Hao
Text to speech

International Conference on Advanced Information Networking and Applications
AINA 2021: Advanced Information Networking and Applications pp 533–540 Cite as
Solving Job Scheduling Problem Using Genetic Algorithm
- Soheila Gheisari 12 ,
- Alireza Rezaee 13 &
- Farshid Hajati 12
- Conference paper
- First Online: 01 May 2021
765 Accesses
Part of the Lecture Notes in Networks and Systems book series (LNNS,volume 227)
The efficient scheduling of independent computational jobs in a computing environment is an important problem where there are some deadlines for each job to become complete. Finding optimal schedules for such an environment is (in general) an NP-complete problem, and so heuristic approaches must be used. Genetic algorithms are known to give the best solutions to such problems. The purpose of this paper is to propound a solution to a job scheduling problem using genetic algorithms. The experimental results show that the most important factor on the time complexity of the algorithm is the size of the population and the number of generations.
- Job Scheduling
- Genetic Algorithm
- Optimal Scheduling
This is a preview of subscription content, access via your institution .
Buying options
- DOI: 10.1007/978-3-030-75078-7_53
- Chapter length: 8 pages
- Instant PDF download
- Readable on all devices
- Own it forever
- Exclusive offer for individuals only
- Tax calculation will be finalised during checkout
- ISBN: 978-3-030-75078-7
- ISBN: 978-3-030-75077-0
- Dispatched in 3 to 5 business days
- Free shipping worldwide Shipping restrictions may apply, check to see if you are impacted .

Abraham, A., Buyya, R., Nath, B.: Nature’s heuristics for scheduling jobs on computational grids. In: Proceedings of the 8th International Conference on Advanced Computing and Communications, pp. 45–52. Tata McGraw-Hill, India (2000)
Google Scholar
Wang, L., Cai, J., Li, M., Liu, Z.: Flexible Job Shop Scheduling Problem Using an Improved Ant Colony Optimization, Scientific Programming, pp. 9016303 (2017)
Ritchie, G., Levine, J.: A fast, effective local search for scheduling independent jobs in heterogeneous computing environments. Proceedings of the 22nd Workshop of the UK Planning and Scheduling Special Interest Group (2003)
Aarts, E.H.L., Van Laarhoven, P.J.M., Lenstra, J.K., Ulder, N.L.J.: A computational study of local search algorithms for job shop scheduling. ORSA J. Comput. 6 , 118–125 (1994)
CrossRef Google Scholar
Rezaee, A., Ajelli, A.: Problem solving of graph correspondence using genetics algorithm and ACO algorithm. Int. J. Innov. Res. Sci. Eng. Technol. 2 (12), 7785–7791 (2013)
Jang, W., Jong, D., Lee, D.: Methodology to improve driving habits by optimizing the in-vehicle data extracted from OBDII using genetic algorithm. In: 2016 International Conference on Big Data and Smart Computing (BigComp). pp. 313–316 (2016)
Shamsieva, A.M., Arkov, V.U.: On genetic algorithm methodology for robust system design. In: 2011 IEEE 12th International Symposium on Computational Intelligence and Informatics (CINTI), pp. 421–426 (2011)
Abdoli, S., Hajati, F.: Offline signature verification using geodesic derivative pattern. In: 22nd Iranian Conference on Electrical Engineering (ICEE), Tehran, pp. 1018–1023 (2014)
Barzamini, R., Hajati, F., Gheisari, S., Motamadinejad, M.B.: Short term load forecasting using multi-layer perception and fuzzy inference systems for Islamic countries. J. Appl. Sci. 12 (1), 40–47 (2012)
Shojaiee, F., Hajati, F.: Local composition derivative pattern for palmprint recognition. In: 22nd Iranian Conference on Electrical Engineering (ICEE), Tehran, pp. 965–970 (2014)
Hajati, F., Raie, A.A., Gao, Y.: Pose-invariant 2.5 D face recognition using geodesic texture warping. In: 11th International Conference on Control Automation Robotics and Vision, Singapore, pp. 1837–1841 (2010)
Ayatollahi, F., Raie, A.A., Hajati, F.: Expression-invariant face recognition using depth and intensity dual-tree complex wavelet transform features. J. Electr. Imaging 24 (2), 3–31 (2015)
Pakazad, S.K., Faez, K., Hajati, F.: Face detection based on central geometrical moments of face components. In: IEEE International Conference on Systems, Man and Cybernetics (SMC 2006), Taiwan (2006)
Hajati, F., Cheraghian, A., Gheisari, S., Gao, Y., Mian, A.S.: Surface geodesic pattern for 3D deformable texture matching. Pattern Recogn. 62 , 21–32 (2017)
Hajati, F., Faez, K., Pakazad, S.K.: An efficient method for face localization and recognition in color images. In: IEEE International Conference on Systems, Man and Cybernetics (SMC 2006), Taiwan (2006)
Hajati, F., Raie, A.A., Gao, Y.: Pose-invariant multimodal (2D + 3D) face recognition using geodesic distance map. J. Am. Sci. 7 (10), 583–590 (2011)
Download references
Author information
Authors and affiliations.
College of Engineering and Science, Victoria University Sydney, Sydney, Australia
Soheila Gheisari & Farshid Hajati
Department of Mechatronics Engineering, Faculty of New Sciences and Technologies, University of Tehran, Tehran, Iran
Alireza Rezaee
You can also search for this author in PubMed Google Scholar
Corresponding author
Correspondence to Farshid Hajati .
Editor information
Editors and affiliations.
Department of Information and Communication Engineering, Fukuoka Institute of Technology, Fukuoka, Japan
Prof. Leonard Barolli
Department of Computer Science, Ryerson University, Toronto, ON, Canada
Dr. Isaac Woungang
Faculty of Business Administration, Rissho University, Tokyo, Japan
Dr. Tomoya Enokido
Rights and permissions
Reprints and Permissions
Copyright information
© 2021 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper.
Gheisari, S., Rezaee, A., Hajati, F. (2021). Solving Job Scheduling Problem Using Genetic Algorithm. In: Barolli, L., Woungang, I., Enokido, T. (eds) Advanced Information Networking and Applications. AINA 2021. Lecture Notes in Networks and Systems, vol 227. Springer, Cham. https://doi.org/10.1007/978-3-030-75078-7_53

Download citation
DOI : https://doi.org/10.1007/978-3-030-75078-7_53
Published : 01 May 2021
Publisher Name : Springer, Cham
Print ISBN : 978-3-030-75077-0
Online ISBN : 978-3-030-75078-7
eBook Packages : Intelligent Technologies and Robotics Intelligent Technologies and Robotics (R0)
Share this paper
Anyone you share the following link with will be able to read this content:
Sorry, a shareable link is not currently available for this article.
Provided by the Springer Nature SharedIt content-sharing initiative

- Google OR-Tools
- Bahasa Indonesia
- Español – América Latina
- Português – Brasil
- Tiếng Việt
Get Started with OR-Tools for Python
The following sections will get you started with OR-Tools for Python:
What is an optimization problem?
Solving an optimization problem in python, more python examples, identifying the type of problem you wish to solve.
The goal of optimization is to find the best solution to a problem out of a large set of possible solutions. (Sometimes you'll be satisfied with finding any feasible solution; OR-Tools can do that as well.)
Here's a typical optimization problem. Suppose that a shipping company delivers packages to its customers using a fleet of trucks. Every day, the company must assign packages to trucks, and then choose a route for each truck to deliver its packages. Each possible assignment of packages and routes has a cost, based on the total travel distance for the trucks, and possibly other factors as well. The problem is to choose the assignments of packages and routes that has the least cost.
Like all optimization problems, this problem has the following elements:
The objective —the quantity you want to optimize. In the example above, the objective is to minimize cost. To set up an optimization problem, you need to define a function that calculates the value of the objective for any possible solution. This is called the objective function . In the preceding example, the objective function would calculate the total cost of any assignment of packages and routes.
An optimal solution is one for which the value of the objective function is the best. ("Best" can be either a maximum or a minimum.)
The constraints —restrictions on the set of possible solutions, based on the specific requirements of the problem. For example, if the shipping company can't assign packages above a given weight to trucks, this would impose a constraint on the solutions.
A feasible solution is one that satisfies all the given constraints for the problem, without necessarily being optimal.
The first step in solving an optimization problem is identifying the objective and constraints.
Next, we give an example of an optimization problem, and show how to set up and solve it in Python.
A linear optimization example
One of the oldest and most widely-used areas of optimization is linear optimization (or linear programming ), in which the objective function and the constraints can be written as linear expressions. Here's a simple example of this type of problem.
Maximize 3x + y subject to the following constraints:
- 0 ≤ x ≤ 1
- 0 ≤ y ≤ 2
- x + y ≤ 2
The objective function in this example is 3x + y . Both the objective function and the constraints are given by linear expressions, which makes this a linear problem.
Main steps in solving the problem
For each language, the basic steps for setting up and solving a problem are the same:
- Import the required libraries,
- Declare the solver,
- Create the variables,
- Define the constraints,
- Define the objective function,
- Invoke the solver and
- Display the results.
Python program
This section walks through a Python program that sets up and solves the problem.
Here are the steps:
- Import the required libraries. from ortools.linear_solver import pywraplp from ortools.init import pywrapinit
- Declare the solver. # Create the linear solver with the GLOP backend. solver = pywraplp.Solver.CreateSolver('GLOP') if not solver: return pywraplp is a Python wrapper for the underlying C++ solver. The argument "GLOP" specifies GLOP , the OR-Tools linear solver.
- Create the variables. # Create the variables x and y. x = solver.NumVar(0, 1, 'x') y = solver.NumVar(0, 2, 'y') print('Number of variables =', solver.NumVariables())
- Define the constraints. The first two constraints, 0 ≤ x ≤ 1 and 0 ≤ y ≤ 2 , are already set by the definitions of the variables. The following code defines the constraint x + y ≤ 2 : # Create a linear constraint, 0 <= x + y <= 2. ct = solver.Constraint(0, 2, 'ct') ct.SetCoefficient(x, 1) ct.SetCoefficient(y, 1) print('Number of constraints =', solver.NumConstraints()) The method SetCoefficient sets the coefficients of x and y in the expression for the constraint.
- Define the objective function. # Create the objective function, 3 * x + y. objective = solver.Objective() objective.SetCoefficient(x, 3) objective.SetCoefficient(y, 1) objective.SetMaximization() The method SetMaximization declares this to be a maximization problem.
- Invoke the solver and display the results. solver.Solve() print('Solution:') print('Objective value =', objective.Value()) print('x =', x.solution_value()) print('y =', y.solution_value())
Complete program
The complete program is shown below.
Running the program
You can run the program above as follows:
- Copy and paste the code above into new file and save it as program.py .
- Open a command window and change to the directory where you saved program.py . At the command prompt, enter: python relative/path/to/ program.py where relative/path/to/ is the path to the directory where you saved the program.
The program returns the values of x and y that maximize the objective function:
For more Python examples that illustrate how to solve various types of optimization problems, see Examples .
There are many different types of optimization problems in the world. For each type of problem, there are different approaches and algorithms for finding an optimal solution.
Before you can start writing a program to solve an optimization problem, you need to identify what type of problem you are dealing with, and then choose an appropriate solver — an algorithm for finding an optimal solution.
Below you will find a brief overview of the types of problems that OR-Tools solves, and links to the sections in this guide that explain how to solve each problem type.
Linear optimization
Constraint optimization, mixed-integer optimization, network flows.
As you learned in the previous section , a linear optimization problem is one in which the objective function and the constraints are linear expressions in the variables.
The primary solver in OR-Tools for this type of problem is the linear optimization solver, which is actually a wrapper for several different libraries for linear and mixed-integer optimization , including third-party libraries.
Learn more about linear optimization
A mixed integer optimization problem is one in which some or all of the variables are required to be integers. An example is the assignment problem , in which a group of workers needs be assigned to a set of tasks. For each worker and task, you define a variable whose value is 1 if the given worker is assigned to the given task, and 0 otherwise. In this case, the variables can only take on the values 0 or 1.
Learn more about mixed-integer optimization
Constraint optimization, or constraint programming (CP), identifies feasible solutions out of a very large set of candidates, where the problem can be modeled in terms of arbitrary constraints. CP is based on feasibility (finding a feasible solution) rather than optimization (finding an optimal solution) and focuses on the constraints and variables rather than the objective function. However, CP can be used to solve optimization problems, simply by comparing the values of the objective function for all feasible solutions.
Learn more about constraint optimization
Assignment problems involve assigning a group of agents (say, workers or machines) to a set of tasks, where there is a fixed cost for assigning each agent to a specific task. The problem is to find the assignment with the least total cost. Assignment problems are actually a special case of network flow problems .
Learn more about assignment
Bin packing is the problem of packing a set of objects of different sizes into containers with different capacities. The goal is to pack as many of the objects as possible, subject to the capacities of the containers. A special case of this is the Knapsack problem , in which there is just one container.
Learn more about bin packing
Scheduling problems involve assigning resources to perform a set of tasks at specific times. An important example is the job shop problem , in which multiple jobs are processed on several machines. Each job consists of a sequence of tasks, which must be performed in a given order, and each task must be processed on a specific machine. The problem is to assign a schedule so that all jobs are completed in as short an interval of time as possible.
Learn more about scheduling
Routing problems involve finding the optimal routes for a fleet of vehicles to traverse a network, defined by a directed graph. The problem of assigning packages to delivery trucks, described in What is an optimization problem ? , is one example of a routing problem. Another is the traveling salesperson problem .
Learn more about routing
Many optimization problems can be represented by a directed graph consisting of nodes and directed arcs between them. For example, transportation problems, in which goods are shipped across a railway network, can be represented by a graph in which the arcs are rail lines and the nodes are distribution centers.
In the maximum flow problem , each arc has a maximum capacity that can be transported across it. The problem is to assign the amount of goods to be shipped across each arc so that the total quantity being transported is as large as possible.
Learn more about network flows
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-01-18 UTC.
Information
- Author Services
Initiatives
You are accessing a machine-readable page. In order to be human-readable, please install an RSS reader.
All articles published by MDPI are made immediately available worldwide under an open access license. No special permission is required to reuse all or part of the article published by MDPI, including figures and tables. For articles published under an open access Creative Common CC BY license, any part of the article may be reused without permission provided that the original article is clearly cited. For more information, please refer to https://www.mdpi.com/openaccess .
Feature papers represent the most advanced research with significant potential for high impact in the field. A Feature Paper should be a substantial original Article that involves several techniques or approaches, provides an outlook for future research directions and describes possible research applications.
Feature papers are submitted upon individual invitation or recommendation by the scientific editors and must receive positive feedback from the reviewers.
Editor’s Choice articles are based on recommendations by the scientific editors of MDPI journals from around the world. Editors select a small number of articles recently published in the journal that they believe will be particularly interesting to readers, or important in the respective research area. The aim is to provide a snapshot of some of the most exciting work published in the various research areas of the journal.

- Active Journals
- Find a Journal
- Proceedings Series
- For Authors
- For Reviewers
- For Editors
- For Librarians
- For Publishers
- For Societies
- For Conference Organizers
- Open Access Policy
- Institutional Open Access Program
- Special Issues Guidelines
- Editorial Process
- Research and Publication Ethics
- Article Processing Charges
- Testimonials
- Preprints.org
- SciProfiles
- Encyclopedia

Article Menu

- Subscribe SciFeed
- Recommended Articles
- Google Scholar
- on Google Scholar
- Table of Contents
Find support for a specific problem in the support section of our website.
Please let us know what you think of our products and services.
Visit our dedicated information section to learn more about MDPI.
JSmol Viewer
Multi-objective task scheduling optimization in spatial crowdsourcing.

1. Introduction
2. related work, 2.1. task matching in sc, 2.2. task scheduling problem in sc, 2.3. the binary-objective optimization problem in sc, 3. the motso model in sc, 3.1. the ranking strategy algorithm, 3.1.1. task execution duration (ted) and ranked task execution duration (rted), 3.1.2. task entropy (te) and ranked task entropy (rte), 3.1.3. the ranked tables, 3.2. multi-objective particle swarm optimization, 4. performance evaluation.
- N is the inertia weight;
- P is population number;
- I is iteration number;
- D is duration max;
- C1 and C2 are acceleration coefficients;
- r1 and r2 are random numbers;
- S is the speed of workers;
- No.w is the number of workers;
- No.t is the number of tasks.
4.1. The Performance of the Ranking Strategy Algorithm
- Initializing the position of a particle randomly (the percentage of randomness is 100%);
- Initializing the position of a hybrid particle, both randomly and from the ranked table (the percentage of randomness is 50%);
- Initializing the positions of all particles from the ranked table (the percentage of randomness is 0%).
- Initializing the positions of all particles randomly;
- Initializing the positions of all particles using the output of the ranking strategy stage.
4.2. Performance of the MOTSO Model
4.2.1. maximizing the number of completed tasks, 4.2.2. minimizing the total travel costs (ttcs), 4.2.3. minimizing the standard deviation of the workload balance, 5. conclusions, author contributions, data availability statement, conflicts of interest, abbreviations.
- Wang, Y.; Jia, X.; Jin, Q.; Ma, J. Mobile crowdsourcing: Framework, challenges, and solutions. Concurr. Comput. Pr. Exp. 2016 , 29 , e3789. [ Google Scholar ] [ CrossRef ]
- Sun, D.; Gao, Y.; Yu, D. Efficient and Load Balancing Strategy for Task Scheduling in Spatial Crowdsourcing. In Web-Age Information Management ; Song, S., Tong, Y., Eds.; Springer: Berlin, Germany, 2016; pp. 161–173. [ Google Scholar ]
- Tong, Y.; She, J.; Ding, B.; Wang, L.; Chen, L. Online mobile Micro-Task Allocation in spatial crowdsourcing. In Proceedings of the 2016 IEEE 32nd International Conference on Data Engineering (ICDE), Helsinki, Finland, 16–20 May 2016; pp. 49–60. [ Google Scholar ]
- Song, T.; Tong, Y.; Wang, L.; She, J.; Yao, B.; Chen, L.; Xu, K. Trichromatic Online Matching in Real-Time Spatial Crowdsourcing. In Proceedings of the 2017 IEEE 33rd International Conference on Data Engineering (ICDE), San Diego, CA, USA, 19–22 April 2017; pp. 1009–1020. [ Google Scholar ]
- Zhao, Y.; Han, Q. Spatial crowdsourcing: Current state and future directions. IEEE Commun. Mag. 2016 , 54 , 102–107. [ Google Scholar ] [ CrossRef ]
- Kazemi, L.; Shahabi, C. GeoCrowd: Enabling Query Answering with Spatial Crowdsourcing. In Proceedings of the 20th International Conference on Intelligent User Interfaces, Redondo Beach, CA, USA, 6–9 November 2012; pp. 189–198. [ Google Scholar ]
- Chen, L.; Shahabi, C. Spatial Crowdsourcing: Challenges and Opportunities. IEEE Data Eng. Bull. 2016 , 39 , 14–25. [ Google Scholar ]
- Cheng, P.; Lian, X.; Chen, L.; Han, J.; Zhao, J. Task Assignment on Multi-Skill Oriented Spatial Crowdsourcing. IEEE Trans. Knowl. Data Eng. 2016 , 28 , 2201–2215. [ Google Scholar ] [ CrossRef ][ Green Version ]
- Kazemi, L.; Shahabi, C.; Chen, L. GeoTruCrowd: Trustworthy Query Answering with Spatial Crowdsourcing. In Proceedings of the 21st ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems, Orlando, FL, USA, 5–8 November 2013; pp. 314–323. [ Google Scholar ]
- Deng, D.; Shahabi, C.; Zhu, L. Task matching and scheduling for multiple workers in spatial crowdsourcing. In Proceedings of the 23rd SIGSPATIAL International Conference on Advances in Geographic Information Systems, Seattle, DC, USA, 3–6 November 2015; p. 21. [ Google Scholar ]
- Deng, D.; Shahabi, C.; Demiryurek, U. Maximizing the number of worker’s self-selected tasks in spatial crowdsourcing. In Proceedings of the 21st ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems, Orlando, FL, USA, 5–8 November 2013; pp. 324–333. [ Google Scholar ]
- Tran, L.; To, H.; Fan, L.; Shahabi, C. A Real-Time Framework for Task Assignment in Hyperlocal Spatial Crowdsourcing. ACM Trans. Intell. Syst. Technol. 2018 , 9 , 1–26. [ Google Scholar ] [ CrossRef ][ Green Version ]
- Tsai, J.-T.; Fang, J.-C.; Chou, J.-H. Optimized task scheduling and resource allocation on cloud computing environment using improved differential evolution algorithm. Comput. Oper. Res. 2013 , 40 , 3045–3055. [ Google Scholar ] [ CrossRef ]
- Zhang, G.; Zuo, X. Deadline Constrained Task Scheduling Based on Standard-PSO in a Hybrid Cloud. In Advances in Swarm Intelligence ; Tan, Y., Shi, Y., Mo, H., Eds.; Springer: Berlin/Heidelberg, Germany, 2013; Volume 7928, pp. 200–209. [ Google Scholar ]
- Jana, B.; Chakraborty, M.; Mandal, T. A Task Scheduling Technique Based on Particle Swarm Optimization Algorithm in Cloud Environment. In Soft Computing: Theories and Applications ; Ray, K., Sharma, T.K., Rawat, S., Saini, R.K., Bandyopadhyay, A., Eds.; Springer: Singapore, 2019; Volume 742, pp. 525–536. [ Google Scholar ]
- Kennedy, J.; Eberhart, R. Particle swarm optimization. In Proceedings of the ICNN’95-International Conference on Neural Networks, Perth, WA, Australia, 27 November–1 December 1995; Volume 4, pp. 1942–1948. [ Google Scholar ] [ CrossRef ]
- Wang, D.; Tan, D.; Liu, L. Particle swarm optimization algorithm: An overview. Soft Comput. 2018 , 22 , 387–408. [ Google Scholar ] [ CrossRef ]
- Coello, C.C.; Lechuga, M. MOPSO: A proposal for multiple objective particle swarm optimization. In Proceedings of the 2002 Congress on Evolutionary Computation, 2002. CEC ’02, Honolulu, HI, USA, 12–17 May 2003; Volume 2, pp. 1051–1056. [ Google Scholar ]
- Alabbadi, A.A.; Abulkhair, M.F. Task-Scheduling Based on Multi-Objective Particle Swarm Optimization in Spatial Crowdsourcing. J. King Abdulaziz Univ. Comput. Inf. Technol. Sci. 2019 , 8 , 45–57. [ Google Scholar ] [ CrossRef ]
- Chen, Z.; Fu, R.; Zhao, Z.; Liu, Z.; Xia, L.; Chen, L.; Cheng, P.; Cao, C.C.; Tong, Y.; Zhang, C.J. gMission: A General Spatial Crowdsourcing Platform. Proc. VLDB Endow. 2014 , 7 , 1629–1632. [ Google Scholar ] [ CrossRef ]
- Uber. Available online: https://www.uber.com// (accessed on 22 November 2018).
- Google Maps. Available online: https://www.google.com/maps (accessed on 22 November 2018).
- Free Driving Directions, Traffic Reports & GPS Navigation App by Waze. Available online: https://www.waze.com/ (accessed on 22 November 2018).
- Restaurants, Dentists, Bars, Beauty Salons, Doctors—Yelp. Available online: https://www.yelp.com/ (accessed on 22 November 2018).
- TaskRabbit Connects You to Safe and Reliable Help in Your Neighborhood. Available online: https://www.taskrabbit.com/ (accessed on 22 November 2018).
- Gigwalk: We’ve Got Your Brand’s Back—Gigwalk. Available online: http://www.gigwalk.com/ (accessed on 22 November 2018).
- To, H. Task Assignment in Spatial Crowdsourcing: Challenges and Approaches. In Proceedings of the 3rd ACM SIGSPATIAL PhD Symposium, Burlingame, CA, USA, 31 October 2016; Volume 1, pp. 1–4. [ Google Scholar ]
- Cheng, P.; Jian, X.; Chen, L. Task Assignment on Spatial Crowdsourcing (Technical Report). arXiv 2016 , arXiv:1605.09675. [ Google Scholar ]
- Gummidi, S.R.B.; Xie, X.; Pedersen, T.B. A Survey of Spatial Crowdsourcing. ACM Trans. Database Syst. 2019 , 44 , 1–46. [ Google Scholar ] [ CrossRef ]
- Tong, Y.; Zhou, Z.; Zeng, Y.; Chen, L.; Shahabi, C. Spatial crowdsourcing: A survey. VLDB J. 2019 , 29 , 217–250. [ Google Scholar ] [ CrossRef ]
- To, H.; Shahabi, C.; Kazemi, L. A Server-Assigned Spatial Crowdsourcing Framework. ACM Trans. Spat. Algorithms Syst. 2015 , 1 , 1–28. [ Google Scholar ] [ CrossRef ]
- To, H.; Fan, L.; Tran, L.; Shahabi, C. Real-time task assignment in hyperlocal spatial crowdsourcing under budget constraints. In Proceedings of the 2016 IEEE International Conference on Pervasive Computing and Communications (PerCom), Sydney, NSW, Australia, 14–19 March 2016; pp. 1–8. [ Google Scholar ]
- Alfarrarjeh, A.; Emrich, T.; Shahabi, C. Scalable Spatial Crowdsourcing: A Study of Distributed Algorithms. In Proceedings of the 2015 16th IEEE International Conference on Mobile Data Management, Pittsburgh, PA, USA, 15–18 June 2015; Volume 1, pp. 134–144. [ Google Scholar ]
- Hassan, U.U.; Curry, E. Efficient task assignment for spatial crowdsourcing: A combinatorial fractional optimization approach with semi-bandit learning. Expert Syst. Appl. 2016 , 58 , 36–56. [ Google Scholar ] [ CrossRef ]
- Wang, L.; Yu, Z.; Han, Q.; Guo, B.; Xiong, H. Multi-Objective Optimization Based Allocation of Heterogeneous Spatial Crowdsourcing Tasks. IEEE Trans. Mob. Comput. 2017 , 17 , 1637–1650. [ Google Scholar ] [ CrossRef ]
- SNAP: Network Datasets: Gowalla. Available online: http://snap.stanford.edu/data/loc-gowalla.html (accessed on 17 January 2017).
Share and Cite
Alabbadi, A.A.; Abulkhair, M.F. Multi-Objective Task Scheduling Optimization in Spatial Crowdsourcing. Algorithms 2021 , 14 , 77. https://doi.org/10.3390/a14030077
Alabbadi AA, Abulkhair MF. Multi-Objective Task Scheduling Optimization in Spatial Crowdsourcing. Algorithms . 2021; 14(3):77. https://doi.org/10.3390/a14030077
Alabbadi, Afra A., and Maysoon F. Abulkhair. 2021. "Multi-Objective Task Scheduling Optimization in Spatial Crowdsourcing" Algorithms 14, no. 3: 77. https://doi.org/10.3390/a14030077
Article Metrics
Article access statistics, further information, mdpi initiatives, follow mdpi.

Subscribe to receive issue release notifications and newsletters from MDPI journals
Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Is there a greedy algorithm to solve the assignment problem?
The assignment problem is defined as:
There are n people who need to be assigned to n jobs, one person per job. The cost that would accrue if the ith person is assigned to the jth job is a known quantity C[i,j] for each pair i, j = 1, 2, ..., n. The problem is to find an assignment with the minimum total cost.
There is a question asking to design a greedy algorithm to solve the problem. It also asks if the greedy algorithm always yields an optimal solution and for the performance class of the algorithm. Here is my attempt at designing an algorithm:

Am I correct in saying that my algorithm is of O(n^2)? Am I also correct in saying that a greedy algorithm does not always yield an optimal solution? I used my algorithm on the following cost matrix and it is clearly not the optimal solution. Did I Do something wrong?

- greedy-algorithms
- assignment-problem
- $\begingroup$ Algorithms for maximum weight bipartite maximum matching are unfortunately more complicated than that. They don't really follow the greedy paradigm. $\endgroup$ – Yuval Filmus Apr 7, 2017 at 6:05
The answer of your post question (already given in Yuval comment) is that there is no greedy techniques providing you the optimal answer to an assignment problem.
The commonly used solution is the Hungarian algorithm, see
Harold W. Kuhn, "The Hungarian Method for the assignment problem", Naval Research Logistics Quarterly, 2: 83–97, 1955
for the original paper.
Otherwise your solution seems correct to me, and as usually with greedy algorithms, it will provide you a feasible solution which you may hope to not be "too far" from the global optimal solution.
Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged algorithms greedy-algorithms assignment-problem or ask your own question .
- Upcoming Events
- 2023 Community Moderator Election ends in 8 days
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
- The Stack Exchange reputation system: What's working? What's not?
- 2023 Community Moderator Election
- 2023 Moderator Election Q&A – Question Collection
Hot Network Questions
- How can I protect /dev/sdX against accidental formatting?
- Theoretical Computer Science vs other Sciences?
- Are there 2 Parkruns close enough together with a large enough start time difference such that one could run both on one day?
- Is there a RAW or optional rule for how a player could discover what type of skill check needs to be made?
- Can the positive root of this polynomial be expressed elementarily?
- Detecting the version of i486 CPU
- What filter is used on this image?
- Finding a career as a researcher without any PhD, work experience, and/or relevant academic degree
- How was altitude calculated before the invention of the altimeter?
- Is cross examination strictly confined to the subjects that the original examination pertained to, or can the opposing party make their own points?
- In Acts 8:32–33 was the Ethiopian eunuch reading a Septuagint scroll or a Hebrew scroll?
- Why Hegel thinks that A and not-A will entail each other?
- Clarifications on the Eversmoking Bottle 5e
- Applying geometry nodes doesn't work on a curve object
- Can we explain why using `Nothing` twice on a list does not operate twice?
- Is the cabin pressure "worse" at the back of the cabin than in front?
- How can I make the rules of my Faerie Portal free from contradiction?
- Find replacement HVAC transformer
- Did any storylines or content from The Clone Wars exist prior to its broadcasting?
- Truncated floor symbol
- What is the velocity in the Lorentz equation relative to when considering a vacuum?
- On top of itself
- I need to have each line of a file run in a subshell of its own
- Best practices Use == or isSameDay apex date
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

IMAGES
VIDEO
COMMENTS
There is an algorithm that optimally solves the problem with time complexity O((n ⋅log(max p j))k) for some fixed k. NP-hard in the ordinary sense (pseudo polynomial time complexity): The problem cannot be optimally solved by an algorithm with polynomial time complexity but with an algorithm of time complexity O((n ⋅max p j)k).
Step 4: Since we only need 2 lines to cover all zeroes, we have NOT found the optimal assignment. Step 5: We subtract the smallest uncovered entry from all uncovered rows. Smallest entry is 500. -500 0 2000 -500 1500 500 0 0 0 Then we add the smallest entry to all covered columns, we get 0 0 2000 0 1500 500 500 0 0 Now we return to Step 3:.
The assignment problem consists of finding, in a weightedbipartite graph, a matchingof a given size, in which the sum of weights of the edges is minimum. If the numbers of agents and tasks are equal, then the problem is called balanced assignment. Otherwise, it is called unbalanced assignment.[1]
The problem is NP-hard, at least for a particular simplified configuration. Assume that each m l is effectively infinite - we can scan a particular libraries' books all on the day we get access. Let all d l = 1 - each library takes one day to get access to, meaning we get access to exactly n libraries.
Many scheduling problems can be solved using greedy algorithms. Problem statement: Given N events with their starting and ending times, find a schedule that includes as many events as possible. It is not possible to select an event partially. Consider the below events: In this case, the maximum number of events is two.
The basic form of the problem of scheduling jobs with multiple (M) operations, over M machines, such that all of the first operations must be done on the first machine, all of the second operations on the second, etc., and a single job cannot be performed in parallel, is known as the flow-shop schedulingproblem.
change that solution by just changing a few assignments and recalculate the ponderation if 2. is better than 1. and repeat starting with 2. as the root solution if you're blocked, you can "visit" other solutions by making important changes to the initial solution. Share Improve this answer Follow answered Oct 20, 2009 at 22:03 Vladimir
Fig. 2: An example of the greedy algorithm for interval scheduling. The nal schedule is f1;4;7g. Second, we consider optimality. The proof's structure is worth noting, because it is common to many correctness proofs for greedy algorithms. It begins by considering an arbitrary solution, which may assume to be an optimal solution.
3.2 Minimum Makespan Scheduling A central problem in scheduling theory is to design a schedule such that the last nishing time of the given jobs (also called makespan) is minimized. This problem is called the minimum makespan scheduling. Problem De nition Given processing times for n jobs, p1;p2;:::;pn, and an integer m, nd an assignment of the ...
This is a mapping problem: you need to map to every hour in a week and every teacher an activity (teach to a certain class or free hour ). Split the problem: Create the list of teachers, classes and preferences then let the user populate some of the preferences on a map to have as a starting point.
The Restricted Assignment Scheduling Problem (RASP), the problem that was proposed by Bertogna () as an example of the kinds of complex multiprocessor scheduling problems that arise in the analysis of modern safety-critical real-time systems, may be described in the following manner.We have a real-time workload that is modeled as a directed acyclic graph \(G=(V,E)\), in which the vertices ...
different subproblems: course timetabling, class-teacher timetabling, student scheduling, teacher assignment, and classroom assignment. This paper focuses primarily on the teacher assignment problem.
In the genetic algorithm solution, the problem is being broken down into 2 sections i.e. a) The assignment of teachers to each subject of each class since each subject of each class can only be taught by 1 teacher as in Rule 5. b)The assignment of classes to each class.
Optimization problems are ubiquitous in logistics, where the scheduling, sequencing and assignment of activities and resources have a significant impact on operational efficiency. These optimization problems are encountered across the entirety of the modern supply chain: sequencing orders on production lines, scheduling cranes in container ...
Key words: Approximation algorithms, generalized assignment problem, scheduling unrelated parallel machines. 1. Introduction The generalized assignment problem can be viewed as the following problem of scheduling parallel machines with costs. Each of n independent jobs is to be processed by exactly one
Genetic algorithms are known to give the best solutions to such problems. The purpose of this paper is to propound a solution to a job scheduling problem using genetic algorithms. The experimental results show that the most important factor on the time complexity of the algorithm is the size of the population and the number of generations.
Assignment. Assignment problems involve assigning a group of agents (say, workers or machines) to a set of tasks, where there is a fixed cost for assigning each agent to a specific task. The problem is to find the assignment with the least total cost. Assignment problems are actually a special case of network flow problems. Learn more about ...
To solve the previous problem, we developed a new method, i.e., the multi-objective task scheduling optimization (MOTSO) model that consists of two algorithms, namely, the multi-objective particle swarm optimization (MOPSO) algorithm with our fitness function Alabbadi, et al. and the ranking strategy algorithm based on the task entropy concept ...
2. The answer of your post question (already given in Yuval comment) is that there is no greedy techniques providing you the optimal answer to an assignment problem. The commonly used solution is the Hungarian algorithm, see. Harold W. Kuhn, "The Hungarian Method for the assignment problem", Naval Research Logistics Quarterly, 2: 83-97, 1955.