SlideShare a Scribd company logo
DDW Clinic Session 3
State Machine
Outline
1. What is a state machine?
2. How to construct a state diagram
3. Abstract state machine class
4. BFS
1. What is a state machine?
● A computation machine where the output is a function of the current input
AND all the previous inputs
●
Pure function State machine
2. How to construct a state transition diagram
Template Sample diagram
● Contains: State, Input, Output
○ Output may or may not be the next state
3. Abstract state machine class
● Points to note:
○ Inherits from abc.ABC (python module for abstract base class)
○ 2 attributes:
■ self.start_state
■ self.state
○ 4 methods:
■ self.start()
■ self.get_next_values(state, inp) → next_state, output
■ self.step(inp)
■ self.tranduce() → output[]
Code.
Part 1.
Code.
Part 2.
Code.
Part 3.
4. BFS
● Explores all
neighboring
vertices before
going in depth
(1) (2)
Source: DDW notes
4. BFS
● Problem: Find shortest path from S to H
● Algorithm:
1. Dequeue SearchNode X from queue
2. For every nth neighbor of X:
a. Create SearchNode N
i. state=neighbor, action=n, parent=X
b. If N is goal → return path
c. Else if N is already explored → pass
d. Else → queue N
● Implementation using SM: StateSpaceSearch
○ State: Node
○ Input: Neighbor #
○ Output: Next node
Source: DDW notes
4. BFS
● StateSpaceSearch
○ State: Node
○ Input: Neighbor #
○ Output: Next node
4. BFS
● Implementation details:
○ Class Queue
○ Abstract class StateSpaceSearch inherits from StateMachine
○ Class MapSM inherits from StateSpaceSearch:
■ 2 attributes: state, start_state
■ 4 methods: start(), get_next_values(), step(), tranduce()
■ 2 properties: statemap, legal_inputs
○ Class Step:
■ 2 attributes: state, action
○ Class SearchNode:
■ 3 attributes: state, action, parent
■ 2 methods: path(), in_path()
○ Function sm_search()
Q&A
Go to slido.com
#ddwclinic3

More Related Content

Similar to DDW Clinic 3: State Machine

form 4 Functions and procedures.pptx
form 4 Functions and procedures.pptxform 4 Functions and procedures.pptx
form 4 Functions and procedures.pptx
ItsJustMe11
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
Võ Hòa
 
Moore and mealy machine
Moore and mealy machineMoore and mealy machine
Moore and mealy machine
Mian Munib
 
lecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.pptlecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.ppt
ssuser2ae35a
 
Algorithms.pdf
Algorithms.pdfAlgorithms.pdf
Algorithms.pdf
OluwafolakeOjo
 
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptxmodule 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
Maaz609108
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
DAC CCAT GUESS PAPER Jun-Jul 2013
DAC CCAT GUESS PAPER Jun-Jul 2013 DAC CCAT GUESS PAPER Jun-Jul 2013
DAC CCAT GUESS PAPER Jun-Jul 2013
prabhatjon
 
project_NathanWendt
project_NathanWendtproject_NathanWendt
project_NathanWendt
Nathan Wendt
 
k10790 nilesh prajapati control me 6th sem
k10790 nilesh prajapati control me 6th semk10790 nilesh prajapati control me 6th sem
k10790 nilesh prajapati control me 6th sem
harshprajapati12
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
MANDHASAIGOUD1
 
Esd module2
Esd module2Esd module2
Esd module2
SOURAV KUMAR
 
Chapter 7_0.pptx
Chapter 7_0.pptxChapter 7_0.pptx
Chapter 7_0.pptx
VishnuPriyan10798
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
Vivek Singh
 
Digital-Unit-III.ppt
Digital-Unit-III.pptDigital-Unit-III.ppt
Digital-Unit-III.ppt
VijayalakshmiV16
 
Programming Class Contest
Programming Class ContestProgramming Class Contest
Programming Class Contest
Toni Santos
 
Java 8 - functional features
Java 8 - functional featuresJava 8 - functional features
Java 8 - functional features
Rafal Rybacki
 
Relational Operators in C
Relational Operators in CRelational Operators in C
Relational Operators in C
Lakshmi Sarvani Videla
 
