SlideShare une entreprise Scribd logo
1  sur  20
Computational
Thinking
11: Activity Selection Problem
Outline
1. Introduction
2. Real Life Applications of ASP
3. Model Formulation
4. Problem Solving
5. Example
6. Summary
1. Introduction
● An activity selection is the problem of scheduling among several
competing activities
● We have a list of activities with their starting time and finishing time.
● Our goal is to select maximum number of non-conflicting activities
that can be performed by a person or a machine, assuming that the
person or machine involved can work on a single activity at a time.
● Any two activities are said to be non-conflicting if starting time of one
activity is greater than or equal to the finishing time of the other
activity.
● In order to solve this problem
we first sort the activities as
per their finishing time in
ascending order.
● Then we select non-
conflicting activities.
Interval Scheduling Problem
● The activity selection problem is also known as the Interval
scheduling maximization problem (ISMP), which is a special type of
the more general Interval Scheduling problem.
● ISMP is about Job Sequencing Problem with Deadline. This problem
consists of n jobs each associated with a deadline and profit and our
objective is to earn maximum profit. We will earn profit only when job
is completed on or before deadline. We assume that each job will take
unit time to complete.
2. Real Life Applications of ASP
Following are some of the real-life applications of this problem:
● Scheduling multiple competing events in a room, such that each event
has its own start and end time.
● Scheduling manufacturing of multiple products on the same machine,
such that each product has its own production timelines.
● Activity Selection is one of the most well-known generic problems
used in Operations Research for dealing with real-life business
problems.
3. Model Formulation
Assume we have n activities with their start and finish times, the
objective is to find solution set having maximum number of non-
conflicting activities that can be executed in a single time frame,
assuming that only one person or machine is available for execution.
Some points to note here:
•It might not be possible to complete all the activities, since their
timings can collapse.
•Two activities, say i and j, are said to be non-conflicting if si >=
fj or sj >= fi where si and sj denote the starting time of
activities i and j respectively, and fi and fj refer to the finishing time
of the activities i and j respectively.
Input and Output Specifications
Input Data for the Algorithm:
•act[] array containing all the activities.
•s[] array containing the starting time of all the activities.
•f[] array containing the finishing time of all the activities.
Ouput Data from the Algorithm:
•sol[] array refering to the solution set containing the maximum
number of non-conflicting activities.
Problem Formulation
4. Problem Solving
Algorithm
Following are the steps we will be following to solve the activity
selection problem,
Step 1: Sort the given activities in ascending order according to their
finishing time.
Step 2: Select the first activity from sorted array act[] and add it
to sol[] array.
Step 3: Repeat steps 4 and 5 for the remaining activities in act[].
Step 4: If the start time of the currently selected activity is greater than
or equal to the finish time of previously selected activity, then add it to
the sol[] array.
Step 5: Select the next activity in act[] array.
Step 6: Print the sol[] array.
5. Examples
Example 1
Let's try to trace the steps of above algorithm using an
example:
In the table below, we have 6 activities with corresponding
start and end time, the objective is to compute an execution
schedule having maximum number of non-conflicting
activities:
Example 2
A possible solution would be:
Step 1: Sort the given activities in ascending order according to their finishing
time.
The table after we have sorted it:For the data given in the above table,
A.Select activity a3. Since the start time of a3 is
greater than the finish time of a2 (i.e. s(a3) > f(a2)), we
add a3 to the solution set. Thus sol = {a2, a3}.
B.Select a4. Since s(a4) < f(a3), it is not added to the
solution set.
C.Select a5. Since s(a5) > f(a3), a5 gets added to
solution set. Thus sol = {a2, a3, a5}
D.Select a1. Since s(a1) < f(a5), a1 is not added to the
solution set.
E.Select a6. a6 is added to the solution set since s(a6)
> f(a5). Thus sol = {a2, a3, a5, a6}.
Step 6: At last, print the array sol[]
Optimal
Solution
Example 3
References
1. https://dyclassroom.com/greedy-algorithm/activity-selection-problem
2. https://dyclassroom.com/greedy-algorithm/job-sequencing-problem-with-deadline
3. https://www.studytonight.com/data-structures/activity-selection-problem#
4. https://www.slideserve.com/graiden-sykes/in-the-name-of-god-algorithms-design-
greedy-algorithms
5. https://slideplayer.com/slide/17736397/
Thank You

