ASE Report Format Model (1)
ASE Report Format Model (1)
K S INSTITUTE OF TECHNOLOGY
# 14, Raghuvanahalli, Kanakapura Main Road,
Bangalore– 560109
Pedagogy report on
“BELLMANFORD ALGORITHM”
2024-2025(ODD-SEM)
SUBJECT: AUTOMATA THEORY AND COMPILER DESIGN (21CS51)
SUBJECT TEACHER
ABSTRACT
This report presents the design and implementation of a The Bellman-Ford algorithm is a
fundamental graph traversal algorithm used to compute the shortest paths from a single source
vertex to all other vertices in a weighted graph. Unlike Dijkstra’s algorithm, which is limited to
graphs with non-negative weights, Bellman-Ford can handle graphs containing negative weight
edges and detect negative weight cycles. The algorithm operates by repeatedly relaxing all edges,
meaning it updates the shortest known distance to each vertex based on the edge weights. This
process is repeated (V - 1) times, where V is the number of vertices, ensuring that the shortest
path is found in at most (V - 1) iterations. If an additional iteration still results in a shorter path, it
indicates the presence of a negative weight cycle, which implies that there is no well-defined
shortest path because the path weight can decrease indefinitely.
The time complexity of Bellman-Ford is O(VE), where V is the number of vertices and E is the
number of edges, making it slower than Dijkstra’s algorithm, which runs in O((V + E) log V)
with a priority queue. However, Bellman-Ford remains useful in cases where negative weight
edges exist, such as financial modeling, network routing (e.g., Distance Vector Routing
Protocol), and constraint satisfaction problems. The algorithm is particularly useful in distributed
networks, where it helps detect inconsistencies in routing tables and prevents routing loops.
Despite its higher time complexity, its ability to handle a wider range of graph types makes it a
crucial tool in graph theory and real-world applications. Relaxation Process – The algorithm
iterates (V - 1) times, where each iteration attempts to relax all edges by updating the shortest
path estimates.
Negative Weight Cycle Detection – If an edge can still be relaxed after V - 1 iterations, a
negative weight cycle exists, indicating that the shortest path cannot be determined.
Comparison with Dijkstra’s Algorithm – Bellman-Ford is slower than Dijkstra’s algorithm but is
more powerful because it handles negative weight edges, whereas Dijkstra fails in such cases.
Time Complexity – It runs in O(VE) time, making it inefficient for large graphs but useful for
graphs with fewer edges and the presence of negative weights. Space Complexity – The
algorithm requires O(V) space for storing distance values and predecessor information. t is
widely used in network routing protocols (e.g., RIP – Routing Information Protocol), currency
arbitrage detection, and constraint satisfaction problems.
PAGE: 2
BELLMAN FORD ALGORITHM
CONTENTS
1 INTRODUCTION 5,6
2 GOALS 7
3 APPLICATIONS 8-20
4 PRESENTATION SLIDES 21-29
5 PRESENTATION IMAGES 30-32
6 CONCLUSION 33
7 REFERENCES 35
PAGE: 3
BELLMAN FORD ALGORITHM
INTRODUCTION
BELLMAN FORD ALGORITHM
Introduction to the Bellman-Ford Algorithm
The Bellman-Ford algorithm is a graph-based algorithm used to find the shortest path from a
single source vertex to all other vertices in a weighted graph. Unlike Dijkstra’s algorithm,
Bellman-Ford can handle negative weight edges, making it more versatile for real-world
applications.
It works by relaxing edges repeatedly and updating the shortest path estimates. If an edge weight
keeps decreasing after (V-1) iterations, the algorithm detects a negative weight cycle, indicating
that no shortest path exists.
Despite being slower than Dijkstra’s algorithm, Bellman-Ford is crucial in network routing,
financial modeling, and traffic systems where negative weights occur.
locks, which require the input of a sequence of numbers in the proper order.
PAGE: 4
BELLMAN FORD ALGORITHM
Key Features:
Works on directed and undirected graphs.
Handles negative weight edges (unlike Dijkstra’s algorithm).
Detects negative weight cycles (if a shorter path is found after |V|-1 iterations, a cycle exists).
Has a time complexity of O(V × E), where V is the number of vertices and E is the number of
edges.
Algorithm Steps:
1. Initialize distances: Set the distance from the source to all vertices as infinity (∞) except for the
source, which is 0.
2. Relax edges repeatedly: For (V-1) iterations, update the shortest path estimates for each edge.
3. Check for negative cycles: If the distance reduces further in the V-th iteration, a negative cycle
exists.
Real-World Applications:
Network routing (detecting delays in packet transmission).
Currency arbitrage (detecting profit opportunities with negative cycles).
Traffic navigation systems (handling different road weights like tolls, distance, etc.).
any input is called the start state. Some of the states are accepting or final.
Below is a table that describes the transition function of a finite-state automaton with states p, q,
and r, on inputs 0 and 1.
Works on Directed and Undirected Graphs – Though mainly used for directed graphs, it can
also work on undirected graphs by converting them into directed edges.
Time Complexity – Runs in O (V * E) time, making it slower than Dijkstra for large graphs
but useful in cases where negative weights exist.
Dynamic Programming Approach – Uses a bottom-up strategy to progressively refine the
shortest path estimates.
1. Does Not Require Priority Queue – Unlike Dijkstra, it doesn’t use a priority queue, making
it easier to implement. Handles Negative Weights – Unlike Dijkstra’s algorithm, Bellman-Ford
can handle graphs with negative weight edges.
2. Detects Negative Cycles – It can identify if there is a negative weight cycle in the graph, which
makes shortest path computation impossible.
3. Iterative Relaxation – Relaxes all edges (V - 1) times to ensure the shortest path calculations
converge.
PAGE: 5
BELLMAN FORD ALGORITHM
GOALS
Find the Shortest Path – Compute the shortest path from a single source node to all other nodes
in a weighted graph.
Detect Negative Weight Cycles – Identify cycles where the total weight is negative, which can
cause infinite loops in shortest path calculations.
Ensure Accuracy – By iterating over all edges multiple times, the algorithm guarantees the
shortest path calculation is correct.
Provide an Alternative to Dijkstra – Used in scenarios where Dijkstra’s algorithm fails due to
the presence of negative weight edges.
Versatile for Network Routing – Applied in networking (e.g., Distance Vector Routing) to
determine the most efficient data transmission path.
Adaptability to Dynamic Graphs – Can be used in scenarios where edge weights change over
time, such as real-time traffic systems.
Foundation for Advanced Algorithms – Forms the basis for other algorithms, like the Floyd-
Warshall algorithm for all-pairs shortest paths.
Used in Economic and Financial Models – Helps analyze cost optimization problems, such as
supply chain logistics and financial risk assessment.
Supports Negative Weights – Unlike Dijkstra’s algorithm, Bellman-Ford can handle graphs with
negative weight edges, making it useful for certain financial and network flow applications.
PAGE: 6
BELLMAN FORD ALGORITHM
Traffic Flow Analysis – Helps in finding the shortest or least congested path in road
networks.
PAGE: 7
BELLMAN FORD ALGORITHM
PAGE: 8
BELLMAN FORD ALGORITHM
SYSTEM DESIGN
The system design of the Bellman-Ford algorithm involves structuring its components to
efficiently compute the shortest path in a graph. Here’s a high-level design breakdown:
WORKING
PAGE: 10
BELLMAN FORD ALGORITHM
- Use: Adjusts water levels and washing parameters based on the size of the load,
optimizing efficiency.
2. Emergency Stop Button (optional):
- Input: User-activated button for emergency stops.
- Use: Triggers an emergency transition to a safe state when pressed.
These inputs and sensors collectively contribute to the intelligence of the washing machine FSM,
ensuring that the machine progresses through the states of the washing cycle in a controlled and
efficient manner.
OUTPUTS
In a washing machine Finite State Machine (FSM), outputs are actions or control signals that
result from the transitions between states. These outputs are responsible for controlling various
components within the washing machine. Here are common outputs associated with a washing
machine FSM:
1. Water Inlet Valve Control:
- Output: Open/Close signal to control the water inlet valve.
- Use: Opens the valve to let water into the machine during the Water Filling state.
2. Motor Control:
- Output: Control signals to the motor for agitating and spinning.
- Use: Activates the motor to agitate the clothes during the Washing state and spin them during
the Spinning state.
3. Pump Control:
- Output: Control signals to the pump for draining water.
- Use: Activates the pump to drain water during the Draining state.
4. Heating Element Control (optional):
- Output: Control signals to the heating element.
- Use: Activates the heating element to adjust water temperature based on the selected program.
5. Indicator Lights/Display:
- Output: Illumination or display messages.
- Use: Informs the user about the current state of the washing machine (e.g., Power On, Cycle
Complete).
PAGE: 11
BELLMAN FORD ALGORITHM
6. Buzzer/Alarm (optional):
- Output: Audible signal.
- Use: Alerts the user in case of errors or when the washing cycle is complete.
7. Locking Mechanism Control (optional):
- Output: Signals to control the door locking mechanism.
- Use: Locks and unlocks the door based on the state of the washing machine.
8. Detergent and Softener Dispenser Control (optional):
- Output: Signals to control dispensers.
- Use: Releases detergent and fabric softener at appropriate stages during the washing cycle.
9. Vibration Control (optional):
- Output: Adjustments to minimize vibrations.
- Use: Controls components to minimize vibrations during spinning, ensuring stability.
10. Emergency Stop Signal (optional):
- Output: Signals to halt all operations.
- Use: In response to an emergency stop input, safely stops all machine functions.
These outputs collectively ensure that the washing machine performs the necessary actions at each
state of the washing cycle, providing a seamless and controlled operation. The combination of
inputs and outputs creates an intelligent system that responds to user inputs and environmental
conditions during the laundry process.
PAGE: 12
BELLMAN FORD ALGORITHM
Fig 15: Skeletal Structure of Spartan 6 FPGA Board indicating output LEDs
PAGE: 13
BELLMAN FORD ALGORITHM
PAGE: 14
BELLMAN FORD ALGORITHM
- The modular structure of FSA allows for a clear representation of different states and
transitions, making it easier to design, understand, and modify the washing machine's control
logic.
3. Easy Maintenance and Debugging:
- The structured nature of FSA simplifies maintenance and debugging processes. Any issues
related to the washing machine's behavior can be traced back to specific states and transitions.
4. User-Friendly Interface:
- FSA facilitates the design of user-friendly interfaces. Users can easily understand and interact
with the washing machine, selecting programs and monitoring the progress through intuitive
controls and indicators.
5. Consistent and Repeatable Operation:
- FSA ensures that the washing machine performs consistently in each cycle, leading to
repeatable and reliable results. This consistency is crucial for achieving optimal cleaning
performance.
6. Efficient Resource Utilization:
- FSA allows for efficient utilization of resources such as water, detergent, and energy by
controlling their distribution and consumption based on the selected washing program and cycle
phase.
7. Adaptability to Different Programs:
- Washing machines with FSA can easily accommodate various washing programs (e.g.,
delicate, normal, heavy-duty). The finite states can represent different program modes, making
the washing machine adaptable to different laundry needs.
8. Energy and Water Conservation:
- FSA enables the washing machine to optimize energy and water consumption by
transitioning to the next phase only when necessary. For example, it ensures that the machine
moves to the rinsing phase after an appropriate washing time.
9. Error Handling and Recovery:
- FSA allows for the incorporation of error-handling states, providing the washing machine
with the capability to detect faults or anomalies and take appropriate actions, such as pausing
the cycle or displaying error messages.
10. Enhanced Safety Features:
PAGE: 15
BELLMAN FORD ALGORITHM
- FSA facilitates the implementation of safety features, such as door locking mechanisms and
emergency stops, ensuring the safety of users and preventing accidents during operation.
In summary, Finite State Automata play a crucial role in enhancing the overall performance of
washing machines by providing a structured and efficient control mechanism. This leads to
improved user experience, consistent results, and the ability to adapt to various washing
requirements.
PAGE: 16
BELLMAN FORD ALGORITHM
This finite state machine diagram explains the various conditions of a turnstile.
PAGE: 17
BELLMAN FORD ALGORITHM
DETERMINISTIC FSA
Formally, a deterministic finite-state automata M is specified by 5
components: M=(Q,Σ, δ, S,A) where
• Q is a finite set of states.
• Σ is an alphabet called the input alphabet.
• δ transition function.
• S is the starting state.
• A is the final state or accept state.
L(M) = {x∈{0,1}*|n1(x)≥2}
4
PAGE: 18
BELLMAN FORD ALGORITHM
APPLICATIONS
1. Elevator Control Systems
2. Traffic Light Control
3. Vending Machines
4. Digital Circuit Design
5. Door Lock Systems
6.Communication Protocols
7.Digital Audio
Players 8.Robotics
9.Washing Machines
10.Game AI
5
WASHING MACHINE
PAGE: 19
BELLMAN FORD ALGORITHM
SYSTEM DESIGN
Washing Machine Controller Functionalities:
1. The wash machine has the following states: idle, soak, wash, rinse, spin.
2. There are three modes of operation mode1, mode2 and mode3.
3. Different time durations are allocated to each mode of operation.
• The controller is composed of two blocks: a finite - sate machine (FSM) block
and a timer block.
• FSM block output control the timer block and other hardware components of
the washing machine.
• The timer block generates the correct time periods required for each cycle after
it has been reset. The timer block has an up- counter and combinational logic.
PAGE: 20
BELLMAN FORD ALGORITHM
WORKING
DFA
10
PAGE: 21
BELLMAN FORD ALGORITHM
11
OUTPUTS
• Water Inlet Valve Control
• Motor Control
• Pump Control
• Heating Element Control (optional)
• Indicator Lights/Display
• Buzzer/Alarm (optional)
• Locking Mechanism Control (optional)
• Detergent and Softener Dispenser Control (optional)
• Vibration Control (optional)
• Emergency Stop Signal (optional)
12
PAGE: 22
BELLMAN FORD ALGORITHM
13
RESULTS
14
PAGE: 23
BELLMAN FORD ALGORITHM
15
ADVANTAGES OF FSM IN
WASHING MACHINES
• Sequential Control
• Modularity and Clarity
• Easy Maintenance and Debugging
• User-Friendly Interface
• Consistent and Repeatable Operation
• Efficient Resource Utilization
• Adaptability to Different Programs
• Energy and Water Conservation
• Error Handling and Recovery
• Enhanced Safety Features
16
PAGE: 24
BELLMAN FORD ALGORITHM
17
THANK YOU
18
PAGE: 25
BELLMAN FORD ALGORITHM
PAGE: 26
BELLMAN FORD ALGORITHM
PAGE: 27
BELLMAN FORD ALGORITHM
PAGE: 28
BELLMAN FORD ALGORITHM
CONCLUSION
The FSM designed has 6 states which perform different operations of a washing machine. The
digital design of washing machine control system using Verilog HDL reduces the development
cycle time.
In future, the number of states of the FSM can be increased for additional operations if required.
Actuators like DC motor, stepper motor and solenoid valves can be interfaced with the FPGA to
realize the real time operation and functioning of the washing machine control system.
PAGE: 29
BELLMAN FORD ALGORITHM
ROLE MEMBERS
INTRODUCTION RAVEESH PRASAD M
APPLICATIONS OF FINITE AUTOMATA YASHAS D GOWDA
SYSTEM DESIGN OF WASHING
YASHAS D GOWDA
MACHINE
WORKING REDDY TEJASWINI A
DFA OF WASHING MACHINE REDDY TEJASWINI A
CONTROL AND SENSORS SHEETAL NAIK
INPUT AND OUTPUT SHEETAL NAIK
RESULTS UJWAL M L
ADVANTAGES AND DISADVANTAGES
OF USING FSM IN WASHING UJWAL M L
MACHINES
CONCLUSION UJWAL M L
PAGE: 30
BELLMAN FORD ALGORITHM
REFERENCES
1. https://www.researchgate.net/publication/353332391_An_Implementation_of_Automat
ic_Washing_Machine_Control_System_Using_Verilog_HDL
2. https://www.elprocus.com/finite-state-machine-mealy-state-machine-and-moore-state-
machine/
3. https://en.wikipedia.org/wiki/Finite-state_machine
4. https://www.engati.com/glossary/finite-automata
5. https://www.geeksforgeeks.org/introduction-of-finite-automata/
PAGE: 31