Automata (1)
Automata (1)
Submitted by
Vidyasagar R 4VV22IS117
Yashwanth N 4VV22IS126
Dr.Ravi kumar V
Head Of The Department
Department of ISE
The Traffic Light System can be effectively modeled using a Deterministic Finite
Automaton (DFA). The system consists of a finite set of states (Red, Green, Yellow) with
deterministic transitions based on time intervals. Additionally, a Fault State is introduced
to represent scenarios where the traffic light system encounters an error or failure.
Objective:
The purpose of this project is to implement a traffic light system using a DFA to model
the states and transitions. This report will cover the design, implementation, and analysis
of the system, including handling faults.
Finite State Machine (FSM):
Definition:
A Finite State Machine (FSM) is a computational model used to design algorithms and
systems that can be in one of a limited number of states at any given time. The system
transitions from one state to another based on inputs or conditions.
Types of FSM:
Applications of FSM:
FSMs are used in various systems such as traffic light control, vending machines,
protocol design, and even games where events trigger state transitions
Deterministic Finite Automaton (DFA):
Definition:
Components of DFA:
Example of DFA:
For the Traffic Light System, the DFA defines the set of states (Red, Green, Yellow) and
the transitions that occur after fixed time intervals.
Traffic Light System Design:
States:
Fault:
A state representing a malfunction or error in the system. When the system encounters a
fault, no transitions occur until the system is reset or fixed.
State Transitions:
The system transitions between states based on time, but if a Fault occurs, the system
enters a state where no further transitions are possible unless corrected.
Normal Transitions:
Fault Transitions:
DFA Model:
This system remains deterministic, as every state has one transition based on
either the timer or a fault condition. If the system is working normally, the
transitions occur in the usual cycle. If a fault occurs, the system moves to the
Fault state and remains there until the error is fixed.
Transition diagram:
Code:
public class TrafficLightFSM {
enum State {
RED, YELLOW, GREEN, FAULT
}
public TrafficLightFSM() {
currentState = State.RED;
}
if (currentState != State.FAULT) {
transition();
} else {
break;
}
}
}
• Deterministic Nature:
The traffic light system behaves deterministically, where each state has one
well-defined next state. For example, after 5 seconds in the Red state, it always
transitions to Green.
• Fault Handling:
The introduction of the Fault state ensures that when a malfunction occurs, the
system will enter a state where no transitions can take place, effectively halting
the traffic light cycle until the system is manually reset or repaired.
• No Ambiguity:
Given the current state and the input (timer or fault condition), the system will
always know exactly what the next state is.
• Cyclic Behavior:
Under normal conditions, the system follows a cyclic pattern: Red → Green
→ Yellow → Red. When the system enters the Fault state, it stops the cycle
until the error is addressed.
1. Real-World Applications:
The Fault state in this DFA is highly relevant in real-world traffic light systems,
where malfunctions or maintenance issues can stop the system from functioning
normally. Such systems may need a manual reset or an alert to technicians.
2. Autonomous Vehicles:
Autonomous vehicles must be able to recognize the state of traffic lights,
including fault signals. For example, if a traffic light is malfunctioning and
stuck in the Fault state, the vehicle needs to handle the situation appropriately
(e.g., treat the intersection as an all-stop or all-go).
3. Scalability:
The DFA model can be extended by adding more states, such as Pedestrian
Crossing, or introducing more complex conditions for state transitions (e.g.,
varying light durations based on traffic flow).
Conclusion:
• The addition of a Fault state provides a robust way to handle errors in the system,
preventing unpredictable behavior during malfunctions.