SlideShare a Scribd company logo
1 of 14
Download to read offline
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

lecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.pptlecture25_algorithmic_state_machines.ppt
lecture25_algorithmic_state_machines.ppt
ssuser2ae35a
 
project_NathanWendt
project_NathanWendtproject_NathanWendt
project_NathanWendt
Nathan Wendt
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
Vivek Singh
 
Programming Class Contest
Programming Class ContestProgramming Class Contest
Programming Class Contest
Toni Santos
 
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
 
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
 
9920Lec12 FSM.ppt
9920Lec12 FSM.ppt9920Lec12 FSM.ppt
9920Lec12 FSM.ppt
 

Recently uploaded

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
Muhammad Subhan
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
Wonjun Hwang
 

Recently uploaded (20)

Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 

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()