Design System Design-ASM and Asynchronous Sequential Circuits
Design System Design-ASM and Asynchronous Sequential CircuitsDesign System Design-ASM and Asynchronous Sequential Circuits
Design System Design-ASM and Asynchronous Sequential Circuits
Indira Priyadarshini
 
Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated Disassembly
Priyanka Aash
 

Similar to DDW Clinic 3: State Machine (20)

form 4 Functions and procedures.pptx
form 4 Functions and procedures.pptxform 4 Functions and procedures.pptx
form 4 Functions and procedures.pptx
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 
Moore and mealy machine
Moore and mealy machineMoore and mealy machine
Moore and mealy machine
 
lecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.pptlecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.ppt
 
Algorithms.pdf
Algorithms.pdfAlgorithms.pdf
Algorithms.pdf
 
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptxmodule 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
DAC CCAT GUESS PAPER Jun-Jul 2013
DAC CCAT GUESS PAPER Jun-Jul 2013 DAC CCAT GUESS PAPER Jun-Jul 2013
DAC CCAT GUESS PAPER Jun-Jul 2013
 
project_NathanWendt
project_NathanWendtproject_NathanWendt
project_NathanWendt
 
k10790 nilesh prajapati control me 6th sem
k10790 nilesh prajapati control me 6th semk10790 nilesh prajapati control me 6th sem
k10790 nilesh prajapati control me 6th sem
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
 
Esd module2
Esd module2Esd module2
Esd module2
 
Chapter 7_0.pptx
Chapter 7_0.pptxChapter 7_0.pptx
Chapter 7_0.pptx
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
Digital-Unit-III.ppt
Digital-Unit-III.pptDigital-Unit-III.ppt
Digital-Unit-III.ppt
 
Programming Class Contest
Programming Class ContestProgramming Class Contest
Programming Class Contest
 
Java 8 - functional features
Java 8 - functional featuresJava 8 - functional features
Java 8 - functional features
 
Relational Operators in C
Relational Operators in CRelational Operators in C
Relational Operators in C
 
Design System Design-ASM and Asynchronous Sequential Circuits
Design System Design-ASM and Asynchronous Sequential CircuitsDesign System Design-ASM and Asynchronous Sequential Circuits
Design System Design-ASM and Asynchronous Sequential Circuits
 
Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated Disassembly
 

Recently uploaded

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 

Recently uploaded (20)

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 

DDW Clinic 3: State Machine

  • 1. DDW Clinic Session 3 State Machine
  • 2. Outline 1. What is a state machine? 2. How to construct a state diagram 3. Abstract state machine class 4. BFS
  • 3. 1. What is a state machine? ● A computation machine where the output is a function of the current input AND all the previous inputs ●
  • 5. 2. How to construct a state transition diagram Template Sample diagram ● Contains: State, Input, Output ○ Output may or may not be the next state
  • 6. 3. Abstract state machine class ● Points to note: ○ Inherits from abc.ABC (python module for abstract base class) ○ 2 attributes: ■ self.start_state ■ self.state ○ 4 methods: ■ self.start() ■ self.get_next_values(state, inp) → next_state, output ■ self.step(inp) ■ self.tranduce() → output[]
  • 10. 4. BFS ● Explores all neighboring vertices before going in depth (1) (2) Source: DDW notes
  • 11. 4. BFS ● Problem: Find shortest path from S to H ● Algorithm: 1. Dequeue SearchNode X from queue 2. For every nth neighbor of X: a. Create SearchNode N i. state=neighbor, action=n, parent=X b. If N is goal → return path c. Else if N is already explored → pass d. Else → queue N ● Implementation using SM: StateSpaceSearch ○ State: Node ○ Input: Neighbor # ○ Output: Next node Source: DDW notes
  • 12. 4. BFS ● StateSpaceSearch ○ State: Node ○ Input: Neighbor # ○ Output: Next node
  • 13. 4. BFS ● Implementation details: ○ Class Queue ○ Abstract class StateSpaceSearch inherits from StateMachine ○ Class MapSM inherits from StateSpaceSearch: ■ 2 attributes: state, start_state ■ 4 methods: start(), get_next_values(), step(), tranduce() ■ 2 properties: statemap, legal_inputs ○ Class Step: ■ 2 attributes: state, action ○ Class SearchNode: ■ 3 attributes: state, action, parent ■ 2 methods: path(), in_path() ○ Function sm_search()