Behavior Modeling
Summary
Structural vs Behavioral
Structural models express properties that are always true.
Behavioral models express how the system responds to external stimuli.
States
State := abstract description of a system at a given time
State Space := set of all possible states
State space increases multiplicatively
- “State Explosion Problem”
TicTacToe has 19683 states
Events
Event := a single, instantaneous, noticeable occurrence
Events can be sync or async
- Clock-based or random
UML Event Taxonomy
- Signal
- Async notifications
- Method Call
- Sync operation invocation
- State Change
- Continuously monitored
- Time Passage
Behavioral Modeling
Reactive Systems := systems that respond to events
Modeling Techniques:
- Combinatorial
- States, but no events
- Sequential
- States, linearly ordered events
- Concurrent
- States, unconstrained events
Combinatorial Modeling
Expresses logic of simple combinatorial systems
Only inputs determine subsequent states, and not the history of events
Decision Tables
Conditions are called inputs, responses are called outputs
Workshop has 3 switches, 2 output devices and 1 master switch. Switches can either be on or off.
Master | Light Switch | Power Switch | Lights | Motor |
---|---|---|---|---|
ON | ON | ON | ON | ON |
ON | ON | OFF | ON | OFF |
Decision Tree
Graphical form of decision table where decisions are made sequentially
Diamonds are decisions, rectangles are actions
flowchart TD M{Master Controller On} M –>|No| oo[Light Off / Motor Off] M –>|Yes| lso{Light Switch On?} lso –>|No| loffp{Power Switch On?} lso –>|Yes| lonp{Power Switch On?} loffp –>|No| loffpoff[Light Off / Motor Off] loffp –>|Yes| loffpon[Light Off / Motor On] lonp –>|No| lonpoff[Light On / Motor Off] lonp –>|Yes| lonpon[Light On/ Motor On]
Sequential Systems
Sequential systems have “memory” of previous system activities
Also called “Finite State Systems” or “Finite State Machines”
State Transition Table
Rows are states
Columns are:
- name
- input event
- output action
- next state
Current state | Input | Action | Next State |
---|---|---|---|
Door closed, motor off | Button pressed | Start motor | Motor running up |
Motor running up | Door open detected | Stop motor | Door open, motor off |
Motor running up | Button pressed | Stop motor | Door partially open, motor off |
Door partially open, motor off | Button pressed | Start motor | Motor running down |
Door open, motor off | Button pressed | Start motor | Motor running down |
Motor running down | Door closed detected | Stop motor | Door closed, motor off |
Motor running down | Button pressed | Stop motor | Door partially closed, motor off |
Door partially closed, motor off | Button pressed | Start motor | Motor running up |
State Transition Diagram
Graphical representation of FSM
etc.