A Genetic Algorithm is an optimization and search technique based on the principles of natural selection and genetics. It is inspired by the process of evolution, where the fittest individuals are selected for reproduction to produce the next generation.
Genetic Algorithms work through the following steps:
- Initialization – Generate an initial population of possible solutions (chromosomes).
- Evaluation – Assess the fitness of each chromosome using a fitness function.
- Selection – Choose the best individuals for reproduction (e.g., roulette wheel selection, tournament selection).
- Crossover (Recombination) – Combine two parent chromosomes to create offspring.
- Mutation – Introduce small changes in the offspring to maintain diversity.
- Replacement – Replace the old population with new individuals.
- Termination – Stop when a stopping condition is met (e.g., a good enough solution is found).
Let's say we are trying to maximize the function:
[
f(x) = x^2
]
where ( x ) is a binary string of length 4.
-
Initial Population (Randomly Generated):
Chromosome Decimal (x) f(x) = x² 1010 10 100 1100 12 144 0110 6 36 0011 3 9 -
Selection: Choose the best two based on fitness: 1100 (144) and 1010 (100).
-
Crossover (Single-point at middle):
- Parent 1: 1100
- Parent 2: 1010
- Offspring: 1110, 1000
-
Mutation: Randomly flip a bit (e.g., 1000 → 1001).
-
New Generation:
Chromosome Decimal (x) f(x) = x² 1110 14 196 1001 9 81 The process repeats until an optimal solution is found.
Feature | Genetic Algorithm | Traditional Optimization (e.g., Gradient Descent) |
---|---|---|
Search Method | Population-based | Single-point search |
Flexibility | Works with any function | Requires differentiable function |
Global vs Local | Finds global optima | May get stuck in local optima |
Mutation | Yes, introduces diversity | No mutation mechanism |
Example Use | Machine learning, game AI | Convex optimization, deep learning |
Knowledge Representation (KR) is a field of Artificial Intelligence (AI) that focuses on how knowledge can be stored, structured, and used in a way that allows machines to process and make intelligent decisions. It defines how information is represented in a format that a computer can understand.
There are four major ways to represent knowledge:
-
Logical Representation – Uses formal logic (e.g., Propositional and First-Order Logic).
- Example:
- "If it rains, the ground will be wet."
- ( \text{Rain} \rightarrow \text{WetGround} )
- Example:
-
Semantic Networks – A graph-based representation where nodes represent concepts and edges represent relationships.
- Example:
- A "Dog" is a "Mammal" → Dog → Mammal
- "A dog has a tail" → Dog → has → Tail
- Example:
-
Frames – A data structure similar to object-oriented programming, where entities have attributes and values.
- Example:
- Object: Car
- Color: Red
- Speed: 120 km/h
- Fuel: Petrol
- Object: Car
- Example:
-
Production Rules – Uses "If-Then" rules to store knowledge.
- Example:
- Rule 1: IF the temperature is below 0°C, THEN water freezes.
- Rule 2: IF a person has a fever, THEN suggest medicine.
- Example:
- Acquire Knowledge – Information is collected from experts, books, or databases.
- Represent Knowledge – The information is stored using one of the KR methods (Logic, Frames, Semantic Networks, or Rules).
- Inference Mechanism – AI applies reasoning (deduction, induction, abduction) to derive new knowledge.
- Update Knowledge – The system must adapt when new information is added.
Imagine an AI that determines whether an animal is a bird:
Feature | Eagle | Penguin | Sparrow |
---|---|---|---|
Has Wings | Yes | Yes | Yes |
Can Fly | Yes | No | Yes |
Lives in Cold | No | Yes | No |
- Production Rule Example:
- IF an animal has wings AND can fly THEN it is a flying bird.
- IF an animal has wings AND NOT can fly THEN it is a non-flying bird.
Using these rules, the AI can infer that an eagle and a sparrow are flying birds, while a penguin is a non-flying bird.
Feature | Knowledge Representation | Database System |
---|---|---|
Focus | Understanding and reasoning | Storing and retrieving data |
Structure | Logical, semantic networks, frames, rules | Tables, rows, columns |
Processing | Inference and decision-making | Query execution |
Example Use | Expert systems, AI chatbots | Banking, inventory management |
A Fuzzy System is a mathematical framework used for dealing with uncertainty and imprecise information. It is based on Fuzzy Logic, which extends classical Boolean logic by allowing values between 0 and 1 instead of only true (1) and false (0). This helps in modeling real-world problems where decisions are not just black and white but have varying degrees of truth.
A fuzzy system operates in the following steps:
- Fuzzification – Converts crisp (exact) inputs into fuzzy values using membership functions.
- Rule Evaluation (Inference Engine) – Uses "If-Then" rules to determine the fuzzy output.
- Defuzzification – Converts the fuzzy output back into a crisp value for decision-making.
Let's consider an air conditioning system that adjusts based on temperature.
-
Temperature Input:
- Cold: ( 0 - 15^\circ C )
- Warm: ( 10 - 30^\circ C )
- Hot: ( 25 - 40^\circ C )
-
Fan Speed Output:
- Slow: 0 - 30%
- Medium: 20 - 70%
- Fast: 60 - 100%
- Rule 1: IF Temperature is Cold, THEN Fan Speed is Slow.
- Rule 2: IF Temperature is Warm, THEN Fan Speed is Medium.
- Rule 3: IF Temperature is Hot, THEN Fan Speed is Fast.
For a temperature of 27°C, it belongs partially to "Warm" and "Hot" categories. Using fuzzy logic, the system calculates the exact fan speed, say 65%, instead of just "medium" or "fast."
Feature | Classical Logic | Fuzzy Logic |
---|---|---|
Values | Strict 0 or 1 (True/False) | Ranges between 0 and 1 |
Handling Uncertainty | Not well-suited | Handles gradual changes well |
Example | "Is the glass full? Yes/No" | "The glass is 70% full" |
Application | Traditional computing | AI, robotics, control systems |
- Control Systems: Air conditioners, washing machines, cruise control.
- AI & Robotics: Decision-making in uncertain environments.
- Medical Diagnosis: Diagnosing diseases based on symptoms.
An Expert System is an AI-based computer system that mimics human expert decision-making. It uses knowledge and inference rules to solve complex problems in specific domains. Expert systems are widely used in fields like medicine, engineering, and business.
- Knowledge Base – Contains facts and expert knowledge (rules, heuristics).
- Inference Engine – Applies logical reasoning to derive conclusions from the knowledge base.
- User Interface – Allows users to interact with the system and receive recommendations.
- Explanation System – Justifies decisions by explaining how conclusions were reached.
- User Input – The system asks the user for relevant information.
- Inference Engine Processes the Knowledge Base –
- Uses IF-THEN rules to analyze input.
- Uses reasoning methods like forward chaining or backward chaining.
- Output Generation – The system provides recommendations or solutions.
- Explanation – The system explains why it made that decision.
- Rule 1: IF the patient has a fever AND cough, THEN they may have the flu.
- Rule 2: IF the patient has high blood sugar, THEN they may have diabetes.
- Rule 3: IF the patient has a fever AND sore throat, THEN they may have strep throat.
- User enters "fever and cough" as symptoms.
- The system matches this input with Rule 1.
- The system outputs: "The patient may have the flu."
- The system provides recommendations: "Take rest, drink fluids, and consider seeing a doctor."
Method | Process | Example |
---|---|---|
Forward Chaining | Starts with facts and applies rules to reach a conclusion. | Given symptoms → Determine disease |
Backward Chaining | Starts with a goal and works backward to find supporting facts. | Given a disease → Check if symptoms match |
Feature | Expert System | Traditional Software |
---|---|---|
Purpose | Mimics human decision-making | Executes predefined instructions |
Knowledge Base | Uses rules and facts | Uses hardcoded logic |
Learning Ability | Can be updated with new rules | Requires reprogramming |
Example Use | Medical diagnosis, legal advice | Payroll system, inventory management |
- Medical Diagnosis (e.g., MYCIN for bacterial infections)
- Business Decision Support
- Engineering Troubleshooting
- Fraud Detection in Banking