Contenu connexe

Similaire à Computational Thinking 11- ActivitySelection.pptx

data structures and algorithms Unit 4
data structures and algorithms Unit 4data structures and algorithms Unit 4
data structures and algorithms Unit 4infanciaj
 
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...iosrjce
 
Job sequencing with Deadlines
Job sequencing with DeadlinesJob sequencing with Deadlines
Job sequencing with DeadlinesYashiUpadhyay3
 
Chapter 6-Scheduling in Industrial of Engineering
Chapter 6-Scheduling in Industrial of EngineeringChapter 6-Scheduling in Industrial of Engineering
Chapter 6-Scheduling in Industrial of EngineeringFaizAzmy2
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptxRahikAhmed1
 
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...ijcsit
 
ADSA orientation.pptx
ADSA orientation.pptxADSA orientation.pptx
ADSA orientation.pptxKiran Babar
 
Modified heuristic time deviation Technique for job sequencing and Computatio...
Modified heuristic time deviation Technique for job sequencing and Computatio...Modified heuristic time deviation Technique for job sequencing and Computatio...
Modified heuristic time deviation Technique for job sequencing and Computatio...ijcsit
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basicsayeshasafdar8
 
complexity.pptx
complexity.pptxcomplexity.pptx
complexity.pptxDr.Shweta
 
Chap017 Scheduling Edit
Chap017 Scheduling EditChap017 Scheduling Edit
Chap017 Scheduling EditRicky Muchtar
 
Sequential Models - Meaning, assumptions, Types and Problems
Sequential Models - Meaning, assumptions, Types and ProblemsSequential Models - Meaning, assumptions, Types and Problems
Sequential Models - Meaning, assumptions, Types and ProblemsSundar B N
 

Similaire à Computational Thinking 11- ActivitySelection.pptx (20)

data structures and algorithms Unit 4
data structures and algorithms Unit 4data structures and algorithms Unit 4
data structures and algorithms Unit 4
 
Algorithms.pdf
Algorithms.pdfAlgorithms.pdf
Algorithms.pdf
 
Greedy method
Greedy methodGreedy method
Greedy method
 
Unit V.pdf
Unit V.pdfUnit V.pdf
Unit V.pdf
 
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
 
C017611624
C017611624C017611624
C017611624
 
Job sequencing with Deadlines
Job sequencing with DeadlinesJob sequencing with Deadlines
Job sequencing with Deadlines
 
Chapter 6-Scheduling in Industrial of Engineering
Chapter 6-Scheduling in Industrial of EngineeringChapter 6-Scheduling in Industrial of Engineering
Chapter 6-Scheduling in Industrial of Engineering
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Master thesis report
Master thesis reportMaster thesis report
Master thesis report
 
ADSA orientation.pptx
ADSA orientation.pptxADSA orientation.pptx
ADSA orientation.pptx
 
Modified heuristic time deviation Technique for job sequencing and Computatio...
Modified heuristic time deviation Technique for job sequencing and Computatio...Modified heuristic time deviation Technique for job sequencing and Computatio...
Modified heuristic time deviation Technique for job sequencing and Computatio...
 
Line balancing and heuristics
Line balancing and heuristicsLine balancing and heuristics
Line balancing and heuristics
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basics
 
complexity.pptx
complexity.pptxcomplexity.pptx
complexity.pptx
 
Chap017 Scheduling Edit
Chap017 Scheduling EditChap017 Scheduling Edit
Chap017 Scheduling Edit
 
Sequential Models - Meaning, assumptions, Types and Problems
Sequential Models - Meaning, assumptions, Types and ProblemsSequential Models - Meaning, assumptions, Types and Problems
Sequential Models - Meaning, assumptions, Types and Problems
 

Dernier

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 

