0% found this document useful (0 votes)
2 views

ASE Report Format Model (1)

The document provides a detailed report on the Bellman-Ford algorithm, a graph traversal method used to find the shortest paths from a single source vertex in a weighted graph, capable of handling negative weight edges and detecting negative cycles. It outlines the algorithm's steps, time complexity, applications in various fields such as network routing and financial modeling, and compares it with Dijkstra's algorithm. The report also includes sections on goals, system design, and advantages of using finite state machines in related applications.

Uploaded by

csraghavi6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

ASE Report Format Model (1)

The document provides a detailed report on the Bellman-Ford algorithm, a graph traversal method used to find the shortest paths from a single source vertex in a weighted graph, capable of handling negative weight edges and detecting negative cycles. It outlines the algorithm's steps, time complexity, applications in various fields such as network routing and financial modeling, and compares it with Dijkstra's algorithm. The report also includes sections on goals, system design, and advantages of using finite state machines in related applications.

Uploaded by

csraghavi6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

ATC Pedagogy

K S INSTITUTE OF TECHNOLOGY
# 14, Raghuvanahalli, Kanakapura Main Road,
Bangalore– 560109

Department of Computer Science & Engineering

Pedagogy report on

“BELLMANFORD ALGORITHM”

2024-2025(ODD-SEM)
SUBJECT: AUTOMATA THEORY AND COMPILER DESIGN (21CS51)
SUBJECT TEACHER

Dr. Vijayalakshmi Mekali


Prepared By:
RAGHAVI CS
SEM:1

PREPARED BY: TEAM 1 Page 1


BELLMAN FORD ALGORITHM

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

SL NO. TITLE PAGE NO

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.

Fig. 1 – Bellman ford images

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.

 Handle Negative Weights – Unlike Dijkstra’s algorithm, Bellman-Ford efficiently processes


graphs containing negative weight edges.

 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.

 Optimize Computational Efficiency – Although slower than Dijkstra, Bellman-Ford is useful


in specific applications where correctness is prioritized over speed.

 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.

  Network Routing Applications – Used in distance-vector routing protocols like RIP


(Routing Information Protocol) to determine the best paths in computer networks.

PAGE: 6
BELLMAN FORD ALGORITHM

SOME APPLICATIONS OF BELLMAN FORD ALGORITHM


  Network Routing Protocols – Used in distance-vector routing protocols like RIP
(Routing Information Protocol) to determine optimal paths in computer networks.

  Traffic Flow Analysis – Helps in finding the shortest or least congested path in road
networks.

 Financial Models – Used for arbitrage detection in currency exchange by identifying


negative weight cycles.

 Telecommunications – Helps in optimizing data packet transmission routes in large


networks.

 Robotics and AI – Used in pathfinding algorithms for autonomous navigation systems.


Traffic Light Control: Traffic lights follow a finite set of states (Red, Green, Yellow)
with transitions triggered by timers and vehicle or pedestrian sensors. The system ensures
a smooth flow of traffic through predefined states.

Fig. 5 – Bellman ford navigation

PAGE: 7
BELLMAN FORD ALGORITHM

Fig. 6 –Routing internal connection


 Digital Circuit Design: Finite state machines are used to model the behavior of digital
circuits. States represent different conditions of the circuit, and transitions occur based
on input signals and timing.
 Door Lock Systems: Door lock systems have states like Locked, Unlocked, and Error.
Transitions are triggered by user actions (inputting a correct code, turning a key) and
sensorinputs(doorpsition).

Fig .7 – Weighted graph representation

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:

1. Input & Graph Representation


 Nodes (Vertices): Represent entities in the graph (e.g., cities, routers).
 Edges (Weighted Connections): Represent the cost/distance between nodes.
 Graph Representation: Stored as an Adjacency List or Edge List.
2. Core Components
 Initialization Module:
o Set distances to all vertices as infinity (∞) except the source (set to 0).
o Store predecessors for path reconstruction.
 Relaxation Module:
o Iterate (V - 1) times, updating distances if a shorter path is found via an edge.
 Negative Cycle Detection Module:
o Run one more iteration; if distance updates still occur, a negative weight cycle exists.
3. Data Structures
 Array/HashMap to store distances.
 List/Dictionary to store graph edges.
 Queue (Optional) for cycle detection in optimized versions.