Dernier (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 

Computational Thinking 11- ActivitySelection.pptx

  • 2. Outline 1. Introduction 2. Real Life Applications of ASP 3. Model Formulation 4. Problem Solving 5. Example 6. Summary
  • 3. 1. Introduction ● An activity selection is the problem of scheduling among several competing activities ● We have a list of activities with their starting time and finishing time. ● Our goal is to select maximum number of non-conflicting activities that can be performed by a person or a machine, assuming that the person or machine involved can work on a single activity at a time. ● Any two activities are said to be non-conflicting if starting time of one activity is greater than or equal to the finishing time of the other activity.
  • 4. ● In order to solve this problem we first sort the activities as per their finishing time in ascending order. ● Then we select non- conflicting activities.
  • 5. Interval Scheduling Problem ● The activity selection problem is also known as the Interval scheduling maximization problem (ISMP), which is a special type of the more general Interval Scheduling problem. ● ISMP is about Job Sequencing Problem with Deadline. This problem consists of n jobs each associated with a deadline and profit and our objective is to earn maximum profit. We will earn profit only when job is completed on or before deadline. We assume that each job will take unit time to complete.
  • 6. 2. Real Life Applications of ASP Following are some of the real-life applications of this problem: ● Scheduling multiple competing events in a room, such that each event has its own start and end time. ● Scheduling manufacturing of multiple products on the same machine, such that each product has its own production timelines. ● Activity Selection is one of the most well-known generic problems used in Operations Research for dealing with real-life business problems.
  • 7. 3. Model Formulation Assume we have n activities with their start and finish times, the objective is to find solution set having maximum number of non- conflicting activities that can be executed in a single time frame, assuming that only one person or machine is available for execution. Some points to note here: •It might not be possible to complete all the activities, since their timings can collapse. •Two activities, say i and j, are said to be non-conflicting if si >= fj or sj >= fi where si and sj denote the starting time of activities i and j respectively, and fi and fj refer to the finishing time of the activities i and j respectively.
  • 8. Input and Output Specifications Input Data for the Algorithm: •act[] array containing all the activities. •s[] array containing the starting time of all the activities. •f[] array containing the finishing time of all the activities. Ouput Data from the Algorithm: •sol[] array refering to the solution set containing the maximum number of non-conflicting activities.
  • 10.
  • 12. Algorithm Following are the steps we will be following to solve the activity selection problem, Step 1: Sort the given activities in ascending order according to their finishing time. Step 2: Select the first activity from sorted array act[] and add it to sol[] array. Step 3: Repeat steps 4 and 5 for the remaining activities in act[]. Step 4: If the start time of the currently selected activity is greater than or equal to the finish time of previously selected activity, then add it to the sol[] array. Step 5: Select the next activity in act[] array. Step 6: Print the sol[] array.
  • 14. Let's try to trace the steps of above algorithm using an example: In the table below, we have 6 activities with corresponding start and end time, the objective is to compute an execution schedule having maximum number of non-conflicting activities: Example 2
  • 15. A possible solution would be: Step 1: Sort the given activities in ascending order according to their finishing time. The table after we have sorted it:For the data given in the above table, A.Select activity a3. Since the start time of a3 is greater than the finish time of a2 (i.e. s(a3) > f(a2)), we add a3 to the solution set. Thus sol = {a2, a3}. B.Select a4. Since s(a4) < f(a3), it is not added to the solution set. C.Select a5. Since s(a5) > f(a3), a5 gets added to solution set. Thus sol = {a2, a3, a5} D.Select a1. Since s(a1) < f(a5), a1 is not added to the solution set. E.Select a6. a6 is added to the solution set since s(a6) > f(a5). Thus sol = {a2, a3, a5, a6}. Step 6: At last, print the array sol[]
  • 18.
  • 19. References 1. https://dyclassroom.com/greedy-algorithm/activity-selection-problem 2. https://dyclassroom.com/greedy-algorithm/job-sequencing-problem-with-deadline 3. https://www.studytonight.com/data-structures/activity-selection-problem# 4. https://www.slideserve.com/graiden-sykes/in-the-name-of-god-algorithms-design- greedy-algorithms 5. https://slideplayer.com/slide/17736397/