4. Execution Flow
1. Graph Input → Load vertices and edges.
2. Initialization → Set up distance table.
3. Edge Relaxation → Iterate and update shortest paths.
4. Cycle Detection → Check for negative cycles.
5. Output Results → Print shortest distances or detect cycle presence.
5. Optimizations & Enhancements
 Early Stopping: If no distance update in an iteration, terminate early.
 Queue-Based Approach: Faster cycle detection using Bellman-Ford with BFS.
 Parallel Processing: Can optimize relaxation using multi-threading.
PAGE: 9
BELLMAN FORD ALGORITHM

WORKING

Fig. 13&14– State Transition diagram of graph

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.

Fig 14: Xilinx generated Technology Schematic

PAGE: 12
BELLMAN FORD ALGORITHM

Fig 15: Skeletal Structure of Spartan 6 FPGA Board indicating output LEDs

Fig 16: State Assignment to Output LEDs

PAGE: 13
BELLMAN FORD ALGORITHM

Fig 17: Results


ADVANTAGES OF FSM IN WASHING MACHINES
The use of Finite State Automata (FSA) in washing machines offers several advantages that
contribute to the efficiency, reliability, and user-friendliness of the washing process. Here are
some key advantages:
1. Sequential Control:
- FSA provides a systematic and sequential control of the washing machine's operation,
ensuring that each phase of the washing cycle occurs in the correct order.
2. Modularity and Clarity:

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.

DISADVANTAGES OF FSM IN WASHING MACHINES


1. The expected character of deterministic finite state machines cannot be needed in some
areas like computer games.
2. The implementation of huge systems using FSM is hard for managing without any idea
of design.
3. Not applicable for all designs.
4. The orders of state conversion are inflexible.
5. Complexity: FSMs can become complex and difficult to manage as the number of states
and transitions increases.

PAGE: 16
BELLMAN FORD ALGORITHM

DEPARTMENT OF COMPUTER SCIENCE


AND ENGINEERING
AUTOMATA THEORY AND COMPILER
DESIGN (21CS51)
TOPIC: APPLICATIONS OF FINITE AUTOMATA IN
WASHING MACHINE
PRESENTED BY: GUIDED BY:
RAVEESH PRASAD M : 1KS21CS080 DR. SUNITA CHALAGERI

REDDY TEJASWINI A : 1KS21CS082 ASSOCIATE PROFESSOR,

SHEETAL NAIK : 1KS21CS089 K.S INSTITUTE OF TECHNOLOGY

UJWAL M. L. : 1KS21CS107 KANAKAPURA ROAD, BANGALORE

YASHAS D GOWDA : 1KS21CS117

FINITE STATE AUTOMATA

A finite-state machine (FSM) or finite-state automaton (plural: automata), or simply


a state machine, is a mathematical model of computation used to design
both computer programs and sequential logic circuits.

This finite state machine diagram explains the various conditions of a turnstile.

PAGE: 17
BELLMAN FORD ALGORITHM

FINITE STATE AUTOMATA

• A finite-state automata (FSA), is a machine which takes, as


input, a finite string of symbols from some alphabet ‘Σ'.
• The state it is in before consuming 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.

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.

strings w ∈ Σ* that are accepted by M:L(M)={w∈Σ*|δ*(q0,w)∈F}.


The language accepted by M, denoted L(M), is the set of all

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

SENSORS AND INPUTS


• Door Sensor
• Program Selection Input
• Water Level Sensor
• Timer/Duration Input
• Detergent and Softener Input
• Temperature Sensor
• Motor Speed Sensor
• Weight Sensor (optional)
• Emergency Stop Button (optional)

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

Table: State Assignments to Output

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

DISADVANTAGES OF FSM IN WASHING


MACHINE

• The expected character of deterministic finite state machines


cannot be needed in some areas like computer games.
• The implementation of huge systems using FSM is hard for
managing without any idea of design.
• Not applicable for all designs.
• The orders of state conversion are inflexible.
• Complexity: FSMs can become complex and difficult to manage
as the number of states and transitions increases.

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

TEAM MEMBERS ROLES

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

You might also like